Last active
March 6, 2019 22:36
-
-
Save aakbar5/824365f5e3165be17c354c49385638ee to your computer and use it in GitHub Desktop.
makefile: setting variables globally as well as under phony target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GLOBAL_VAR=GOLBAL_VAR_VALUE # This value will be set as it is global | |
export GLOBAL_VAR_EXPORT=GLOBAL_VAR_EXPORT_VALUE # This value will be set as it is global | |
# @$(foreach var, $(filter GB_ENV_%, $(.VARIABLES)), $(eval export $(subst GB_ENV_,,$(var))=$($(var)))) | |
all: | |
# Following two vars remain unset as Makefile doesn't set var under phony target | |
@LOCAL_VAR=LOCAL_VAR_VALUE | |
@export LOCAL_VAR_EXPORT=LOCAL_VAR_EXPORT_VALUE | |
# Following two vars will be set using eval | |
@$(eval LOCAL_VAR_EVAL=LOCAL_VAR_EVAL_VALUE) | |
@$(eval export LOCAL_VAR_EXPORT_EVAL=LOCAL_VAR_EXPORT_EVAL_VALUE) | |
@echo "GLOBAL_VAR : $(GLOBAL_VAR)" | |
@echo "GLOBAL_VAR_EXPORT : $(GLOBAL_VAR_EXPORT)" | |
@echo "LOCAL_VAR : $(LOCAL_VAR)" | |
@echo "LOCAL_VAR_EXPORT : $(LOCAL_VAR_EXPORT)" | |
@echo "LOCAL_VAR_EVAL : $(LOCAL_VAR_EVAL)" | |
@echo "LOCAL_VAR_EXPORT_EVAL : $(LOCAL_VAR_EXPORT_EVAL)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment