-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile.arm9
More file actions
160 lines (119 loc) · 3.33 KB
/
Makefile.arm9
File metadata and controls
160 lines (119 loc) · 3.33 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# SPDX-License-Identifier: CC0-1.0
#
# SPDX-FileContributor: Antonio Niño Díaz, 2023
BLOCKSDS ?= /opt/blocksds/core
BLOCKSDSEXT ?= /opt/blocksds/external
WONDERFUL_TOOLCHAIN ?= /opt/wonderful
ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/
# Source code paths
# -----------------
SOURCEDIRS := source/arm9 source/common
INCLUDEDIRS := include source
# Defines passed to all files
# ---------------------------
ifeq ($(DEBUG),1)
DEFINES += -DDSWIFI_LOGS
endif
# lwIP requirements
# -----------------
ifeq ($(ENABLE_LWIP),1)
DEFINES += -DDSWIFI_ENABLE_LWIP
SOURCEDIRS += lwip/source
INCLUDEDIRS += lwip/include source/arm9/lwip/include
endif
# Libraries
# ---------
LIBDIRS := $(BLOCKSDS)/libs/libnds
# Build artifacts
# ---------------
ifeq ($(ENABLE_LWIP),1)
ifeq ($(DEBUG),1)
NAME := libdswifi9d
BUILDDIR := build/debug/arm9
else
NAME := libdswifi9
BUILDDIR := build/release/arm9
endif
else
ifeq ($(DEBUG),1)
NAME := libdswifi9d_noip
BUILDDIR := build/debug_noip/arm9
else
NAME := libdswifi9_noip
BUILDDIR := build/release_noip/arm9
endif
endif
ARCHIVE := lib/$(NAME).a
# Tools
# -----
PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi-
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
AR := $(PREFIX)ar
MKDIR := mkdir
RM := rm -rf
# Verbose flag
# ------------
ifeq ($(VERBOSE),1)
V :=
else
V := @
endif
# Source files
# ------------
SOURCES_S := $(shell find -L $(SOURCEDIRS) -name "*.s")
SOURCES_C := $(shell find -L $(SOURCEDIRS) -name "*.c")
SOURCES_CPP := $(shell find -L $(SOURCEDIRS) -name "*.cpp")
# Compiler and linker flags
# -------------------------
DEFINES += -D__NDS__ -DARM9
ARCH := -mcpu=arm946e-s+nofp
WARNFLAGS := -Wall -Wextra -Wstrict-prototypes -Wshadow
INCLUDEFLAGS := $(foreach path,$(INCLUDEDIRS),-I$(path)) \
$(foreach path,$(LIBDIRS),-I$(path)/include)
ASFLAGS += -g -x assembler-with-cpp $(DEFINES) $(ARCH) \
-mthumb -mthumb-interwork $(INCLUDEFLAGS) \
-ffunction-sections -fdata-sections
CFLAGS += -g -std=gnu23 $(WARNFLAGS) $(DEFINES) $(ARCH) \
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -Os \
-ffunction-sections -fdata-sections \
-fomit-frame-pointer
CXXFLAGS += -g -std=gnu++23 $(WARNFLAGS) $(DEFINES) $(ARCH) \
-mthumb -mthumb-interwork $(INCLUDEFLAGS) -Os \
-ffunction-sections -fdata-sections \
-fno-exceptions -fno-rtti \
-fomit-frame-pointer
# Intermediate build files
# ------------------------
OBJS := $(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_S))) \
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_C))) \
$(addsuffix .o,$(addprefix $(BUILDDIR)/,$(SOURCES_CPP)))
DEPS := $(OBJS:.o=.d)
# Targets
# -------
.PHONY: all clean
all: $(ARCHIVE)
$(ARCHIVE): $(OBJS)
@echo " AR.9 $@"
@$(MKDIR) -p $(@D)
$(V)$(AR) rcs $@ $(OBJS)
clean:
@echo " CLEAN.9"
$(V)$(RM) $(ARCHIVE) $(BUILDDIR)
# Rules
# -----
$(BUILDDIR)/%.s.o : %.s
@echo " AS.9 $<"
@$(MKDIR) -p $(@D)
$(V)$(CC) $(ASFLAGS) -MMD -MP -c -o $@ $<
$(BUILDDIR)/%.c.o : %.c
@echo " CC.9 $<"
@$(MKDIR) -p $(@D)
$(V)$(CC) $(CFLAGS) -MMD -MP -c -o $@ $<
$(BUILDDIR)/%.cpp.o : %.cpp
@echo " CXX.9 $<"
@$(MKDIR) -p $(@D)
$(V)$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $<
# Include dependency files if they exist
# --------------------------------------
-include $(DEPS)