-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
48 lines (36 loc) · 842 Bytes
/
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
DIR_GUARD=mkdir -p $(@D)
BUILD_PATH := ./build
PROJECT_DIR := ./src
CFILES := $(shell find $(PROJECT_DIR) -type f -name *.c)
HFILES := $(shell find $(PROJECT_DIR) -type f -name *.h)
OBJFILES := $(patsubst %.c, $(BUILD_PATH)/%.o, $(CFILES))
OUTPUT := $(BUILD_PATH)/pico-emu
SANITIZER := \
-fsanitize=address \
-fsanitize=undefined
GCC_FLAGS := \
-g \
-O2 \
-pthread \
-I$(PROJECT_DIR) \
-msse \
-std=c17 \
-m64 \
-Wall \
-Werror
$(BUILD_PATH)/%.o: %.c $(CFILES) $(HFILES)
@$(DIR_GUARD)
@echo " [ C ] $<"
@clang -c $(GCC_FLAGS) $(SANITIZER) -o $@ $<
$(OUTPUT): $(OBJFILES)
@$(DIR_GUARD)
@echo " [ pico-emu ] $(OUTPUT) "
@clang $(OBJFILES) $(SANITIZER) -pthread -o $(OUTPUT)
clean:
rm $(OBJFILES)
rm $(OUTPUT)
all: $(OUTPUT)
run: $(OUTPUT)
$(OUTPUT)
format:
clang-format -i --style=file $(CFILES) $(HFILES)