forked from yellows8/3dshax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.arm9
403 lines (307 loc) · 12.7 KB
/
Makefile.arm9
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
# DATA is a list of directories containing binary files embedded using bin2o
# GRAPHICS is a list of directories containing image files to be converted with grit
#---------------------------------------------------------------------------------
TARGET := 3dshax_arm9
BUILD := build9
SOURCES := 3dshaxarm9 3dshax_common
INCLUDES := include 3dshaxarm9 3dshax_common
DATA := data
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
DEFINES :=
LDNAME := 3dshaxarm9.ld
ARM9BINCPOUT_PATH :=
ifneq ($(strip $(ARM9BINCPOUT_PATH)),)
ARM9BINCPOUT_PATH := $(ARM9BINCPOUT_PATH)
endif
BINCPCMD :=
ifneq ($(strip $(OUTPATH)),)
BINCPCMD := @cp $(OUTPUT).bin $(OUTPATH)$(ARM9BINCPOUT_PATH)
endif
ifeq ($(strip $(DISABLEAES)),)
DEFINES := $(DEFINES) -DENABLEAES
endif
ifeq ($(strip $(DISABLENANDREDIR)),)
DEFINES := $(DEFINES) -DENABLENANDREDIR
endif
ifeq ($(strip $(DISABLE_ARM9DEBUGGING)),)
DEFINES := $(DEFINES) -DENABLE_ARM9DEBUGGING
endif
ifeq ($(strip $(DISABLE_ARM11KERNEL_DEBUG)),)
DEFINES := $(DEFINES) -DENABLE_ARM11KERNEL_DEBUG
endif
ifeq ($(strip $(DISABLE_ARM11KERNEL_PROCSTARTHOOK)),)
DEFINES := $(DEFINES) -DENABLE_ARM11KERNEL_PROCSTARTHOOK
endif
ifneq ($(strip $(DISABLE_ARM11KERNEL_SVCHANDLER_PATCH)),)
DEFINES := $(DEFINES) -DDISABLE_ARM11KERNEL_SVCHANDLER_PATCH
endif
ifneq ($(strip $(DISABLE_NETDEBUG)),)
DEFINES := $(DEFINES) -DDISABLE_NETDEBUG=1
endif
ifneq ($(strip $(ENABLE_ARM11KERNEL_SVCBREAKPATCH)),)
DEFINES := $(DEFINES) -DENABLE_ARM11KERNEL_SVCBREAKPATCH=1
endif
ifeq ($(strip $(DISABLE_GETEXHDRHOOK)),)
DEFINES := $(DEFINES) -DENABLE_GETEXHDRHOOK
endif
ifneq ($(strip $(ENABLE_LOADA9_x01FFB800)),)
DEFINES := $(DEFINES) -DENABLE_LOADA9_x01FFB800
endif
ifneq ($(strip $(LOADA9_x01FFB800_INCFILEPATH)),)
DEFINES := $(DEFINES) -DLOADA9_x01FFB800_INCFILEPATH=\"$(LOADA9_x01FFB800_INCFILEPATH)\"
endif
ifneq ($(strip $(ENABLE_ARM11PROCLIST_OVERRIDE)),)
DEFINES := $(DEFINES) -DENABLE_ARM11PROCLIST_OVERRIDE
endif
ifneq ($(strip $(ENABLE_REGIONFREE)),)
DEFINES := $(DEFINES) -DENABLE_REGIONFREE=1
endif
ifneq ($(strip $(ENABLE_THEMECACHENAME)),)
DEFINES := $(DEFINES) -DENABLE_THEMECACHENAME=1
endif
ifneq ($(strip $(DISABLE_GAMECARDUPDATE)),)
DEFINES := $(DEFINES) -DDISABLE_GAMECARDUPDATE=1
endif
ifeq ($(strip $(ENABLE_REGIONFREE)),2)
DEFINES := $(DEFINES) -DDISABLE_GAMECARDUPDATE=1
endif
ifneq ($(strip $(ADDEXHDR_SYSMODULE_DEPENDENCY)),)
DEFINES := $(DEFINES) -DADDEXHDR_SYSMODULE_DEPENDENCY=$(ADDEXHDR_SYSMODULE_DEPENDENCY)
endif
ifneq ($(strip $(ADDEXHDR_SYSMODULE_DEPENDENCY_PADCHECK)),)
DEFINES := $(DEFINES) -DADDEXHDR_SYSMODULE_DEPENDENCY_PADCHECK=$(ADDEXHDR_SYSMODULE_DEPENDENCY_PADCHECK)
endif
ifneq ($(strip $(ENABLE_BROWSER_APPMEM)),)
DEFINES := $(DEFINES) -DENABLE_BROWSER_APPMEM
endif
ifneq ($(strip $(ENABLE_GAMECARD)),)
DEFINES := $(DEFINES) -DENABLE_GAMECARD
endif
ifneq ($(strip $(ENABLE_ARM11CODELOAD_SERVACCESSCONTROL_OVERWRITE)),)
DEFINES := $(DEFINES) -DENABLE_ARM11CODELOAD_SERVACCESSCONTROL_OVERWRITE=1
endif
ifneq ($(strip $(ENABLE_OLDFS_AUTOLOCATE)),)
DEFINES := $(DEFINES) -DENABLE_OLDFS_AUTOLOCATE=1
endif
ifneq ($(strip $(ENABLE_DMA)),)
DEFINES := $(DEFINES) -DENABLE_DMA=1
endif
ifneq ($(strip $(DISABLE_FSACCESSINFO_OVERWRITE)),)
DEFINES := $(DEFINES) -DDISABLE_FSACCESSINFO_OVERWRITE
endif
ifneq ($(strip $(DISABLE_A9THREAD)),)
DEFINES := $(DEFINES) -DDISABLE_A9THREAD=1
endif
ifneq ($(strip $(ENABLE_CONFIGMEM_DEVUNIT)),)
DEFINES := $(DEFINES) -DENABLE_CONFIGMEM_DEVUNIT=1
endif
ifneq ($(strip $(ENABLE_FIRMLAUNCH_HOOK)),)
DEFINES := $(DEFINES) -DENABLE_FIRMLAUNCH_HOOK=1
endif
ifneq ($(strip $(DISABLE_FIRMLAUNCH_LOADSD)),)
DEFINES := $(DEFINES) -DDISABLE_FIRMLAUNCH_LOADSD=1
endif
ifneq ($(strip $(ENABLE_FIRMLAUNCH_LOADNAND)),)
DEFINES := $(DEFINES) -DENABLE_FIRMLAUNCH_LOADNAND=1
endif
ifneq ($(strip $(ALTSD_FIRMPATH)),)
DEFINES := $(DEFINES) -DALTSD_FIRMPATH=1
endif
ifneq ($(strip $(DISABLE_MATCHINGFIRM_HWCHECK)),)
DEFINES := $(DEFINES) -DDISABLE_MATCHINGFIRM_HWCHECK=1
endif
ifneq ($(strip $(ENABLE_BOOTSAFEFIRM_STARTUP)),)
DEFINES := $(DEFINES) -DENABLE_BOOTSAFEFIRM_STARTUP=1
endif
ifneq ($(strip $(ENABLE_CMDLOGGING)),)
DEFINES := $(DEFINES) -DARM11KERNEL_ENABLECMDLOG
endif
ifneq ($(strip $(CMDLOGGING_PADCHECK)),)
DEFINES := $(DEFINES) -DCMDLOGGING_PADCHECK=$(CMDLOGGING_PADCHECK)
endif
ifneq ($(strip $(CMDLOGGING_PROCNAME0)),)
DEFINES := $(DEFINES) -DCMDLOGGING_PROCNAME0=$(CMDLOGGING_PROCNAME0)
endif
ifneq ($(strip $(CMDLOGGING_PROCNAME1)),)
DEFINES := $(DEFINES) -DCMDLOGGING_PROCNAME1=$(CMDLOGGING_PROCNAME1)
endif
ifneq ($(strip $(CMDLOGGING_ALTPROCNAME)),)
DEFINES := $(DEFINES) -DCMDLOGGING_ALTPROCNAME=$(CMDLOGGING_ALTPROCNAME)
endif
ifneq ($(strip $(CMDLOGGING_IGNORE_PROCNAME)),)
DEFINES := $(DEFINES) -DCMDLOGGING_IGNORE_PROCNAME=$(CMDLOGGING_IGNORE_PROCNAME)
endif
ifneq ($(strip $(CMDLOGGING_CMDHDR_FILTER)),)
DEFINES := $(DEFINES) -DCMDLOGGING_CMDHDR_FILTER=$(CMDLOGGING_CMDHDR_FILTER)
endif
ifneq ($(strip $(ENABLE_DUMP_NANDIMAGE)),)
DEFINES := $(DEFINES) -DENABLE_DUMP_NANDIMAGE
endif
ifneq ($(strip $(NANDREDIR_SECTORNUM)),)
DEFINES := $(DEFINES) -DNANDREDIR_SECTORNUM_=$(NANDREDIR_SECTORNUM)
endif
ifneq ($(strip $(NANDREDIR_SECTORNUM_PADCHECK0)),)
DEFINES := $(DEFINES) -DNANDREDIR_SECTORNUM_PADCHECK0=$(NANDREDIR_SECTORNUM_PADCHECK0)
endif
ifneq ($(strip $(NANDREDIR_SECTORNUM_PADCHECK0VAL)),)
DEFINES := $(DEFINES) -DNANDREDIR_SECTORNUM_PADCHECK0VAL=$(NANDREDIR_SECTORNUM_PADCHECK0VAL)
endif
ifneq ($(strip $(NANDREDIR_SECTORNUM_PADCHECK1)),)
DEFINES := $(DEFINES) -DNANDREDIR_SECTORNUM_PADCHECK1=$(NANDREDIR_SECTORNUM_PADCHECK1)
endif
ifneq ($(strip $(NANDREDIR_SECTORNUM_PADCHECK1VAL)),)
DEFINES := $(DEFINES) -DNANDREDIR_SECTORNUM_PADCHECK1VAL=$(NANDREDIR_SECTORNUM_PADCHECK1VAL)
endif
ifneq ($(strip $(LOADA9_NEW3DSMEM)),)
DEFINES := $(DEFINES) -DLOADA9_NEW3DSMEM
LDNAME := 3dshaxarm9new3dsmem.ld
endif
ifneq ($(strip $(LOADA9_FCRAM)),)
DEFINES := $(DEFINES) -DLOADA9_FCRAM
LDNAME := 3dshaxarm9fcram.ld
endif
ifneq ($(strip $(NEW3DS_MEMDUMPA9_ADR)),)
DEFINES := $(DEFINES) -DNEW3DS_MEMDUMPA9_ADR=$(NEW3DS_MEMDUMPA9_ADR)
endif
ifneq ($(strip $(NEW3DS_MEMDUMPA9_SIZE)),)
DEFINES := $(DEFINES) -DNEW3DS_MEMDUMPA9_SIZE=$(NEW3DS_MEMDUMPA9_SIZE)
endif
ifneq ($(strip $(NEW3DS_MEMDUMPA9_DISABLEVRAMCLR)),)
DEFINES := $(DEFINES) -DNEW3DS_MEMDUMPA9_DISABLEVRAMCLR
endif
ifneq ($(strip $(NEW3DS_ARM9BINLDR_PATCHADDR0)),)
DEFINES := $(DEFINES) -DNEW3DS_ARM9BINLDR_PATCHADDR0=$(NEW3DS_ARM9BINLDR_PATCHADDR0)
endif
ifneq ($(strip $(NEW3DS_ARM9BINLDR_PATCHADDR0_VAL)),)
DEFINES := $(DEFINES) -DNEW3DS_ARM9BINLDR_PATCHADDR0_VAL=$(NEW3DS_ARM9BINLDR_PATCHADDR0_VAL)
endif
ifneq ($(strip $(NEW3DS_ARM9BINLDR_PATCHADDR1)),)
DEFINES := $(DEFINES) -DNEW3DS_ARM9BINLDR_PATCHADDR1=$(NEW3DS_ARM9BINLDR_PATCHADDR1)
endif
ifneq ($(strip $(NEW3DS_ARM9BINLDR_PATCHADDR1_VAL)),)
DEFINES := $(DEFINES) -DNEW3DS_ARM9BINLDR_PATCHADDR1_VAL=$(NEW3DS_ARM9BINLDR_PATCHADDR1_VAL)
endif
ifneq ($(strip $(NEW3DS_ARM9BINLDR_CLRMEM)),)
DEFINES := $(DEFINES) -DNEW3DS_ARM9BINLDR_CLRMEM=$(NEW3DS_ARM9BINLDR_CLRMEM)
endif
ifneq ($(strip $(NEW3DS_ARM9BINLDR_CLRMEM_SIZE)),)
DEFINES := $(DEFINES) -DNEW3DS_ARM9BINLDR_CLRMEM_SIZE=$(NEW3DS_ARM9BINLDR_CLRMEM_SIZE)
endif
ifneq ($(strip $(ENABLE_NIMURLS_PATCHES)),)
DEFINES := $(DEFINES) -DENABLE_NIMURLS_PATCHES
endif
ifneq ($(strip $(NIMPATCHURL_UPDATE)),)
DEFINES := $(DEFINES) -DNIMPATCHURL_UPDATE=\"$(NIMPATCHURL_UPDATE)\"
endif
ifneq ($(strip $(NIMPATCHURL_ECOMMERCE)),)
DEFINES := $(DEFINES) -DNIMPATCHURL_ECOMMERCE=\"$(NIMPATCHURL_ECOMMERCE)\"
endif
ifneq ($(strip $(ENABLE_LOADSD_AESKEYS)),)
DEFINES := $(DEFINES) -DENABLE_LOADSD_AESKEYS
endif
ifneq ($(strip $(MEMDUMPBOOT_SRCADDR)),)
DEFINES := $(DEFINES) -DMEMDUMPBOOT_SRCADDR=$(MEMDUMPBOOT_SRCADDR)
endif
ifneq ($(strip $(MEMDUMPBOOT_DSTADDR)),)
DEFINES := $(DEFINES) -DMEMDUMPBOOT_DSTADDR=$(MEMDUMPBOOT_DSTADDR)
endif
ifneq ($(strip $(MEMDUMPBOOT_SIZE)),)
DEFINES := $(DEFINES) -DMEMDUMPBOOT_SIZE=$(MEMDUMPBOOT_SIZE)
endif
ARCH := -mthumb -mthumb-interwork
CFLAGS := -g -Wall -Os\
-march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
-ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM9 $(DEFINES)
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH) $(DEFINES)
LDFLAGS = -nostartfiles -T../$(LDNAME) -g $(ARCH) -Wl,-Map,$(notdir $*.map)
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project (order is important)
#---------------------------------------------------------------------------------
LIBS :=
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(PNGFILES:.png=.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.arm9
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).bin
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).bin : $(OUTPUT).elf
@$(OBJCOPY) -O binary $< $@
$(BINCPCMD)
@echo "ARM9BINCPOUT_PATH: $(ARM9BINCPOUT_PATH)"
@echo built ... $(notdir $@)
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------