eDeviser
eDeviser

Reputation: 1873

Error in Makefile during a simple check for existing file

within a makefile I need to check if a file exists. Regarding to this answer from holms, I tried it in this way:

all:
    ifeq ("","$(wildcard testFile)")
       echo "File exists"
    else
       echo "File is missing"
    endif

Nevertheless I get this error:

ifeq ("","")
/bin/sh: 1: Syntax error: word unexpected (expecting ")")
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 2

Where is my mistake and how to interpret this syntax error message?

Upvotes: 3

Views: 1800

Answers (1)

user657267
user657267

Reputation: 21000

You've tabbed the make syntax lines, so make is passing them to your shell, get rid of the tabs (also reverse the conditional and remove the quotes)

all:
ifeq (,$(wildcard testFile))
    echo File is missing
else
    echo File exists
endif

Upvotes: 4

Related Questions