diff --git a/script/make-rules/common.mk b/script/make-rules/common.mk index 6e0314402..04ff329e5 100644 --- a/script/make-rules/common.mk +++ b/script/make-rules/common.mk @@ -14,4 +14,49 @@ # ============================================================================== # Makefile helper functions for common tasks -# \ No newline at end of file +# + + + + +# ============================================================================== +# Makefile helper functions for common tasks + +# Help information for the makefile package +define makehelp + @printf "\n\033[1mUsage: make ...\033[0m\n\n\\033[1mTargets:\\033[0m\n\n" + @sed -n 's/^##//p' $< | awk -F':' '{printf "\033[36m%-28s\033[0m %s\n", $$1, $$2}' | sed -e 's/^/ /' + @printf "\n\033[1m$$USAGE_OPTIONS\033[0m\n" +endef + +# Here are some examples of builds +define MAKEFILE_EXAMPLE +# make build BINS=sealer Only a single sealer binary is built. +# make -j $(nproc) all Run tidy gen add-copyright format lint cover build concurrently. +# make gen Generate all necessary files. +# make linux.arm64 sealer is compiled on arm64 platform. +# make verify-copyright Verify the license headers for all files. +# make install-deepcopy-gen Install deepcopy-gen tools if the license is missing. +# make build BINS=sealer V=1 DEBUG=1 Build debug binaries for only sealer. +# make build.multiarch PLATFORMS="linux_arm64 linux_amd64" V=1 Build binaries for both platforms. +endef +export MAKEFILE_EXAMPLE + +# Define all help functions @printf "\n\033[1mCurrent sealer version information: $(shell sealer version):\033[0m\n\n" +define makeallhelp + @printf "\n\033[1mMake example:\033[0m\n\n" + $(call MAKEFILE_EXAMPLE) + @printf "\n\033[1mAriables:\033[0m\n\n" + @echo " DEBUG: $(DEBUG)" + @echo " BINS: $(BINS)" + @echo " PLATFORMS: $(PLATFORMS)" + @echo " V: $(V)" +endef + +# Help information for other makefile packages +CUT_OFF?="---------------------------------------------------------------------------------" +HELP_NAME:=$(shell basename $(MAKEFILE_LIST)) +define smallhelp + @sed -n 's/^##//p' $< | awk -F':' '{printf "\033[36m%-35s\033[0m %s\n", $$1, $$2}' | sed -e 's/^/ /' + @echo $(CUT_OFF) +endef \ No newline at end of file