Skip to content

Instantly share code, notes, and snippets.

@LaughingSun
Last active November 22, 2015 03:02
Show Gist options
  • Save LaughingSun/9528cc4bb8f18acf8904 to your computer and use it in GitHub Desktop.
Save LaughingSun/9528cc4bb8f18acf8904 to your computer and use it in GitHub Desktop.
gnu make is a little hard to understand sometimes... this is telling in regards to how it handles environment variables generally, within rules and within sub makes
root.ruleA You ain't got no kind of feeling inside
export TMP="I got something that'll sho nuff set yo' stuff on fire"
make -C ./submake
make[1]: Entering directory '/home/ismael/Fiddles/make-bug/submake'
child You ain't got no kind of feeling inside
make[1]: Leaving directory '/home/ismael/Fiddles/make-bug/submake'
root.ruleB You ain't got no kind of feeling inside
make -C ./submake
make[1]: Entering directory '/home/ismael/Fiddles/make-bug/submake'
child You ain't got no kind of feeling inside
make[1]: Leaving directory '/home/ismael/Fiddles/make-bug/submake'
root.ruleC You ain't got no kind of feeling inside
make -C ./submake TMP="What I got will knock your pride aside"
make[1]: Entering directory '/home/ismael/Fiddles/make-bug/submake'
child What I got will knock your pride aside
make[1]: Leaving directory '/home/ismael/Fiddles/make-bug/submake'
root.ruleC You ain't got no kind of feeling inside
make -C ./submake
make[1]: Entering directory '/home/ismael/Fiddles/make-bug/submake'
child Tell me something good
make[1]: Leaving directory '/home/ismael/Fiddles/make-bug/submake'
export TMP="You ain't got no kind of feeling inside"
.PHONY: all
all: ruleA ruleB ruleC ruleD
ruleA:
@echo root.ruleA ${TMP}
export TMP="I got something that'll sho nuff set yo' stuff on fire"
$(MAKE) -C ./submake
ruleB:
@echo root.ruleB ${TMP}
$(shell export TMP="You refuse to put anything before your pride")
$(MAKE) -C ./submake
ruleC:
@echo root.ruleC ${TMP}
$(MAKE) -C ./submake TMP="What I got will knock your pride aside"
ruleD:
@echo root.ruleC ${TMP}
$(eval export TMP="Tell me something good")
$(MAKE) -C ./submake
# Note: this should be submake/Makefile, but gisthub doesn't support subdirectories
.PHONY: all
all: child
child:
@echo child ${TMP}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment