LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 620|回复: 1

如何在Makefile里面根据某个文件是否存在选择特定的目标?

[复制链接]
发表于 2005-11-27 15:06:41 | 显示全部楼层 |阅读模式
我打算在default目标中判断某几个特定的文件是否存在。
根据判断结果执行不同的编译目标。
请问,Makefile应该怎么写?

比如如果存在file1 或者 file2 则执行target1目标,否则执行target2目标。
发表于 2005-11-28 00:06:34 | 显示全部楼层
condition := $(shell if [ -f file1 ]; then echo -n file1; fi) $(shell if [ -f file2 ]; then echo -n file2; fi)

ifneq ($(strip $(condition)),)
target1:
    echo target1
else
target2:
    echo target2
endif
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表