when using $ for Bash inside the Makefile you need to double them: $$a for example. I am not familiar with the designation $' , but I must assume that you know what you are doing with it. if it is not a Makefile construct, you also need to double the dollar sign on that.
also the hash sign # completes the shell extension in the Make assessment, so it never sees the correct guy. slipping away from him helps, but I don't have a job yet. [/ p>
I debug it by doing two steps: first set GCCVER as a list of commands without closing $(shell) , and then in the 2nd step GCCVER := $(shell $(GCCVER)) . you can also try this by commenting on the $(shell) step when it doesn't work, using export and creating the "set" recipe:
GCCVER := some commands here #GCCVER := $(shell $(GCCVER)) # expand the commands, commented out now export # all variables available to shell set: set # make sure this is prefixed by a tab, not spaces
Then:
make set | grep GCCVER
[update]:
GCCVER := a=`mktemp` && echo -e '\#include <stdio.h>\nmain() {printf("%u.%u\\n", __GNUC__, __GNUC_MINOR__);}' | gcc -o "$$a" -xc -; "$$a"; rm "$$a" GCCVER := $(shell $(GCCVER)) export default: set jcomeau@intrepid :/tmp$ make | grep GCCVER GCCVER=4.6
And a full circle, getting rid of the extra step:
jcomeau@intrepid :/tmp$ make | grep GCCVER; cat Makefile GCCVER=4.6 GCCVER := $(shell a=`mktemp` && echo -e '\#include <stdio.h>\nmain() {printf("%u.%u\\n", __GNUC__, __GNUC_MINOR__);}' | gcc -o "$$a" -xc -; "$$a"; rm "$$a") export default: set
Using the $' Bash construct:
jcomeau@intrepid :/tmp$ make | grep GCCVER; cat Makefile GCCVER=4.6 GCCVER := $(shell a=`mktemp` && echo $$'\#include <stdio.h>\nmain() {printf("%u.%u\\n", __GNUC__, __GNUC_MINOR__);}' | gcc -o "$$a" -xc -; "$$a"; rm "$$a") export default: set
Since your system does not work the same as mine, I'm going to sort it out and say either use the reinierpost clause, or alternatively:
GCCVER := $(shell gcc -dumpversion | cut -d. -f1,2)