-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
37 lines (28 loc) · 1.27 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
BUILD_DIR := build
CC := clang
LD := ld.lld
TARGET := $(BUILD_DIR)/mod.elf
LDSCRIPT := mod.ld
CFLAGS := -target mips -mips2 -mabi=32 -O2 -G0 -mno-abicalls -mno-odd-spreg -mno-check-zero-division \
-fomit-frame-pointer -ffast-math -fno-unsafe-math-optimizations -fno-builtin-memset \
-Wall -Wextra -Wno-incompatible-library-redeclaration -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-variable \
-Wno-missing-braces -Wno-unsupported-floating-point-opt -Werror=section
CPPFLAGS := -nostdinc -D_LANGUAGE_C -DMIPS -I include -I include/dummy_headers -I mm-decomp/include -I mm-decomp/src -I mm-decomp/assets -I mm-decomp/include/libc
LDFLAGS := -nostdlib -T $(LDSCRIPT) -Map $(BUILD_DIR)/mod.map --unresolved-symbols=ignore-all --emit-relocs -e 0 --no-nmagic
C_SRCS := $(wildcard src/*.c)
C_OBJS := $(addprefix $(BUILD_DIR)/, $(C_SRCS:.c=.o))
C_DEPS := $(addprefix $(BUILD_DIR)/, $(C_SRCS:.c=.d))
$(TARGET): $(C_OBJS) $(LDSCRIPT) | $(BUILD_DIR)
$(LD) $(C_OBJS) $(LDFLAGS) -o $@
$(BUILD_DIR) $(BUILD_DIR)/src:
ifeq ($(OS),Windows_NT)
mkdir $(subst /,\,$@)
else
mkdir -p $@
endif
$(C_OBJS): $(BUILD_DIR)/%.o : %.c | $(BUILD_DIR) $(BUILD_DIR)/src
$(CC) $(CFLAGS) $(CPPFLAGS) $< -MMD -MF $(@:.o=.d) -c -o $@
clean:
rm -rf $(BUILD_DIR)
-include $(C_DEPS)
.PHONY: clean