Makefile If-Then Else和循环 [英] Makefile If-Then Else and Loops

查看:527
本文介绍了Makefile If-Then Else和循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释如何在Makefile中使用if-then语句和for循环吗?我似乎找不到带有示例的良好文档.

Can someone explain how to use if-then statements and for loops in Makefiles? I can't seem to find any good documentation with examples.

推荐答案

条件表格

简单

conditional-directive
text-if-true
endif

中度复杂

conditional-directive
text-if-true
else
text-if-false
endif

更复杂

conditional-directive
text-if-one-is-true
else
conditional-directive
text-if-true
else
text-if-false
endif
endif

条件指令

语法相等​​

ifeq (arg1, arg2)
ifeq 'arg1' 'arg2'
ifeq "arg1" "arg2"
ifeq "arg1" 'arg2'
ifeq 'arg1' "arg2"

如果语法不相等

ifneq (arg1, arg2)
ifneq 'arg1' 'arg2'
ifneq "arg1" "arg2"
ifneq "arg1" 'arg2'
ifneq 'arg1' "arg2"

如果定义了语法

ifdef variable-name

如果未定义语法

ifndef variable-name  

foreach函数

foreach函数语法

foreach Function Syntax

$(foreach var, list, text)  

foreach语义学
对于列表"中每个由空格分隔的单词,将由"var"命名的变量设置为该单词并执行文本.

foreach Semantics
For each whitespace separated word in "list", the variable named by "var" is set to that word and text is executed.

这篇关于Makefile If-Then Else和循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆