Reputation: 260
I have a gnu Makefile that collects version information through environment variables. Now, I want to do "something" globally before any target is built using the gnumake syntax. As pseudo code, this means:
I tried this:
$(shell if exist $(subst /,\,$(products)filenames.h) del /F/Q $(subst /,\,$(products)filenames.h))
$(foreach Item, $(EnvFilenames), @echo $(Item) >> $(subst /,\,$(products)filenames.h))
this gives me an error:
C:\temp\Makefile.mak:72: *** missing separator. Stop.
where Line 72 is the $(shell ...
line. If I put this in a define
section:
define foobar
$(shell if exist $(subst /,\,$(products)filenames.h) del /F/Q $(subst /,\,$(products)filenames.h))
$(foreach Item, $(EnvFilenames), @echo $(Item) >> $(subst /,\,$(products)filenames.h))
endef
and call this for a target, it runs fine:
$(products)$test.o : test.c $(commons)
$(call foobar)
$(cc) $(cflags_m) test.c -o$@
and does what it should... but as soon as I want to call it from inside of another define
, it fails again with a missing seperator.
What does it mean and how can I fix it?
Compilation takes place on a Win32 platform and does not have to be multi-platform.
Upvotes: 3
Views: 4743
Reputation: 189327
If once per Make invocation is sufficient, you could put it in a global assignment.
# Ignore the value, calling for side effects
IGNORE := $(shell commands with side effects)
I would recommend against this hack, but I can imagine situations where it might come in handy.
Upvotes: 7