Given a colon-delimited list of paths, getting a space-delimited list with GNU Make is straightforward:
CPATHS := /usr/bin/foo:/usr/bin/baz:/usr/bin/baz SPATHS := $(subst :, ,$(CPATHS))
However, I couldn't find a nice way to go the opposite direction. The following hack does work (at least if sed is installed) but I'm pretty sure there will be a nicer way to solve this just using Make's internal functions.
SPATHS := /usr/bin/foo /usr/bin/baz /usr/bin/baz CPATHS := $(shell echo $(SPATHS) > tmp; sed 's/ \+/:/g' tmp; rm tmp)
The variable $@ represents the name of the target and $< represents the first prerequisite required to create the output file.
From the GNU make reference manual: $(subst from,to,text) Performs a textual replacement on the text text: each occurrence of from is replaced by to. The result is substituted for the function call. For example, $(subst ee,EE,feet on the street) substitutes the string 'fEEt on the strEEt'.
And in your scenario, $MAKE is used in commands part (recipe) of makefile. It means whenever there is a change in dependency, make executes the command make --no-print-directory post-build in whichever directory you are on.
MAKEFILE_LIST. Contains the name of each makefile that is parsed by make , in the order in which it was parsed. The name is appended just before make begins to parse the makefile. Thus, if the first thing a makefile does is examine the last word in this variable, it will be the name of the current makefile.
The only tricky part here is to define a literal space:
space := $(subst ,, ) SPATHS := /usr/bin/foo /usr/bin/baz /usr/bin/baz CPATHS := $(subst $(space),:,$(SPATHS))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With