【C/C++】Makefile之automatic variab

2019-12-12  本文已影响0人  Great_Jojo

$@、$<、$^就是automatic variables,具体可参考GNU Make manual: Automatic-Variables

下面用一个简单的例子做一个快速的介绍:

hello: hello_main.c hello.c hello.h
         gcc -o $@ $^

Attention:

When the first dependency is a variable representing a list, $< is evaluated after it is expanded. [2]

LIST = lib1.cpp lib2.cpp
all: $(LIST) main.cpp

这里$< 只是指 lib1.cpp

参考资料:

  1. GNU Make manual: Automatic-Variables, gnu.org.
  2. What do the makefile symbols $@ and $< mean?, stackoverflow.
上一篇下一篇

猜你喜欢

热点阅读