Search code examples
makefilefile-exists

Can't check file existense in a makefile


After reading this answer for "How do I check if file exists in Makefile?" question, I decided to try. I have a file tact1.pdf in the same folder with the makefile.

Code:

FILE = 'tact1.pdf'
all:
ifneq ("$(wildcard $(FILE))","")
    @echo "File exists"
else
    @echo "No file"
endif

Output:

$ make
No file

I tried the full path to the file: same result. What's wrong? OS: Windows XP, using cygwin.


Solution

  • Drop the quotes around the filename. They might be okay in bash or perl, but in a makefile, they are considered the first and last characters of the filename.

    FILE = tact1.pdf