2010-10-14 66 views
3

请解释$ @ $^$在makefile下面makefile文件别名

LIBS = -lkernel32 -luser32 -lgdi32 -lopengl32 
CFLAGS = -Wall 

# (This should be the actual list of C files) 
SRC=$(wildcard '*.c') 

test: $(SRC) 
    gcc -o [email protected] $^ $(CFLAGS) $(LIBS) 
+0

可能重复的[makefile符号$ @和$ <是什么意思?](http://stackoverflow.com/questions/3220277/what-do-the-makefile-symbols-and-mean) – 2015-05-26 13:58:30

回答

6

这就是这两个符号的意思是:

  • $ @是目标即test
  • $ ^是该规则的先决条件列表(其在此情况下是在SRC=$(wildcard '*.c')中指定的扩展通配符列表)

所有这些变量都在GNU make手册的Automatic variables page中解释。

+0

什么是'扩展在SRC = $(通配符'* .c')中指定的通配符列表是什么意思?它只是导致''* .c''? – naught101 2014-04-07 06:21:48

+0

啊,它是[文件匹配通配符](https://www.gnu.org/software/make/manual/html_node/Wildcard-Function.html#Wildcard-Function)。 – naught101 2014-04-07 12:19:37

+0

@ naught101它在答案*通配符列表*中明确陈述,想象一下通配符的shell glob ... :) – t0mm13b 2014-04-07 12:21:52