本文共 816 字,大约阅读时间需要 2 分钟。
轉載自
The following snippet of code can be used to check for the existence of a file from within a Makefile.
ifneq ("$(wildcard $(PATH_TO_FILE))","")FILE_EXISTS = 1elseFILE_EXISTS = 0endif
Quoting from make documentation.
$(wildcard
pattern )
pattern
is a file name pattern, typically containing wildcard
is a space-separated list of the names of existing files In this present case, we are not using any wildcards, but the absolute path to the file.
********************************************************************************************************
If file1
does not exist then $(wildcard file1)
will evaluate to an empty string.
ifeq ($(wildcard file1),) CLEAN_SRC =else CLEAN_SRC = *.h file3endif
转载地址:http://rqsgi.baihongyu.com/