我的 Makefile 这样写不对么?
时间:2010-06-26
来源:互联网
target1 target2 target3:
@make $@_compile
ifneq ($@,target1)
@echo "#### target_name = target1"
else
@echo "#### target_name = target_others"
endif
target1_compile:
@echo "#### compile for target1"
target2_compile:
@echo "#### compile for target2"
target3_compile:
@echo "#### compile for target3"
---------------------------------------------
注释:
我这段 Makefile 的作用很简单,目的就是:
(1) 当输入 make target1 时,希望输出结果如下
#### target_name = target1
#### compile for target1
(2) 当输出 make target2 时,希望输出结果如下
#### target_name = target2
#### compile for target2
但是结果并不是,输入 make target1 结果如预期,但是 (2) 的输出结果如下:
#### target_name = target1
#### compile for target2
看样子,好像是 ifneq 写的有问题?大家帮忙看下这句有啥问题啊?
@make $@_compile
ifneq ($@,target1)
@echo "#### target_name = target1"
else
@echo "#### target_name = target_others"
endif
target1_compile:
@echo "#### compile for target1"
target2_compile:
@echo "#### compile for target2"
target3_compile:
@echo "#### compile for target3"
---------------------------------------------
注释:
我这段 Makefile 的作用很简单,目的就是:
(1) 当输入 make target1 时,希望输出结果如下
#### target_name = target1
#### compile for target1
(2) 当输出 make target2 时,希望输出结果如下
#### target_name = target2
#### compile for target2
但是结果并不是,输入 make target1 结果如预期,但是 (2) 的输出结果如下:
#### target_name = target1
#### compile for target2
看样子,好像是 ifneq 写的有问题?大家帮忙看下这句有啥问题啊?
作者: anank 发布时间: 2010-06-26
ifneq ($@,target1)
@echo "#### target_name = target1"
else
@echo "#### target_name = target_others"
endif
ifneq表示()表示参数是否不相等,不相等才进入TURE的部分。
貌似#@也有问题,它不是指全部的目标文件集吗?好好理解下逻辑
@echo "#### target_name = target1"
else
@echo "#### target_name = target_others"
endif
ifneq表示()表示参数是否不相等,不相等才进入TURE的部分。
貌似#@也有问题,它不是指全部的目标文件集吗?好好理解下逻辑
作者: cnfcpidtf111 发布时间: 2010-06-26
不知道楼主在研究什么高深秘籍
一片混乱
一片混乱

作者: ah13k 发布时间: 2010-06-26
make evaluates conditionals when it reads a makefile. Consequently, you cannot use automatic variables in the tests of conditionals because they are not defined until commands are run (see Automatic Variables).
作者: EricFisher 发布时间: 2010-06-26
换句话说,你可以测试一下条件判断中的$@是未定义,或者为空。
ifndef $@
ifeq ($@, )
ifndef $@
ifeq ($@, )
作者: EricFisher 发布时间: 2010-06-26
回复 EricFisher
明白了。
谢谢大家的回复。
我的表达方面也有些问题,哈哈,以后改正。
明白了。
谢谢大家的回复。
我的表达方面也有些问题,哈哈,以后改正。
作者: anank 发布时间: 2010-06-27
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28