I have a makefile that used to work with make 3.80. Now I updated to 3.81 and I obtain the following error:
Makefile:185: *** invalid syntax in conditional. Stop.
Line 185 corresponds to:
ifdef $(FDEP_FILES)
A few lines above I define FDEP_FILES
FDEP_FILES += $(addsuffix .df, $(TEST_BASENAMES_FC))
and
TEST_BASENAMES_FC += $(basename $(shell ls *.fc 2> /dev/null ))
The makefile works when there is only one .fc file in the folder, while it fails in case of multiple makefile.
If what you want to is determine whether FDEP_FILES
is defined then the test should be:
ifdef FDEP_FILES
The reason it fails when you have more than one file is that $(FDEP_FILES)
will be expanded to its value and then ifdef
will test whether the variable named with this value is defined. Since the value is not a valid variable name, you get an error.
But note that ifdef
will consider a variable with an empty string as a value as being defined. With the code you've shown us, I'm not convinced that you won't end up with an empty string under some circumstances. You should consider testing with ifneq ($(strip $(FDEP_FILES)),)
. With this test, the branch will be taken only if FDEP_FILES
has a non-empty string as value.