-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
108 lines (84 loc) · 2.53 KB
/
Makefile
File metadata and controls
108 lines (84 loc) · 2.53 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
BUILD_DIR = build
# libcommon config
export COMMON_OUT_DIR=../$(BUILD_DIR)
IRON_SRC_PATHS = \
src/iron/*.c \
src/iron/opt/*.c \
src/iron/xr17032/*.c \
src/iron/mir/*.c \
src/common/vec.c
COYOTE_SRC_PATHS = \
src/coyote/*.c \
src/common/*.c \
MARS_SRC_PATHS = \
src/mars/*.c \
src/common/*.c \
IRON_SRC = $(wildcard $(IRON_SRC_PATHS))
IRON_OBJECTS = $(IRON_SRC:src/%.c=build/%.o)
COYOTE_SRC = $(wildcard $(COYOTE_SRC_PATHS))
COYOTE_OBJECTS = $(COYOTE_SRC:src/%.c=build/%.o)
MARS_SRC = $(wildcard $(MARS_SRC_PATHS))
MARS_OBJECTS = $(MARS_SRC:src/%.c=build/%.o)
CC ?= gcc
LD = $(CC)
INCLUDEPATHS = -Iinclude/ -Icommon/include/
ASANFLAGS = -fsanitize=undefined -fsanitize=address
CFLAGS = -std=gnu23 -fwrapv -fno-strict-aliasing
WARNINGS = \
-Wall -Wimplicit-fallthrough -Wmaybe-uninitialized \
-Wno-override-init -Wno-enum-compare -Wno-unused -Wno-enum-conversion -Wno-discarded-qualifiers -Wno-strict-aliasing
ALLFLAGS = $(CFLAGS) $(WARNINGS)
OPT = -g3 -O0
LDFLAGS =
ifneq ($(OS),Windows_NT)
CFLAGS += -rdynamic
endif
ifdef ASAN_ENABLE
CFLAGS += $(ASANFLAGS)
LDFLAGS += $(ASANFLAGS)
endif
#include configuration file, if present
-include config.mk
.PHONY: all
all: coyote mars iron-test libiron
bin/libcommon.a:
$(MAKE) -C common
cp $(BUILD_DIR)/libcommon.a bin/libcommon.a
build/%.o: src/%.c
$(shell echo 1>&2 -e "Compiling $<")
@$(CC) -c -o $@ $< -MD $(INCLUDEPATHS) $(ALLFLAGS) $(OPT)
.PHONY: coyote
coyote: bin/coyote
bin/coyote: bin/libiron.a $(COYOTE_OBJECTS)
@$(LD) $(LDFLAGS) $(COYOTE_OBJECTS) -o bin/coyote -Lbin -liron -lcommon
.PHONY: mars
mars: bin/mars
bin/mars: bin/libiron.a $(MARS_OBJECTS)
@$(LD) $(LDFLAGS) $(MARS_OBJECTS) -o bin/mars -Lbin -liron -lm -lcommon
.PHONY: iron-test
iron-test: bin/iron-test
bin/iron-test: bin/libiron.a src/iron/driver/driver.c
@$(CC) src/iron/driver/driver.c -o bin/iron-test $(INCLUDEPATHS) $(CFLAGS) $(OPT) -Lbin -liron -lcommon
bin/libiron.o: $(IRON_OBJECTS) bin/libcommon.a
@$(LD) $(LDFLAGS) $(IRON_OBJECTS) -r -o bin/libiron.o -Lbin -lcommon
.PHONY: libiron
libiron: bin/libiron.a
bin/libiron.a: bin/libiron.o
@ar rcs bin/libiron.a bin/libiron.o
.PHONY: clean
clean:
@rm -rf build/
@rm -rf bin/
@mkdir build/
@mkdir bin/
@mkdir -p $(dir $(IRON_OBJECTS))
@mkdir -p $(dir $(COYOTE_OBJECTS))
@mkdir -p $(dir $(MARS_OBJECTS))
-include $(IRON_OBJECTS:.o=.d)
-include $(COYOTE_OBJECTS:.o=.d)
-include $(MARS_OBJECTS:.o=.d)
# generate compile commands with bear if u got it!!!
# very good highly recommended ʕ·ᴥ·ʔ
.PHONY: bear-gen-cc
bear-gen-cc: clean
bear -- $(MAKE) all iron-test