forked from AliceLR/megazeux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.in
109 lines (86 loc) · 3.4 KB
/
Makefile.in
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
#
# Nintendo DS Makefile
#
.PHONY: package clean
ifeq ($(strip $(BLOCKSDS)),)
$(error "BLOCKSDS must be set in your environment.")
endif
EXTRA_LICENSES += ${LICENSE_CC0} ${LICENSE_MPL2} ${LICENSE_NEWLIB}
#
# NDS target rules
#
WONDERFUL_TOOLCHAIN ?= /opt/wonderful
ARM_NONE_EABI_PATH ?= $(WONDERFUL_TOOLCHAIN)/toolchain/gcc-arm-none-eabi/bin/
CROSS_COMPILE := ${ARM_NONE_EABI_PATH}arm-none-eabi-
# Don't strip when generating debug symbols.
NO_STRIP_IN_DEBUGLINK ?= 1
# Disable rules that require target code to run natively.
SUPPRESS_HOST_TARGETS ?= 1
#
# Override library paths.
#
EXTRA_LIBS_DIRS := $(BLOCKSDS)/libs/maxmod \
$(BLOCKSDS)/libs/libnds
EXTRA_LIBS_NAMES := -lmm9 -lnds9 -lc -lgcc
EXTRA_INCLUDES := $(foreach path,$(EXTRA_LIBS_DIRS),-I$(path)/include)
EXTRA_LIBS := $(foreach path,$(EXTRA_LIBS_DIRS),-L$(path)/lib) \
-Wl,--start-group $(EXTRA_LIBS_NAMES) -Wl,--end-group
ARCH_CFLAGS += -marm -mcpu=arm946e-s+nofp
ARCH_CFLAGS += ${EXTRA_INCLUDES} -Iarch/nds -ffunction-sections -fdata-sections
ARCH_LDFLAGS += -marm -mcpu=arm946e-s+nofp
ARCH_LDFLAGS += ${EXTRA_LIBS}
ARCH_CFLAGS += -DPICOLIBC_LONG_LONG_PRINTF_SCANF -specs=$(BLOCKSDS)/sys/crts/ds_arm9.specs
ARCH_LDFLAGS += -DPICOLIBC_LONG_LONG_PRINTF_SCANF -specs=$(BLOCKSDS)/sys/crts/ds_arm9.specs
ARCH_CXXFLAGS += ${ARCH_CFLAGS}
ARM7_BINARY := arch/nds-blocksds/megazeux.arm7.elf
#
# Vile hack, remove me ASAP
#
arch/nds/%.o: arch/nds/%.c
$(if ${V},,@echo " CC " $<)
${CC} -MD ${core_cflags} ${core_flags} -Wno-unused-macros -c $< -o $@
arch/nds/render.o: arch/nds/protected_palette.bin.o
arch/nds/%.bin.o arch/nds/%_bin.h : arch/nds/%.bin
$(if ${V},,@echo " CC " $<)
@$(BLOCKSDS)/tools/bin2c/bin2c $< $(@D)
@$(CC) $(CFLAGS) -MMD -MP -c -o arch/nds/$*.bin.o arch/nds/$*_bin.c
package: mzx $(ARM7_BINARY)
$(BLOCKSDS)/tools/ndstool/ndstool -c ${mzxrun}.nds -7 $(ARM7_BINARY) -9 ${mzxrun} -b arch/nds-blocksds/icon.png "MegaZeux ${VERSION} (B)"
#
# Build the ARM7 binary.
#
ARM7_SOURCE_FILES := $(shell find -L arch/nds/arm7/source -name "*.c")
ARM7_DEPEND_FILES := $(addsuffix .d,$(ARM7_SOURCE_FILES))
ARM7_OBJECT_FILES := $(addsuffix .o,$(ARM7_SOURCE_FILES))
ARM7_LIBS_DIRS := $(BLOCKSDS)/libs/maxmod \
$(BLOCKSDS)/libs/libnds
ARM7_LIBS_NAMES := -lmm7 -lnds7 -lc -lgcc
ARM7_INCLUDES := $(foreach path,$(ARM7_LIBS_DIRS),-I$(path)/include)
ARM7_LIBS := $(foreach path,$(ARM7_LIBS_DIRS),-L$(path)/lib) \
-Wl,--start-group $(ARM7_LIBS_NAMES) -Wl,--end-group
$(ARM7_BINARY): $(ARM7_OBJECT_FILES)
$(if ${V},,@echo " LD.7 " $@)
${CC} -o $@ $< -mthumb -specs=$(BLOCKSDS)/sys/crts/ds_arm7.specs \
-Wl,--start-group $(ARM7_LIBS) -Wl,--end-group
arch/nds/arm7/source/%.c.o: arch/nds/arm7/source/%.c
$(if ${V},,@echo " CC.7 " $<)
${CC} -MD -Os -std=gnu11 -specs=$(BLOCKSDS)/sys/crts/ds_arm7.specs \
-Wall -Wno-unused-macros -mcpu=arm7tdmi \
-mthumb $(ARM7_INCLUDES) \
-ffunction-sections -fdata-sections -fomit-frame-pointer \
-c $< -o $@
#
# Misc. helpers.
#
clean:
@rm -f ${mzxrun}.nds arch/nds/*.{d,o} ${ARM7_DEPEND_FILES} ${ARM7_OBJECT_FILES} ${ARM7_BINARY}
@rm -f arch/nds/protected_palette.bin.S arch/nds/protected_palette_bin.h
#
# We're only interested in our packaged binary; remove the ELF intermediaries
#
build := ${build_root}/games/megazeux
build: package ${build}
${CP} arch/nds/pad.config ${build}
${CP} ${mzxrun}.nds ${build}
${RM} ${build}/${mzxrun} ${build}/${mzxrun}.debug
include arch/zip.inc