学习Makefile第五课------使用判断条件

来源:互联网 发布:淘宝消费群体分析 编辑:程序博客网 时间:2024/04/30 21:21
1.示例
ibs_for_gcc = -lgnu 
normal_libs = 
foo: $(objects) 
ifeq ($(CC),gcc)    ----------------------如果objects = gcc ,执行$(CC) -o foo $(objects) $(libs_for_gcc) ,否则执行else里面的语句
$(CC) -o foo $(objects) $(libs_for_gcc) 
else 
$(CC) -o foo $(objects) $(normal_libs) 
endif 
2.语法
条件表达式的语法为:
<conditional-directive> 
<text-if-true> 
endif 
以及:
<conditional-directive> 
<text-if-true> 
else 
<text-if-false> 
endif
(1)ifeq
  ifeq (<arg1>, <arg2>) ---------arg1和arg2相同为真
(2)ifneq
   ifneq (<arg1>, <arg2>) -------不同为真
(3)ifdef
   ifdef <variable-name> ---------值非空,为真
(4)ifndef
   ifndef <variable-name>---------和“ifdef”是相反的意思
最好不要使用自动变量,也不要分成多个文件
0 0
原创粉丝点击