-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
79 lines (61 loc) · 1.7 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
# -- Compilers --
CC = gcc
CXX = g++
# -- Output files --
OUT ?= missing.h preprocessed.h functions.py
# -- Directories --
SRC ?= .
INCLUDES = -I.
LDFLAGS = -L.
# -- Flags --
ifdef DEBUG
CFLAGS += -ggdb -O0 -DDEBUG=1
LDFLAGS += -ggdb -O0 -DDEBUG=1
endif
CFLAGS += $(INCLUDES)
# -- Input Files --
C_FILES = $(wildcard $(SRC)/*.c)
CPP_FILES = $(wildcard $(SRC)/*.cpp) $(wildcard $(SRC)/*.cc)
OBJ_FILES = $(patsubst %.c, %.o, $(C_FILES)) $(patsubst %.cpp, %.o, $(CPP_FILES)) $(patsubst %.cc, %.o, $(CPP_FILES))
# -- Dependencies --
DEPFILE = .depfile
all: $(OUT)
missing.h:
bash missing.sh > "$@"
release:
$(MAKE) -C docker
# Output file
# =========================================================
preprocessed.h: $(OBJ_FILES) missing.h
@echo Collecting $@ from [ $^ ]
cat $^ > $@
functions.py: preprocessed.h script.py
python script.py $<
# Compile source files
# These rules are rewritten into the dependencies file
# =========================================================
.c.o:
@echo Compiling $@ from [ $< ]
$(CC) $(CFLAGS) -E -P -c $< > $@
.cc.o:
@echo Compiling $@ from [ $< ]
$(CXX) $(CFLAGS) -E -P -c $< > $@
.cpp.o:
@echo Compiling $@ from [ $< ]
$(CXX) $(CFLAGS) -E -P -c $< > $@
# Generate dependencies.
# =========================================================
$(DEPFILE):
rm -f $(DEPFILE)
$(CC) -E -MM $(CFLAGS) $(INCLUDES) $(CPP_FILES) $(C_FILES) -MF $(DEPFILE)
clean:
rm -f $(OUT) $(SRC)/*.o $(DEPFILE)
# Generated dependency file. Note the dependencies on
# $(DEPFILE)
# =========================================================
NODEPS:=clean tags svn
ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
-include $(DEPFILE)
endif
.SUFFIXES: .c .cpp
.PHONY: all clean install