makefile学习2

  1. 变量赋值

    • = 基本赋值(与位置无关,可能被后面的语句改变)
    • :=覆盖之前的值(与位置有关)
    • ?= 是如果没有被赋值过就赋予等号后面的值
    • += 是添加等号后面的值
  2. strip函数、

    $(strip STRINT)
    函数名称:去空格函数—strip。
    函数功能:去掉字串(若干单词,使用若干空字符分割) “STRINT”开头和结尾的
    空字符,并将其中多个连续空字符合并为一个空字符。
    返回值:无前导和结尾空字符、使用单一空格分割的多单词字符串。
    函数说明:空字符包括空格、[Tab]等不可显示字符
    示例:
    STR = a b c
    LOSTR = $(strip $(STR))
    结果是“a b c”。

  3. filter-out函数

    $(filter-out PATTERN…,TEXT) `
    函数名称 :反过滤函数—filter-out。
    函数功能 :和“filter”函数实现的功能相反。过滤掉字串“TEXT”中所有符合模式“PATTERN”的单词,保留所有不符合此模式的单词。可以有多个模式。存在多个模式时,模式表达式之间使用空格分割。

objects=main1.o foo.o main2.o bar.o 
mains=main1.o main2.o 
$(filter-out $(mains),$(objects)) 
实现了去除变量“objects”中“mains”定义的字串(文件名)功能。它的返回值为“foo.o bar.o”。
  1. touch 的功能
    touch有两个功能:

    • 创建文件
    • 把已存在文件的时间更新为当前系统的时间(默认)

      -c  如果该文件不存在,则不创建该文件
      -r 如:touch -r test1 test2  即:把test2的时间设置成和test1一样
      -t  设置文件的时间

  2. @F

    自动化变量 ( @ F ) T h e f i l e − w i t h i n − d i r e c t o r y p a r t o f t h e f i l e n a m e o f t h e t a r g e t . I f t h e v a l u e o f ‘ (@F) The file-within-directory part of the file name of the target. If the value of ‘ (@F)Thefilewithindirectorypartofthefilenameofthetarget.Ifthevalueof@’ is dir/foo.o then ‘ ( @ F ) ’ i s f o o . o . ‘ (@F)’ is foo.o. ‘ (@F)isfoo.o.(@F)’ is equivalent to ‘$(notdir $@)

  3. $$?

$? is the return code when a program exits or finishes.
( M A K E ) ∣ ∣ e x i t " (MAKE) || exit " (MAKE)exit"$?"
成功返回0,失败返回非0

  1. $< $*.if90
  2. -o $@ -c $*.if90
  3. 控制函数
    • $(error text…): Generates a fatal error where the message is text. N
    • $(warning text…): This function works similarly to the error function, above, except that make doesn’t exit.
    • $(info text…): his function does nothing more than print its (expanded) argument(s) to standard output.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值