mirror of
https://github.com/pret/pmd-red.git
synced 2024-11-22 20:50:07 +00:00
Makefile overhaul
Addition of a build directory, and more flexible to allow for possible blue build.
This commit is contained in:
parent
97ab00ba21
commit
9e5147a9ad
@ -10,7 +10,7 @@ Then get the compiler from https://github.com/pret/agbcc and run the following c
|
||||
install.sh PATH_OF_PMD-RED_DIRECTORY
|
||||
${DEVKITARM}/bin/arm-none-eabi/ranlib PATH_OF_PMD-RED_DIRECTORY/tools/agbcc/lib/libgcc.a lib/libc.a
|
||||
|
||||
Then in the pokeruby directory, build the tools.
|
||||
Then in the pmd-red directory, build the tools.
|
||||
|
||||
build_tools.sh
|
||||
|
||||
@ -22,6 +22,6 @@ Finally, build the rom.
|
||||
|
||||
Install [**devkitARM**](http://devkitpro.org/wiki/Getting_Started/devkitARM).
|
||||
|
||||
Then get the compiled tools from https://github.com/pret/pokeruby-tools. Copy the `tools/` folder over the `tools/` folder in your pokeruby directory.
|
||||
Then get the compiled tools from https://github.com/pret/pokeruby-tools. Copy the `tools/` folder over the `tools/` folder in your pmd-red directory.
|
||||
|
||||
You can then build pokeruby using `make` in the MSYS environment provided with devkitARM.
|
||||
You can then build pmd-red using `make` in the MSYS environment provided with devkitARM.
|
||||
|
174
Makefile
174
Makefile
@ -1,99 +1,115 @@
|
||||
AS := $(DEVKITARM)/bin/arm-none-eabi-as
|
||||
ASFLAGS := -mcpu=arm7tdmi
|
||||
include $(DEVKITARM)/base_tools
|
||||
|
||||
CC1 := tools/agbcc/bin/agbcc
|
||||
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Wunused -Werror -O2 -fhex-asm
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
CPP := $(DEVKITARM)/bin/arm-none-eabi-cpp
|
||||
CPPFLAGS := -I tools/agbcc/include -iquote include -nostdinc -undef
|
||||
|
||||
LD := $(DEVKITARM)/bin/arm-none-eabi-ld
|
||||
#### Tools ####
|
||||
|
||||
OBJCOPY := $(DEVKITARM)/bin/arm-none-eabi-objcopy
|
||||
|
||||
LIBGCC := tools/agbcc/lib/libgcc.a
|
||||
LIBC := tools/agbcc/lib/libc.a
|
||||
|
||||
MD5 := md5sum -c
|
||||
|
||||
GFX := tools/gbagfx/gbagfx
|
||||
AIF := tools/aif2pcm/aif2pcm
|
||||
MID := tools/mid2agb/mid2agb
|
||||
SCANINC := tools/scaninc/scaninc
|
||||
PREPROC := tools/preproc/preproc
|
||||
SHELL := /bin/bash -o pipefail
|
||||
AS := $(PREFIX)as
|
||||
CC1 := tools/agbcc/bin/agbcc
|
||||
CPP := $(PREFIX)cpp
|
||||
LD := $(PREFIX)ld
|
||||
OBJCOPY := $(PREFIX)objcopy
|
||||
SHA1SUM := sha1sum -c
|
||||
GBAGFX := tools/gbagfx/gbagfx
|
||||
AIF2PCM := tools/aif2pcm/aif2pcm
|
||||
MID2AGB := tools/mid2agb/mid2agb
|
||||
PREPROC := tools/preproc/preproc
|
||||
SCANINC := tools/scaninc/scaninc
|
||||
RAMSCRGEN := tools/ramscrgen/ramscrgen
|
||||
|
||||
# Clear the default suffixes.
|
||||
.SUFFIXES:
|
||||
ASFLAGS := -mcpu=arm7tdmi
|
||||
override CC1FLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Wunused -Werror -O2 -fhex-asm
|
||||
CPPFLAGS := -I tools/agbcc/include -iquote include -nostdinc -undef
|
||||
|
||||
#### Files ####
|
||||
|
||||
BUILD_NAME = red
|
||||
|
||||
ROM := pmd_$(BUILD_NAME).gba
|
||||
MAP := $(ROM:%.gba=%.map)
|
||||
|
||||
BUILD_DIR := build/pmd_$(BUILD_NAME)
|
||||
|
||||
C_SOURCES := $(wildcard src/*.c)
|
||||
ASM_SOURCES := $(wildcard asm/*.s data/*.s)
|
||||
|
||||
C_OBJECTS := $(addprefix $(BUILD_DIR)/, $(C_SOURCES:%.c=%.o))
|
||||
ASM_OBJECTS := $(addprefix $(BUILD_DIR)/, $(ASM_SOURCES:%.s=%.o))
|
||||
ALL_OBJECTS := $(C_OBJECTS) $(ASM_OBJECTS)
|
||||
|
||||
SUBDIRS := $(sort $(dir $(ALL_OBJECTS)))
|
||||
|
||||
LIBC := tools/agbcc/lib/libc.a
|
||||
LIBGCC := tools/agbcc/lib/libgcc.a
|
||||
|
||||
LD_SCRIPT := $(BUILD_DIR)/ld_script.ld
|
||||
|
||||
# Special configurations required for lib files
|
||||
%/src/agb_flash.o : CC1FLAGS := -O -mthumb-interwork
|
||||
%/src/agb_flash_1m.o: CC1FLAGS := -O -mthumb-interwork
|
||||
%/src/agb_flash_mx.o: CC1FLAGS := -O -mthumb-interwork
|
||||
|
||||
#### Main Rules ####
|
||||
|
||||
ALL_BUILDS := red
|
||||
|
||||
# Available targets
|
||||
.PHONY: all clean tidy
|
||||
|
||||
MAKEFLAGS += --no-print-directory
|
||||
# Secondary expansion is required for dependency variables in object rules.
|
||||
.SECONDEXPANSION:
|
||||
# Clear the default suffixes
|
||||
.SUFFIXES:
|
||||
# Don't delete intermediate files
|
||||
.SECONDARY:
|
||||
# Delete files that weren't built properly
|
||||
.DELETE_ON_ERROR:
|
||||
|
||||
.PRECIOUS: %.1bpp %.4bpp %.8bpp %.gbapal %.lz %.rl %.pcm %.bin
|
||||
|
||||
.PHONY: all clean tidy
|
||||
|
||||
C_SRCS := $(wildcard src/*.c)
|
||||
C_OBJS := $(C_SRCS:%.c=%.o)
|
||||
# Create build subdirectories
|
||||
|
||||
ASM_SRCS := $(wildcard asm/*.s)
|
||||
ASM_OBJS := $(ASM_SRCS:%.s=%.o)
|
||||
$(shell mkdir -p $(SUBDIRS))
|
||||
|
||||
DATA_ASM_SRCS := $(wildcard data/*.s)
|
||||
DATA_ASM_OBJS := $(DATA_ASM_SRCS:%.s=%.o)
|
||||
|
||||
OBJS := $(C_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS)
|
||||
|
||||
all: pmd_red.gba
|
||||
|
||||
# For contributors to make sure a change didn't affect the contents of the ROM.
|
||||
|
||||
compare: all
|
||||
@$(MD5) rom.md5
|
||||
all: $(ROM)
|
||||
ifeq ($(COMPARE),1)
|
||||
@$(SHA1SUM) $(BUILD_NAME).sha1
|
||||
endif
|
||||
|
||||
clean: tidy
|
||||
|
||||
$(RM) $(ALL_OBJECTS)
|
||||
tidy:
|
||||
rm -f pmd_red.gba pmd_red.elf pmd_red.map
|
||||
rm -f $(ASM_OBJS)
|
||||
rm -f $(DATA_ASM_OBJS)
|
||||
rm -f $(C_OBJS)
|
||||
rm -f $(ASM_OBJS)
|
||||
rm -f $(DATA_ASM_OBJS)
|
||||
rm -f $(C_SRCS:%.c=%.i)
|
||||
rm -f $(C_SRCS:%.c=%.s)
|
||||
rm -f *.ld
|
||||
$(RM) $(ALL_BUILDS:%=pmd_%{.gba,.elf,.map})
|
||||
$(RM) -r build
|
||||
|
||||
src/agb_flash.o: CFLAGS := -O -mthumb-interwork
|
||||
src/agb_flash_1m.o: CFLAGS := -O -mthumb-interwork
|
||||
src/agb_flash_mx.o: CFLAGS := -O -mthumb-interwork
|
||||
|
||||
$(C_OBJS): %.o : %.c
|
||||
@$(CPP) $(CPPFLAGS) $< -o $*.i
|
||||
@$(CC1) $(CFLAGS) $*.i -o $*.s
|
||||
@printf ".text\n\t.align\t2, 0\n" >> $*.s
|
||||
$(AS) $(ASFLAGS) -o $@ $*.s
|
||||
|
||||
$(ASM_OBJS): %.o: %.s
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
$(DATA_ASM_OBJS): %.o: %.s
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
sym_ewram.ld: sym_ewram.txt
|
||||
$(RAMSCRGEN) ewram_data sym_ewram.txt ENGLISH >$@
|
||||
|
||||
sym_ewram2.ld: sym_ewram2.txt
|
||||
$(RAMSCRGEN) ewram_data sym_ewram2.txt ENGLISH >$@
|
||||
|
||||
sym_iwram.ld: sym_iwram.txt
|
||||
$(RAMSCRGEN) iwram_data sym_iwram.txt ENGLISH >$@
|
||||
|
||||
ld_script.ld: ld_script.txt sym_ewram.ld sym_ewram2.ld sym_iwram.ld
|
||||
sed -f ld_script.sed ld_script.txt >ld_script.ld
|
||||
|
||||
pmd_red.elf: ld_script.ld $(OBJS) $(LIBC)
|
||||
$(LD) -T ld_script.ld -Map pmd_red.map -o $@ $(OBJS) $(LIBC) $(LIBGCC)
|
||||
|
||||
pmd_red.gba: pmd_red.elf
|
||||
$(ROM): %.gba: %.elf
|
||||
$(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0xA000000 $< $@
|
||||
|
||||
%.elf: $(LD_SCRIPT) $(ALL_OBJECTS) $(LIBC)
|
||||
cd $(BUILD_DIR) && $(LD) -T ld_script.ld -Map ../../$(MAP) -o ../../$@ ../../$(LIBC) ../../$(LIBGCC)
|
||||
|
||||
$(LD_SCRIPT): ld_script.txt $(BUILD_DIR)/sym_ewram.ld $(BUILD_DIR)/sym_ewram2.ld $(BUILD_DIR)/sym_iwram.ld
|
||||
cd $(BUILD_DIR) && sed -e "s#tools/#../../tools/#g" ../../ld_script.txt >ld_script.ld
|
||||
$(BUILD_DIR)/sym_%.ld: sym_%.txt
|
||||
$(CPP) -P $(CPPFLAGS) $< | sed -e "s#tools/#../../tools/#g" > $@
|
||||
|
||||
$(C_OBJECTS): $(BUILD_DIR)/%.o: %.c
|
||||
@$(CPP) $(CPPFLAGS) $< -o $(BUILD_DIR)/$*.i
|
||||
echo $(CC1) $(CC1FLAGS) $(BUILD_DIR)/$*.i -o $(BUILD_DIR)/$*.s
|
||||
@$(CC1) $(CC1FLAGS) $(BUILD_DIR)/$*.i -o $(BUILD_DIR)/$*.s
|
||||
@printf ".text\n\t.align\t2, 0\n" >> $(BUILD_DIR)/$*.s
|
||||
$(AS) $(ASFLAGS) -o $@ $(BUILD_DIR)/$*.s
|
||||
|
||||
$(BUILD_DIR)/data/%.o: data/%.s
|
||||
$(AS) $(ASFLAGS) $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: %.s
|
||||
$(AS) $(ASFLAGS) $< -o $@
|
@ -1,10 +1,10 @@
|
||||
# Pokémon Mystery Dungeon: Red Rescue Team [![Build Status][travis-badge]][travis]
|
||||
# Pokémon Mystery Dungeon: Red Rescue Team
|
||||
|
||||
This is a disassembly of Pokémon Mystery Dungeon: Red Rescue Team.
|
||||
|
||||
It builds the following rom:
|
||||
|
||||
* pmd_red.gba `md5: 2100cf6f17e12cd34f1513647dfa506b`
|
||||
* pmd_red.gba `sha1: 9f4cfc5b5f4859d17169a485462e977c7aac2b89`
|
||||
|
||||
To set up the repository, see [INSTALL.md](INSTALL.md).
|
||||
|
||||
@ -33,5 +33,3 @@ To set up the repository, see [INSTALL.md](INSTALL.md).
|
||||
[pokeemerald]: https://github.com/pret/pokeemerald
|
||||
[Discord]: https://discord.gg/6EuWgX9
|
||||
[irc]: https://kiwiirc.com/client/irc.freenode.net/?#pret
|
||||
[travis]: https://travis-ci.org/pret/pokeruby
|
||||
[travis-badge]: https://travis-ci.org/pret/pokeruby.svg?branch=master
|
||||
|
7
asmdiff.sh
Normal file
7
asmdiff.sh
Normal file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb"
|
||||
OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))"
|
||||
$OBJDUMP $OPTIONS baserom.gba > baserom.dump
|
||||
$OBJDUMP $OPTIONS pmd_red.gba > pmd_red.dump
|
||||
diff -u baserom.dump pmd_red.dump | less
|
@ -1,14 +0,0 @@
|
||||
/<EWRAM>/ {
|
||||
r sym_ewram.ld
|
||||
d
|
||||
}
|
||||
|
||||
/<EWRAM2>/ {
|
||||
r sym_ewram2.ld
|
||||
d
|
||||
}
|
||||
|
||||
/<IWRAM>/ {
|
||||
r sym_iwram.ld
|
||||
d
|
||||
}
|
@ -7,7 +7,7 @@ SECTIONS {
|
||||
ALIGN(4)
|
||||
{
|
||||
ewram_start = .;
|
||||
<EWRAM>
|
||||
INCLUDE "sym_ewram.ld"
|
||||
. = ALIGN(4);
|
||||
src/agb_flash.o(.bss);
|
||||
. = ALIGN(4);
|
||||
@ -17,7 +17,7 @@ SECTIONS {
|
||||
. = ALIGN(4);
|
||||
tools/agbcc/lib/libc.a:syscalls.o(.bss);
|
||||
. = ALIGN(16);
|
||||
<EWRAM2>
|
||||
INCLUDE "sym_ewram2.ld"
|
||||
. = ALIGN(4);
|
||||
tools/agbcc/lib/libc.a:impure.o(.data);
|
||||
. = ALIGN(4);
|
||||
@ -35,7 +35,7 @@ SECTIONS {
|
||||
ALIGN(4)
|
||||
{
|
||||
iwram_start = .;
|
||||
<IWRAM>
|
||||
INCLUDE "sym_iwram.ld"
|
||||
. = 0x8000;
|
||||
}
|
||||
|
||||
|
1406
sym_ewram.txt
1406
sym_ewram.txt
File diff suppressed because it is too large
Load Diff
872
sym_ewram2.txt
872
sym_ewram2.txt
File diff suppressed because it is too large
Load Diff
102
sym_iwram.txt
102
sym_iwram.txt
@ -1,77 +1,77 @@
|
||||
SoundMainRAM_Buffer: @ 3000000
|
||||
.space 0x400
|
||||
SoundMainRAM_Buffer = .; /* 3000000 */
|
||||
. += 0x400;
|
||||
|
||||
gUnknown_3000400: @ 3000400
|
||||
.space 0x800
|
||||
gUnknown_3000400 = .; /* 3000400 */
|
||||
. += 0x800;
|
||||
|
||||
gUnknown_3000C00: @ 3000C00
|
||||
.space 0x294
|
||||
gUnknown_3000C00 = .; /* 3000C00 */
|
||||
. += 0x294;
|
||||
|
||||
gUnknown_3000E94: @ 3000E94
|
||||
.space 0x144
|
||||
gUnknown_3000E94 = .; /* 3000E94 */
|
||||
. += 0x144;
|
||||
|
||||
gUnknown_3000FD8: @ 3000FD8
|
||||
.space 0x10
|
||||
gUnknown_3000FD8 = .; /* 3000FD8 */
|
||||
. += 0x10;
|
||||
|
||||
gUnknown_3000FE8: @ 3000FE8
|
||||
.space 0x30
|
||||
gUnknown_3000FE8 = .; /* 3000FE8 */
|
||||
. += 0x30;
|
||||
|
||||
gUnknown_3001018: @ 3001018
|
||||
.space 0x180
|
||||
gUnknown_3001018 = .; /* 3001018 */
|
||||
. += 0x180;
|
||||
|
||||
gUnknown_3001198: @ 3001198
|
||||
.space 0x9C0
|
||||
gUnknown_3001198 = .; /* 3001198 */
|
||||
. += 0x9C0;
|
||||
|
||||
alt_3001B58:
|
||||
alt_3001B58 = .;
|
||||
|
||||
unk_code_ram: @ 3001B58
|
||||
unk_code_ram = .; /* 3001B58 */
|
||||
|
||||
gUnknown_3001B58: @ 3001B58
|
||||
.space 0x2
|
||||
gUnknown_3001B58 = .; /* 3001B58 */
|
||||
. += 0x2;
|
||||
|
||||
gUnknown_3001B5A: @ 3001B5A
|
||||
.space 0x2
|
||||
gUnknown_3001B5A = .; /* 3001B5A */
|
||||
. += 0x2;
|
||||
|
||||
gUnknown_3001B5C: @ 3001B5C
|
||||
.space 0x4
|
||||
gUnknown_3001B5C = .; /* 3001B5C */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B60: @ 3001B60
|
||||
.space 0x4
|
||||
gUnknown_3001B60 = .; /* 3001B60 */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B64: @ 3001B64
|
||||
.space 0x4
|
||||
gUnknown_3001B64 = .; /* 3001B64 */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B68: @ 3001B68
|
||||
.space 0x4
|
||||
gUnknown_3001B68 = .; /* 3001B68 */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B6C: @ 3001B6C
|
||||
.space 0x4
|
||||
gUnknown_3001B6C = .; /* 3001B6C */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B70: @ 3001B70
|
||||
.space 0x4
|
||||
gUnknown_3001B70 = .; /* 3001B70 */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B74: @ 3001B74
|
||||
.space 0x4
|
||||
gUnknown_3001B74 = .; /* 3001B74 */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B78: @ 3001B78
|
||||
.space 0x4
|
||||
gUnknown_3001B78 = .; /* 3001B78 */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B7C: @ 3001B7C
|
||||
.space 0x4
|
||||
gUnknown_3001B7C = .; /* 3001B7C */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B80: @ 3001B80
|
||||
.space 0x4
|
||||
gUnknown_3001B80 = .; /* 3001B80 */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B84: @ 3001B84
|
||||
.space 0x4
|
||||
gUnknown_3001B84 = .; /* 3001B84 */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B88: @ 3001B88
|
||||
.space 0x4
|
||||
gUnknown_3001B88 = .; /* 3001B88 */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B8C: @ 3001B8C
|
||||
.space 0x4
|
||||
gUnknown_3001B8C = .; /* 3001B8C */
|
||||
. += 0x4;
|
||||
|
||||
gUnknown_3001B90: @ 3001B90
|
||||
.space 0x2470
|
||||
gUnknown_3001B90 = .; /* 3001B90 */
|
||||
. += 0x2470;
|
||||
|
||||
gUnknown_3004000: @ 3004000
|
||||
gUnknown_3004000 = .; /* 3004000 */
|
Loading…
Reference in New Issue
Block a user