生成文件符号$ @和$<是什么?意思是? [英] What do the makefile symbols $@ and $< mean?
本文介绍了生成文件符号$ @和$<是什么?意思是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=main.cpp hello.cpp factorial.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
$(CC) $(CFLAGS) $< -o $@
$@
和$<
到底做什么?
推荐答案
$@
是要生成的文件的名称,而$<
是第一个前提条件(通常是源文件).您可以在 GNU Make手册.
$@
is the name of the file being generated, and $<
the first prerequisite (usually the source file). You can find a list of all these special variables in the GNU Make manual.
例如,考虑以下声明:
all: library.cpp main.cpp
在这种情况下:
-
$@
的计算结果为all
-
$<
的计算结果为library.cpp
-
$^
评估为library.cpp main.cpp
$@
evaluates toall
$<
evaluates tolibrary.cpp
$^
evaluates tolibrary.cpp main.cpp
这篇关于生成文件符号$ @和$<是什么?意思是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文