-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·96 lines (73 loc) · 2.04 KB
/
Makefile
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
INTERNAL_OBJ=__internal_target.o
CLEAN_FILES?=
INCLUDE_DIRS?=
LINK_LIBS?=
LINK_LIB_PATH?=
CFLAGS?=
COMPILE_PREFIX?=
ifdef DEBUG
AT=
else
AT=@
endif
ifdef USEGCC
CC=$(COMPILE_PREFIX)gcc
CXX=$(COMPILE_PREFIX)g++
AR=$(COMPILE_PREFIX)ar
LD=$(COMPILE_PREFIX)ld
STRIP=$(COMPILE_PREFIX)strip
else
CC=$(COMPILE_PREFIX)clang
CXX=$(COMPILE_PREFIX)clang++
AR=$(COMPILE_PREFIX)llvm-ar
LD=$(COMPILE_PREFIX)ld.lld
STRIP=$(COMPILE_PREFIX)llvm-strip
endif
-include options.mk
dirs:=$(shell find . -maxdepth 1 -type d)
dirs:=$(patsubst ./%,%,$(dirs))
dirs:=$(filter-out .%,$(dirs))
dirs:=$(filter-out $(EXCLUDE_DIRS),$(dirs))
SUBDIRS=$(dirs)
CFLAGS+= -O3 -Wall
$(info $(CC))
$(info $(CXX))
CFILES=$(wildcard *.c)
CPPFILES=$(wildcard *.cpp)
CCFILES=$(wildcard *.cc)
SFILES=$(wildcard *.S)
CFILES:=$(filter-out $(EXCLUDE_SRCFILE),$(CFILES))
CPPFILES:=$(filter-out $(EXCLUDE_SRCFILE),$(CPPFILES))
CCFILES:=$(filter-out $(EXCLUDE_SRCFILE),$(CCFILES))
SFILES=$(filter-out $(EXCLUDE_SRCFILE),$(SFILES))
COBJS :=$(patsubst %.c,%.o,$(CFILES))
CPPOBJS:=$(patsubst %.cpp,%.o,$(CPPFILES))
CPPOBJS+=$(patsubst %.cc,%.o,$(CCFILES))
CPPOBJS+=$(patsubst %.S,%.o,$(SFILES))
#$(info $(CPPOBJS))
ALLOBJS:=$(addsuffix /$(INTERNAL_OBJ),$(SUBDIRS))
ALLOBJS:=$(ALLOBJS) $(COBJS) $(CPPOBJS)
CLEAN=clean distclean
.PHONY:$(SUBDIRS) $(CLEAN) $(INTERNAL_OBJ)
ifeq ($(strip $(ALLOBJS)),)
$(INTERNAL_OBJ):
$(AT)$(AR) -rcs $@
else
$(INTERNAL_OBJ):$(COBJS) $(CPPOBJS) $(SUBDIRS)
$(AT)$(LD) -r $(ALLOBJS) -o $@
endif
%.o:%.c
$(AT)$(CC) $(CFLAGS) -c -o $@ $< $(INCLUDE_DIRS) $(LINK_LIB_PATH) -Wl,--start-group $(LINK_LIBS) -Wl,--end-group
%.o:%.cpp
$(AT)$(CXX) $(CFLAGS) -c -o $@ $< $(INCLUDE_DIRS) $(LINK_LIB_PATH) -Wl,--start-group $(LINK_LIBS) -Wl,--end-group
%.o:%.cc
$(AT)$(CXX) $(CFLAGS) -c -o $@ $< $(INCLUDE_DIRS) $(LINK_LIB_PATH) -Wl,--start-group $(LINK_LIBS) -Wl,--end-group
$(SUBDIRS):
$(AT)for everydirectory in $(SUBDIRS);do \
make -C $$everydirectory;\
done
$(CLEAN):
$(AT)rm -rf *.o $(CLEAN_FILES)
$(AT)for everydirectory in $(SUBDIRS);do \
make -C $$everydirectory $@;\
done