From 6f14f15785f43a526efb4abfc105707c055c2793 Mon Sep 17 00:00:00 2001 From: Rejean Loyer Date: Sat, 15 Aug 2020 01:45:13 -0400 Subject: [PATCH] tarball: build system: add variables printing and troubleshooting targets. --- Makefile | 53 -------------------- crossplatform.mk | 124 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index 86156d64d8..655b7eb8ad 100644 --- a/Makefile +++ b/Makefile @@ -1062,57 +1062,4 @@ update_ecs: +cd compiler/ecs && $(_MAKE) -f Makefile.bootstrap clean +cd compiler/ecs && $(_MAKE) -f Makefile.bootstrap -troubleshoot: - @$(call echo,Printing values of some variables.) - @$(call echo,_CF_DIR=$(_CF_DIR)) - @$(call echo,HOST_PLATFORM=$(HOST_PLATFORM)) - @$(call echo,TARGET_PLATFORM=$(TARGET_PLATFORM)) - @$(call echo,PLATFORM=$(PLATFORM)) - @$(call echo,LINUX_HOST=$(LINUX_HOST)) - @$(call echo,LINUX_TARGET=$(LINUX_TARGET)) - @$(call echo,OSX_HOST=$(OSX_HOST)) - @$(call echo,OSX_TARGET=$(OSX_TARGET)) - @$(call echo,WINDOWS_HOST=$(WINDOWS_HOST)) - @$(call echo,WINDOWS_TARGET=$(WINDOWS_TARGET)) - @$(call echo,BSD_HOST=$(BSD_HOST)) - @$(call echo,BSD_TARGET=$(BSD_TARGET)) - @$(call echo,OS=$(OS)) - @$(call echo,OSTYPE=$(OSTYPE)) - @$(call echo,BASH=$(BASH)) - @$(call echo,TERM=$(TERM)) - @$(call echo,SHELL=$(SHELL)) - @$(call echo,WIN_SHELL_COMMANDS=$(WIN_SHELL_COMMANDS)) - @$(call echo,WIN_PS_TOOLS=$(WIN_PS_TOOLS)) - @$(call echo,CCACHE=$(CCACHE)) - @$(call echo,CCACHE_COMPILE=$(CCACHE_COMPILE)) - @$(call echo,CCACHE_PREFIX=$(CCACHE_PREFIX)) - @$(call echo,DISTCC=$(DISTCC)) - @$(call echo,GCC_PREFIX=$(GCC_PREFIX)) - @$(call echo,CC=$(CC)) - @$(call echo,CPP=$(CPP)) - @$(call echo,ECP=$(ECP)) - @$(call echo,ECC=$(ECC)) - @$(call echo,ECS=$(ECS)) - @$(call echo,EAR=$(EAR)) - @$(call echo,AS=$(AS)) - @$(call echo,LD=$(LD)) - @$(call echo,AR=$(AR)) - @$(call echo,STRIP=$(STRIP)) - @$(call echo,UPX=$(UPX)) - @$(call echo,TARGET_ARCH=$(TARGET_ARCH)) - @$(call echo,DESTDIR=$(DESTDIR)) - @$(call echo,PREFIXLIBDIR=$(PREFIXLIBDIR)) - @$(call echo,ARCH=$(ARCH)) - @$(call echo,ARCH_FLAGS=$(ARCH_FLAGS)) - @$(call echo,GIT_REPOSITORY=$(GIT_REPOSITORY)) - @$(call echo,DIR_VER=$(DIR_VER)) - @$(call echo,REPOSITORY_VER=$(REPOSITORY_VER)) - @$(call echo,CPPFLAGS=$(CPPFLAGS)) - @$(call echo,OPENSSL_CONF=$(OPENSSL_CONF)) - @$(call echo,OPENSSL_INCLUDE_DIR=$(OPENSSL_INCLUDE_DIR)) - @$(call echo,OPENSSL_LIB_DIR=$(OPENSSL_LIB_DIR)) - @$(call echo,OPENSSL_BIN_DIR=$(OPENSSL_BIN_DIR)) - @$(call echo,ROOT_ABSPATH=$(ROOT_ABSPATH)) - @$(call echo,DYLD_LIBRARY_PATH=$(DYLD_LIBRARY_PATH)) - .NOTPARALLEL: $(NOT_PARALLEL_TARGETS) diff --git a/crossplatform.mk b/crossplatform.mk index 3e9c9e1f14..2510ca182d 100644 --- a/crossplatform.mk +++ b/crossplatform.mk @@ -1,5 +1,13 @@ +empty := +space := $(empty) $(empty) +str_is = $(if $(subst $2,,$1),,true) +single_goal = $(if $(word 2,$(MAKECMDGOALS)),,$(word 1,$(MAKECMDGOALS))) +single_goal_split = $(subst -,$(space),$1) +goals_is_single_print_target = $(if $(single_goal),$(if $(call str_is,$(word 1,$(single_goal_split)),print),$(if $(call str_is,$(word 2,$(single_goal_split)),var),true,$(if $(call str_is,$(word 2,$(single_goal_split)),substr),$(if $(call str_is,$(word 3,$(single_goal_split)),vars),true,),)),),) ifneq ($(wildcard config.mk),) +ifeq ($(goals_is_single_print_target),) $(info Using config.mk configuration file.) +endif include config.mk endif @@ -445,3 +453,119 @@ ifdef WINDOWS_TARGET endif endif endif + +var_info = $(if $(value $1),$1 = $(value $1),$1 is defined as an empty value) +var_eval = $(if $(value $1),$(if $($1),$1 = $($1),$1 evaluates to an empty value),$1 is defined as an empty value) +var_both = $(if $(value $1),$1 = $(value $1) $(if $($1),$(if $(call str_is,$($1),$(value $1)),(equal to definition),= $($1)),= (empty value)),$1 is defined as an empty value) +var_stat = $(call var_info,$1) [$(origin $1) $(flavor $1)] +var_full = $(call var_both,$1) [$(origin $1) $(flavor $1)] +info_var = $(info $(call $(if $2,$2,var_info),$1)) +info_check_var_defined = $(info $(if $(subst $(space),,$(foreach var,$(.VARIABLES),$(if $(subst $1,,$(var)),,1))),$(call $(if $2,$2,var_info),$1),$1 is not defined)) +info_all_vars = $(foreach var,$(sort $(.VARIABLES)),$(call info_var,$(var),$2)) +info_all_substr_vars = $(foreach var,$(sort $(.VARIABLES)),$(if $(findstring $1,$(var)),$(call info_var,$(var),$2),)) +msg_var_eval_crash = is not provided since evaluating variables that use control flow functions will crash + +NOT_PARALLEL_TARGETS += print-all-vars-info print-all-vars-eval print-all-vars-both print-all-vars-stat print-all-vars-full +.PHONY: print-all-vars-info print-all-vars-eval print-all-vars-both print-all-vars-stat print-all-vars-full +print-all-vars-info: ; @$(call info_all_vars) +print-all-vars-eval: ; @$(info note: print-all-vars-eval $(msg_var_eval_crash)) +print-all-vars-both: ; @$(info note: print-all-vars-both $(msg_var_eval_crash)) +print-all-vars-stat: ; @$(if $(subst all,,$*),$(call info_check_var_defined,$*,var_stat),$(call info_all_vars,var_stat)) +print-all-vars-full: ; @$(info note: print-all-vars-full $(msg_var_eval_crash)) + +NOT_PARALLEL_TARGETS += print-var-info-% print-var-eval-% print-var-both-% print-var-stat-% print-var-full-% +.PHONY: print-var-info-% print-var-eval-% print-var-both-% print-var-stat-% print-var-full-% +print-var-info-%: ; @$(call info_check_var_defined,$*) +print-var-eval-%: ; @$(call info_check_var_defined,$*,var_eval) +print-var-both-%: ; @$(call info_check_var_defined,$*,var_both) +print-var-stat-%: ; @$(call info_check_var_defined,$*,var_stat) +print-var-full-%: ; @$(call info_check_var_defined,$*,var_full) + +NOT_PARALLEL_TARGETS += print-substr-vars-info-% print-substr-vars-eval-% print-substr-vars-both-% print-substr-vars-stat-% print-substr-vars-full-% +.PHONY: print-substr-vars-info-% print-substr-vars-eval-% print-substr-vars-both-% print-substr-vars-stat-% print-substr-vars-full-% +print-substr-vars-info-%: ; @$(call info_all_substr_vars,$*) +print-substr-vars-eval-%: ; @$(call info_all_substr_vars,$*,var_eval) +print-substr-vars-both-%: ; @$(call info_all_substr_vars,$*,var_both) +print-substr-vars-stat-%: ; @$(call info_all_substr_vars,$*,var_stat) +print-substr-vars-full-%: ; @$(call info_all_substr_vars,$*,var_full) + +NOT_PARALLEL_TARGETS += troubleshoot +.PHONY: troubleshoot +troubleshoot: troubleshoot-core troubleshoot-toolchain troubleshoot-openssl troubleshoot-version + +NOT_PARALLEL_TARGETS += troubleshoot-core +.PHONY: troubleshoot-core +troubleshoot-core: + @$(info -- core variables --) + @$(call info_check_var_defined,_CF_DIR,var_full) + @$(call info_check_var_defined,WIN_SHELL_COMMANDS,var_full) + @$(call info_check_var_defined,WIN_PS_TOOLS,var_full) + @$(info -- important environtment variables --) + @$(call info_check_var_defined,OS,var_full) + @$(call info_check_var_defined,OSTYPE,var_full) + @$(call info_check_var_defined,BASH,var_full) + @$(call info_check_var_defined,TERM,var_full) + @$(call info_check_var_defined,SHELL,var_full) + @$(info -- host and target variables --) + @$(call info_check_var_defined,HOST_PLATFORM,var_full) + @$(call info_check_var_defined,TARGET_PLATFORM,var_full) + @$(call info_check_var_defined,PLATFORM,var_full) + @$(call info_check_var_defined,LINUX_HOST,var_full) + @$(call info_check_var_defined,LINUX_TARGET,var_full) + @$(call info_check_var_defined,OSX_HOST,var_full) + @$(call info_check_var_defined,OSX_TARGET,var_full) + @$(call info_check_var_defined,WINDOWS_HOST,var_full) + @$(call info_check_var_defined,WINDOWS_TARGET,var_full) + @$(call info_check_var_defined,BSD_HOST,var_full) + @$(call info_check_var_defined,BSD_TARGET,var_full) + @$(call info_check_var_defined,TARGET_ARCH,var_full) + @$(info -- arch variables --) + @$(call info_check_var_defined,ARCH,var_full) + @$(call info_check_var_defined,ARCH_FLAGS,var_full) + +NOT_PARALLEL_TARGETS += troubleshoot-toolchain +.PHONY: troubleshoot-toolchain +troubleshoot-toolchain: + @$(info -- toolchain variables --) + @$(call info_check_var_defined,GCC_PREFIX,var_full) + @$(call info_check_var_defined,CC,var_full) + @$(call info_check_var_defined,CPP,var_full) + @$(call info_check_var_defined,ECP,var_full) + @$(call info_check_var_defined,ECC,var_full) + @$(call info_check_var_defined,ECS,var_full) + @$(call info_check_var_defined,EAR,var_full) + @$(call info_check_var_defined,AS,var_full) + @$(call info_check_var_defined,LD,var_full) + @$(call info_check_var_defined,AR,var_full) + @$(call info_check_var_defined,STRIP,var_full) + @$(info -- related variables --) + @$(call info_check_var_defined,UPX,var_full) + @$(call info_check_var_defined,CCACHE,var_full) + @$(call info_check_var_defined,CCACHE_COMPILE,var_full) + @$(call info_check_var_defined,CCACHE_PREFIX,var_full) + @$(call info_check_var_defined,DISTCC,var_full) + @$(info -- more related variables --) + @$(call info_check_var_defined,DESTDIR,var_full) + @$(call info_check_var_defined,PREFIXLIBDIR,var_full) + @$(call info_check_var_defined,CPPFLAGS,var_full) + @$(call info_check_var_defined,ROOT_ABSPATH,var_full) + @$(call info_check_var_defined,DYLD_LIBRARY_PATH,var_full) + +NOT_PARALLEL_TARGETS += troubleshoot-openssl +.PHONY: troubleshoot-openssl +troubleshoot-openssl: + @$(info -- toolchain variables --) + @$(call info_check_var_defined,OPENSSL_CONF,var_full) + @$(call info_check_var_defined,OPENSSL_INCLUDE_DIR,var_full) + @$(call info_check_var_defined,OPENSSL_LIB_DIR,var_full) + @$(call info_check_var_defined,OPENSSL_BIN_DIR,var_full) + +NOT_PARALLEL_TARGETS += troubleshoot-version +.PHONY: troubleshoot-version +troubleshoot-version: + @$(info -- version variables --) + @$(call info_check_var_defined,GIT_REPOSITORY,var_full) + @$(call info_check_var_defined,DIR_VER,var_full) + @$(call info_check_var_defined,REPOSITORY_VER,var_full) + +.DEFAULT_GOAL =