-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (41 loc) · 982 Bytes
/
Copy pathMakefile
File metadata and controls
51 lines (41 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
CROSS_COMPILE =
AS = $(CROSS_COMPILE)as
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
AR = $(CROSS_COMPILE)ar
CPP = $(CC) -E
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
export AS CC LD AR CPP NM
export STRIP OBJCOPY OBJDUMP
# 编译选项
CFLAGS := -Wall -O2 -g
CFLAGS += -I $(shell pwd)/include
LDFLAGS := -lpthread
export CFLAGS LDFLAGS
# 指定顶层目录,并导出
# 这是因为在递归编译过程中多次调用顶层 Makefile.build
# 所以要把顶层路径导出
TOPDIR := $(shell pwd)
export TOPDIR
# 目标文件
TARGET := test_makefile
# 顶层依赖文件
obj-y += main.o
obj-y += a.o
obj-y += sub-dir-1/
obj-y += sub-dir-2/
# 第一个规则
all:
make -f Makefile.build
$(CC) -o $(TARGET) built-in.o $(LDFLAGS)
# clean
clean:
rm -f $(shell find -name '*.o')
rm -f $(TARGET)
distclean:
rm -f $(shell find -name '*.o')
rm -f $(shell find -name '*.d')
rm -f $(TARGET)