I have a command with two dollar signs (secondary expansion)
$(PREFIX)/bin/gdk-pixbuf-query-loaders > $(shell $(PREFIX)/bin/gdk-pixbuf-query-loaders | awk -F "=" '/LoaderDir/ {print $$2}' | tr -d ' ')/../loaders.cache
The shell command should extract a path from the following output:
...
# LoaderDir = /home/redux/x-libs/i686-nptl-linux-gnu/lib/gdk-pixbuf-2.0/2.10.0/loaders
...
When I run make then the rule expands to the following command:
/home/redux/x-libs/i686-nptl-linux-gnu/bin/gdk-pixbuf-query-loaders > /home/redux/x-libs/i686-nptl-linux-gnu/lib/gdk-pixbuf-2.0/2.10.0/loaders/../loaders.cache
That's OK, but if I use a second makefile that starts the first one, then the rule expands to
/home/redux/x-libs/i686-nptl-linux-gnu/bin/gdk-pixbuf-query-loaders > /../loaders.cache
and an error occures:
/bin/sh: 11: cannot create /../loaders.cache: Permission denied
The command to start the first makefile from the second makefile is as follows:
$(MAKE) -f $(makefile_path)/build_libs_for_host.mk .print_and_write_triplets $(RULES) JOBS=$(JOBS) HOST=$(patsubst build_host_%,%,$@)
And the command (in bash) to start the second makefile (that starts the first one I created) is:
time make -f ~/_dev/_pro/second.mk all RULES=build_gdk_pixbuf JOBS=-j4 |& tee ~/log_20170221_x-libs.txt
Both makefiles use .SECONDEXPANSION:
. I can't see the mistake.
Now I'm stuck. What's wrong with this expansion?
GNU make has some magic rules and maybe I have to add a parameter to the $(MAKE)
line?