forked from tomasz-lisowski/swsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
56 lines (48 loc) · 1.4 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
DIR_LIB:=lib
include $(DIR_LIB)/make-pal/pal.mak
DIR_SRC:=src
DIR_INCLUDE:=include
DIR_BUILD:=build
CC:=gcc
MAIN_NAME:=swsim
MAIN_SRC:=$(wildcard $(DIR_SRC)/*.c)
MAIN_OBJ:=$(MAIN_SRC:$(DIR_SRC)/%.c=$(DIR_BUILD)/$(MAIN_NAME)/%.o)
MAIN_DEP:=$(MAIN_OBJ:%.o=%.d)
MAIN_CC_FLAGS:=\
-W \
-Wall \
-Wextra \
-Werror \
-Wno-unused-parameter \
-Wconversion \
-Wshadow \
-O2 \
-I$(DIR_INCLUDE) \
-I$(DIR_LIB)/swicc/include \
-L$(DIR_LIB)/swicc/build \
-lswicc
MAIN_LIBSWICC_TARGET:=main
all: main
.PHONY: all
main: $(DIR_BUILD) $(DIR_BUILD)/$(MAIN_NAME) $(DIR_BUILD)/$(MAIN_NAME).$(EXT_BIN)
main-dbg: MAIN_LIBSWICC_TARGET:=main-dbg-asan ARG="-DDEBUG_CLR"
main-dbg: MAIN_CC_FLAGS+=-g -DDEBUG -DDEBUG_CLR -fsanitize=address
main-dbg: main
.PHONY: main main-dbg
# Build swSIM.
$(DIR_BUILD)/$(MAIN_NAME).$(EXT_BIN): $(DIR_LIB)/swicc/build/$(LIB_PREFIX)swicc.$(EXT_LIB_STATIC) $(MAIN_OBJ)
$(CC) $(MAIN_OBJ) -o $(@) $(MAIN_CC_FLAGS)
# Build swICC.
$(DIR_LIB)/swicc/build/$(LIB_PREFIX)swicc.$(EXT_LIB_STATIC):
cd $(DIR_LIB)/swicc && $(MAKE) $(MAIN_LIBSWICC_TARGET)
# Compile source files to object files.
$(DIR_BUILD)/$(MAIN_NAME)/%.o: $(DIR_SRC)/%.c
$(CC) $(<) -o $(@) $(MAIN_CC_FLAGS) -c -MMD
# Recompile source files after a header they include changes.
-include $(MAIN_DEP)
$(DIR_BUILD) $(DIR_BUILD)/$(MAIN_NAME):
$(call pal_mkdir,$(@))
clean:
$(call pal_rmdir,$(DIR_BUILD))
cd $(DIR_LIB)/swicc && $(MAKE) clean
.PHONY: clean