-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMakefile
102 lines (85 loc) · 3.81 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
######################################
# _____ _ _____ ____ #
# |_ _(_)_ __ _ _|___ /| _ \ #
# | | | | '_ \| | | | |_ \| | | | #
# | | | | | | | |_| |___) | |_| | #
# |_| |_|_| |_|\__, |____/|____/ #
# |___/ #
# Author: Max Bebök #
# License: MIT #
######################################
BUILD_DIR=build
SOURCE_DIR=src/t3d
INSTALLDIR=$(N64_INST)
include $(N64_INST)/include/n64.mk
src := $(SOURCE_DIR)/t3d.c $(SOURCE_DIR)/t3dmath.c $(SOURCE_DIR)/t3dmodel.c \
$(SOURCE_DIR)/t3ddebug.c $(SOURCE_DIR)/t3dskeleton.c $(SOURCE_DIR)/t3danim.c \
$(SOURCE_DIR)/tpx.c \
$(SOURCE_DIR)/rsp/rsp_tiny3d.S $(SOURCE_DIR)/rsp/rsp_tinypx.S
inc := $(SOURCE_DIR)/t3d.h $(SOURCE_DIR)/t3dmath.h $(SOURCE_DIR)/t3dmodel.h \
$(SOURCE_DIR)/t3ddebug.h $(SOURCE_DIR)/t3dskeleton.h $(SOURCE_DIR)/t3danim.h \
$(SOURCE_DIR)/tpx.h
# N64_CFLAGS += -std=gnu2x -DNDEBUG
N64_CFLAGS += -std=gnu2x -Os -Isrc \
-Wall -Wextra -Werror \
-Wformat-signedness -fno-common \
-Wshadow -Wdouble-promotion -Wformat-security -Wformat-overflow -Wformat-truncation
OBJ = $(BUILD_DIR)/t3dmath.o $(BUILD_DIR)/t3d.o \
$(BUILD_DIR)/t3dmodel.o $(BUILD_DIR)/t3ddebug.o $(BUILD_DIR)/t3dskeleton.o $(BUILD_DIR)/t3danim.o \
$(BUILD_DIR)/tpx.o \
$(BUILD_DIR)/rsp/rsp_tiny3d.o $(BUILD_DIR)/rsp/rsp_tiny3d_clipping.o \
$(BUILD_DIR)/rsp/rsp_tinypx.o
all: $(BUILD_DIR)/libt3d.a
# Static Library
$(BUILD_DIR)/libt3d.a: $(OBJ)
@mkdir -p $(dir $@)
@echo " [LD_LIB] $<"
$(N64_LD) -r -o $(BUILD_DIR)/libt3d.a $^
$(BUILD_DIR)/rsp/rsp_tiny3d.o: $(SOURCE_DIR)/rsp/rspq_triangle.inc
$(BUILD_DIR)/rsp/rsp_tiny3d_clipping.o: $(SOURCE_DIR)/rsp/rspq_triangle.inc
# RSP metadata
$(SOURCE_DIR)/rsp/rsp_tiny3d.h: $(BUILD_DIR)/rsp/rsp_tiny3d.o $(BUILD_DIR)/rsp/rsp_tiny3d_clipping.o
@echo " [RSP_METADATA] $<"
echo "// NOTE: this file is autogenerated by the Makefile of t3d!" > $(SOURCE_DIR)/rsp/rsp_tiny3d.h
$(N64_GCCPREFIX_TRIPLET)objdump -S -t $(BUILD_DIR)/rsp/rsp_tiny3d.elf \
| grep ".data " | grep -v emux \
| awk '{print "#define", "RSP_T3D_" $$5, "0x" $$1;}' \
>> $(SOURCE_DIR)/rsp/rsp_tiny3d.h
$(N64_GCCPREFIX_TRIPLET)objdump -S -t $(BUILD_DIR)/rsp/rsp_tiny3d_clipping.elf \
| grep ".data " | grep -v emux \
| awk '{print "#define", "RSP_T3D_CLIP_" $$5, "0x" $$1;}' \
>> $(SOURCE_DIR)/rsp/rsp_tiny3d.h
$(N64_GCCPREFIX_TRIPLET)objdump -S -t $(BUILD_DIR)/rsp/rsp_tiny3d.elf \
| grep ".text " | grep -v emux \
| awk '{print "#define", "RSP_T3D_CODE_" $$5, "0x" $$1;}' \
>> $(SOURCE_DIR)/rsp/rsp_tiny3d.h
$(N64_GCCPREFIX_TRIPLET)objdump -S -t $(BUILD_DIR)/rsp/rsp_tiny3d_clipping.elf \
| grep ".text " | grep -v emux \
| awk '{print "#define", "RSP_T3D_CODE_CLIP_" $$5, "0x" $$1;}' \
>> $(SOURCE_DIR)/rsp/rsp_tiny3d.h
$(SOURCE_DIR)/rsp/rsp_tinypx.h: $(BUILD_DIR)/rsp/rsp_tinypx.o
@echo " [RSP_METADATA] $<"
echo "// NOTE: this file is autogenerated by the Makefile of t3d!" > $(SOURCE_DIR)/rsp/rsp_tinypx.h
$(N64_GCCPREFIX_TRIPLET)objdump -S -t $(BUILD_DIR)/rsp/rsp_tinypx.elf \
| grep ".data " | grep -v emux \
| awk '{print "#define", "RSP_TPX_" $$5, "0x" $$1;}' \
>> $(SOURCE_DIR)/rsp/rsp_tinypx.h
$(BUILD_DIR)/t3d.o: $(SOURCE_DIR)/rsp/rsp_tiny3d.h
$(BUILD_DIR)/tpx.o: $(SOURCE_DIR)/rsp/rsp_tiny3d.h $(SOURCE_DIR)/rsp/rsp_tinypx.h
# Sources
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.c
@mkdir -p $(dir $@)
@echo " [CC_LIB] $<"
$(N64_CC) -c $(CFLAGS) $(N64_CFLAGS) -o $@ $<
install: all
mkdir -p $(INSTALLDIR)/mips64-elf/include/t3d
install -cv -m 0644 t3d-inst.mk $(INSTALLDIR)/include/t3d.mk
for file in $(inc); do \
install -Cv -m 0644 $$file $(INSTALLDIR)/mips64-elf/include/t3d; \
done
install -Cv -m 0644 $(BUILD_DIR)/libt3d.a $(INSTALLDIR)/mips64-elf/lib
clean:
rm -rf $(BUILD_DIR)
rm -f $(SOURCE_DIR)/rsp/rsp_tiny3d.h
-include $(wildcard $(BUILD_DIR)/*.d)
.PHONY: all clean