Skip to content

Instantly share code, notes, and snippets.

@deryni
Last active March 24, 2016 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deryni/3615cc5f03760abecf51 to your computer and use it in GitHub Desktop.
Save deryni/3615cc5f03760abecf51 to your computer and use it in GitHub Desktop.
Sub-make exporting test for http://stackoverflow.com/q/36158577/258523
export lst :=
$(warning Using make $(MAKE_VERSION))
tmp := a
lst += $(tmp)
$(warning lst is $(value lst):$(flavor lst))
tmp := b
lst += $(tmp)
$(warning lst is $(value lst):$(flavor lst))
all:
$(MAKE) -f sub.mk
+ make -f main.mk -s
main.mk:3: Using make 3.81
main.mk:7: lst is a:simple
main.mk:11: lst is a b:simple
sub.mk:1: MAKEFLAGS:s
sub.mk:2: MAKEOVERRIDES:
sub.mk:3: -*-command-variables-*-:
sub.mk:7: lst is a b $(tmp):recursive
sub.mk:11: lst is a b $(tmp) $(tmp):recursive
+ make -f main.mk -s lst=foo
main.mk:3: Using make 3.81
main.mk:7: lst is foo:recursive
main.mk:11: lst is foo:recursive
sub.mk:1: MAKEFLAGS:s
sub.mk:2: MAKEOVERRIDES:${-*-command-variables-*-}
sub.mk:3: -*-command-variables-*-:lst=foo
sub.mk:7: lst is foo $(tmp):recursive
sub.mk:11: lst is foo $(tmp) $(tmp):recursive
+ make -f main.mk -s lst:=foo
main.mk:3: Using make 3.81
main.mk:7: lst is foo:simple
main.mk:11: lst is foo:simple
sub.mk:1: MAKEFLAGS:s
sub.mk:2: MAKEOVERRIDES:${-*-command-variables-*-}
sub.mk:3: -*-command-variables-*-:lst:=foo
sub.mk:7: lst is foo c:simple
sub.mk:11: lst is foo c d:simple
+ make-4.1/make -f main.mk -s
main.mk:3: Using make 4.1
main.mk:7: lst is a:simple
main.mk:11: lst is a b:simple
sub.mk:1: MAKEFLAGS:s
sub.mk:2: MAKEOVERRIDES:
sub.mk:3: -*-command-variables-*-:
sub.mk:7: lst is a b $(tmp):recursive
sub.mk:11: lst is a b $(tmp) $(tmp):recursive
+ make-4.1/make -f main.mk -s lst=foo
main.mk:3: Using make 4.1
main.mk:7: lst is foo:recursive
main.mk:11: lst is foo:recursive
sub.mk:1: MAKEFLAGS:s
sub.mk:2: MAKEOVERRIDES:${-*-command-variables-*-}
sub.mk:3: -*-command-variables-*-:lst=foo
sub.mk:7: lst is foo $(tmp):recursive
sub.mk:11: lst is foo $(tmp) $(tmp):recursive
+ make-4.1/make -f main.mk -s lst:=foo
main.mk:3: Using make 4.1
main.mk:7: lst is foo:simple
main.mk:11: lst is foo:simple
sub.mk:1: MAKEFLAGS:s
sub.mk:2: MAKEOVERRIDES:${-*-command-variables-*-}
sub.mk:3: -*-command-variables-*-:lst:=foo
sub.mk:7: lst is foo c:simple
sub.mk:11: lst is foo c d:simple
#!/bin/sh
set -x
{
make -f main.mk -s
make -f main.mk -s lst=foo
make -f main.mk -s lst:=foo
} > OUTPUT
$(warning MAKEFLAGS:$(value MAKEFLAGS))
$(warning MAKEOVERRIDES:$(value MAKEOVERRIDES))
$(warning -*-command-variables-*-:$(value -*-command-variables-*-))
tmp := c
override lst += $(tmp)
$(warning lst is $(value lst):$(flavor lst))
tmp := d
override lst += $(tmp)
$(warning lst is $(value lst):$(flavor lst))
all: ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment