In a makefile for GNU Make I use this idiom to test whether a file exists:
static:
ifeq ($(wildcard $(FileName)),)
# do something when the file doesn't exist
else
# do something different when it does
endif
But it doesn't work in NMake (fatal error U1000: syntax error : ')' missing in macro invocation
). How can I replace it? It would be perfect if the replacement works in both build systems.
csharptest.net's answer is almost on point, but it lacks a minuscule detail regarding the difference in indentation rules between commands and directives:
static:
!if exists($(FileName))
@echo $(FileName) does exist!
#^^^ DO MIND THE INDENTATION HERE, a command shall fail otherwise!
#
!else
!error $(FileName) does not exist!
#^^^^^ !directives don't have to be indented, though.
#
!endif
Oddly enough, it can be either exist
(as given in official docs) or exists
to the same effect.