Skip to content

Instantly share code, notes, and snippets.

@songtianlun
Last active October 10, 2020 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save songtianlun/8984626fd80cd20b7c2e71f95caaf8d1 to your computer and use it in GitHub Desktop.
Save songtianlun/8984626fd80cd20b7c2e71f95caaf8d1 to your computer and use it in GitHub Desktop.
A Makefile that can batch single c file.
# 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment