gist: https://gist.github.com/songtianlun/8984626fd80cd20b7c2e71f95caaf8d1
代码语言:javascript复制# Batch Single C file MakeFile
# 指定CPU架构 Architecture -> ARCH
ARCH ?=
CC = $(ARCH)gcc
SUFFIX = .c
CFLAGS = -Wall -g
LD =
CUR_SOURCE = $(wildcard *$(SUFFIX))
CUR_TARGETS = $(patsubst %$(SUFFIX), %, $(CUR_SOURCE))
all:$(CUR_TARGETS)
# %:%.c 是一个表示与目标相同 文件的模式变量
$(CUR_TARGETS):%:%$(SUFFIX)
$(CC) $< $(CFLAGS) -o $@ $(LD)
# 指定伪目标
.PHONY:clean all
clean:
-rm -rf $(TARGETS)
参考文献
- arch 这个词到底是什么意思?:https://www.v2ex.com/t/389388
- 玩转Makefile | 一次编译多个目标:https://blog.csdn.net/yychuyu/article/details/79950414
Author: Frytea
Title: Makefile实例:批量编译多个目标
Link: https://cloud.tencent.com/developer/article/1730098
Copyright: This work by TL-Song is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.