-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
129 lines (108 loc) · 3.82 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#======================================================================================================================#
CC_SRC := $(wildcard *.c)
CC_SRC += $(wildcard platform/*.c)
CC_SRC += $(wildcard platform/math/*.c)
CC_SRC += $(wildcard genshin_clock/*.c)
CC_SRC += $(wildcard genshin_clock/resources/*.c)
CC_SRC += $(wildcard Arm-2D/Library/Source/*.c)
CC_SRC += $(wildcard Arm-2D/Helper/Source/*.c)
CC_SRC += $(wildcard Arm-2D/examples/common/asset/*.c)
CC_SRC += $(wildcard Arm-2D/examples/common/benchmark/*.c)
CC_SRC += $(wildcard Arm-2D/examples/common/controls/*.c)
CC_INC := .
CC_INC += genshin_clock
CC_INC += platform
CC_INC += platform/math
CC_INC += platform/math/dsp
CC_INC += Arm-2D/Library/Include
CC_INC += Arm-2D/Helper/Include
CC_INC += Arm-2D/examples/common/benchmark
CC_INC += Arm-2D/examples/common/controls
CC_DEF := ARM_SECTION\(x\)=
CC_DEF += __va_list=va_list
CC_DEF += _RTE_=1
#======================================================================================================================#
ifeq ($(OS),Windows_NT)
CROSS := i686-w64-mingw32-
CC := $(CROSS)gcc
STRIP := $(CROSS)strip
SIZE := $(CROSS)size
OUT := build/arm_2d.exe
RM := cmd /c rd /s /q
CC_INC += sdl2/32/include
LD_INC := sdl2/32/lib/x86
LD_LIB := SDL2main SDL2
CCFLAG += -w
LDFLAG += -Wl,--warn-common
LDFLAG += -Wl,--gc-sections
app: build/SDL2.dll $(OUT)
else ifeq ($(shell uname), Darwin)
# Code for OS X
CC := $(CROSS)gcc
STRIP := $(CROSS)strip
SIZE := $(CROSS)size
OUT := build/arm_2d
RM := rm -rf
CCFLAG += -DSDL_DISABLE_ARM_NEON_H -D_THREAD_SAFE
CC_INC += /opt/homebrew/include
LD_INC += /opt/homebrew/lib
LD_LIB := SDL2 SDL2main
app: $(OUT)
else
CC := $(CROSS)gcc
STRIP := $(CROSS)strip
SIZE := $(CROSS)size
OUT := build/arm_2d
RM := rm -rf
CCFLAG += -w
LD_LIB := SDL2
LDFLAG += -Wl,--warn-common
LDFLAG += -Wl,--gc-sections
app: $(OUT)
endif
#======================================================================================================================#
CCFLAG += -std=gnu11 -MMD -g
CCFLAG += -ffunction-sections -fdata-sections
CCFLAG += -fno-ms-extensions
CCFLAG += -Wno-macro-redefined
CCFLAG += -Ofast
CCFLAG += -flto
LDFLAG += -flto
LDFLAG += -lpthread
#======================================================================================================================#
.DEFAULT_GOAL = all
_Comma := ,
ifeq (${wildcard obj},)
$(shell mkdir obj)
endif
ifeq (${wildcard build},)
$(shell mkdir build)
endif
CC_OBJ := $(addprefix obj/,$(addsuffix .o,$(notdir $(CC_SRC))))
$(foreach src,$(CC_SRC),$(eval obj/$(notdir $(src)).o : $(src)))
-include $(CC_OBJ:%.o=%.d)
CCSuffix := $(CCFLAG) $(addprefix -I,$(CC_INC)) $(addprefix -D,$(CC_DEF))
LDObject := $(CC_OBJ) $(addprefix -l,$(LD_LIB))
LDSuffix := $(LDFLAG) $(addprefix -Wl$(_Comma)-L,$(LD_INC))
#======================================================================================================================#
.PHONY: all
all: app
@echo Build Completed.
#----------------------------------------------------------------------------------------------------------------------#
build/SDL2.dll:
@echo Copy SDL2.dll
@-cmd /c copy sdl2\32\bin\SDL2.dll build\SDL2.dll
#----------------------------------------------------------------------------------------------------------------------#
$(OUT): $(CC_OBJ)
@echo Linking $(OUT) ...
@$(CC) $(LDObject) $(LDSuffix) -o $(OUT)
#----------------------------------------------------------------------------------------------------------------------#
obj/%.c.o:
@echo Compile $(@F:.o=) ...
@$(CC) -c $< -o $@ $(CCSuffix)
#----------------------------------------------------------------------------------------------------------------------#
.PHONY: clean
clean:
@-$(RM) build
@-$(RM) obj
@echo Clean Completed.