[Round 2] Apply all source related changes for the new INSTALL.md in one commit.

This commit is contained in:
luckytyphlosion 2020-12-16 20:31:56 -05:00
parent 345aab63cf
commit 166183d5ed
17 changed files with 213 additions and 121 deletions

View File

@ -1,29 +1,34 @@
TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0
ifeq ($(CC),)
HOSTCC := gcc
else
HOSTCC := $(CC)
endif
# don't use dkP's base_tools anymore
# because the redefinition of $(CC) conflicts
# with when we want to use $(CC) to preprocess files
# thus, manually create the variables for the bin
# files, or use arm-none-eabi binaries on the system
# if dkP is not installed on tihs system
ifeq ($(CXX),)
HOSTCXX := g++
else
HOSTCXX := $(CXX)
endif
ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
include $(TOOLCHAIN)/base_tools
else
ifneq (,$(TOOLCHAIN))
ifneq ($(wildcard $(TOOLCHAIN)/bin),)
export PATH := $(TOOLCHAIN)/bin:$(PATH)
endif
endif
PREFIX := arm-none-eabi-
OBJCOPY := $(PREFIX)objcopy
export CC := $(PREFIX)gcc
export AS := $(PREFIX)as
AS := $(PREFIX)as
ifneq ($(MODERN),1)
CPP := $(CC) -E
else
CPP := $(PREFIX)cpp
endif
export CPP := $(PREFIX)cpp
export LD := $(PREFIX)ld
LD := $(PREFIX)ld
# note: the makefile must be set up so MODERNCC is never called
# if MODERN=0
MODERNCC := $(PREFIX)gcc
ifeq ($(OS),Windows_NT)
EXE := .exe
@ -37,6 +42,16 @@ MAKER_CODE := 01
REVISION := 0
MODERN ?= 0
ROM_NAME := pokeemerald.gba
ELF_NAME := $(ROM_NAME:.gba=.elf)
MAP_NAME := $(ROM_NAME:.gba=.map)
OBJ_DIR_NAME := build/emerald
MODERN_ROM_NAME := pokeemerald_modern.gba
MODERN_ELF_NAME := $(MODERN_ROM_NAME:.gba=.elf)
MODERN_MAP_NAME := $(MODERN_ROM_NAME:.gba=.map)
MODERN_OBJ_DIR_NAME := build/modern
SHELL := /bin/bash -o pipefail
ELF = $(ROM:.gba=.elf)
@ -64,20 +79,20 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN)
ifeq ($(MODERN),0)
CC1 := tools/agbcc/bin/agbcc$(EXE)
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -g
ROM := pokeemerald.gba
OBJ_DIR := build/emerald
ROM := $(ROM_NAME)
OBJ_DIR := $(OBJ_DIR_NAME)
LIBPATH := -L ../../tools/agbcc/lib
else
CC1 = $(shell $(CC) --print-prog-name=cc1) -quiet
CC1 = $(shell $(MODERNCC) --print-prog-name=cc1) -quiet
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast -g
ROM := pokeemerald_modern.gba
OBJ_DIR := build/modern
LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))"
ROM := $(MODERN_ROM_NAME)
OBJ_DIR := $(MODERN_OBJ_DIR_NAME)
LIBPATH := -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libc.a))"
endif
CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN)
ifeq ($(MODERN),0)
CPPFLAGS += -I tools/agbcc/include -I tools/agbcc
ifneq ($(MODERN),1)
CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef
endif
LDFLAGS = -Map ../../$(MAP)
@ -111,7 +126,7 @@ MAKEFLAGS += --no-print-directory
# Secondary expansion is required for dependency variables in object rules.
.SECONDEXPANSION:
.PHONY: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern
.PHONY: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern tidymodern tidynonmodern
infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
@ -162,7 +177,7 @@ all: rom
tools: $(TOOLDIRS)
$(TOOLDIRS):
@$(MAKE) -C $@ CC=$(HOSTCC) CXX=$(HOSTCXX)
@$(MAKE) -C $@
rom: $(ROM)
ifeq ($(COMPARE),1)
@ -177,7 +192,7 @@ clean: mostlyclean clean-tools
clean-tools:
@$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);)
mostlyclean: tidy
mostlyclean: tidynonmodern tidymodern
rm -f $(SAMPLE_SUBDIR)/*.bin
rm -f $(CRY_SUBDIR)/*.bin
rm -f $(MID_SUBDIR)/*.s
@ -192,10 +207,15 @@ mostlyclean: tidy
tidy:
rm -f $(ROM) $(ELF) $(MAP)
rm -r $(OBJ_DIR)
ifeq ($(MODERN),0)
@$(MAKE) tidy MODERN=1
endif
tidynonmodern:
rm -f $(ROM_NAME) $(ELF_NAME) $(MAP_NAME)
rm -rf $(OBJ_DIR_NAME)
tidymodern:
rm -f $(MODERN_ROM_NAME) $(MODERN_ELF_NAME) $(MODERN_MAP_NAME)
rm -rf $(MODERN_OBJ_DIR_NAME)
ifneq ($(MODERN),0)
$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member
endif
@ -223,7 +243,7 @@ sound/%.bin: sound/%.aif ; $(AIF) $< $@
ifeq ($(MODERN),0)
$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc
$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE)
$(C_BUILDDIR)/libc.o: CFLAGS := -O2
$(C_BUILDDIR)/siirtc.o: CFLAGS := -mthumb-interwork
@ -232,10 +252,10 @@ $(C_BUILDDIR)/agb_flash.o: CFLAGS := -O -mthumb-interwork
$(C_BUILDDIR)/agb_flash_1m.o: CFLAGS := -O -mthumb-interwork
$(C_BUILDDIR)/agb_flash_mx.o: CFLAGS := -O -mthumb-interwork
$(C_BUILDDIR)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc
$(C_BUILDDIR)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE)
$(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding
$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm
$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm$(EXE)
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -O2 -mthumb-interwork -quiet
else
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
@ -296,11 +316,11 @@ endif
ifeq ($(NODEP),1)
$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s
$(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@
$(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
else
define DATA_ASM_DEP
$1: $2 $$(shell $(SCANINC) -I include -I "" $2)
$$(PREPROC) $$< charmap.txt | $$(CPP) -I include | $$(AS) $$(ASFLAGS) -o $$@
$$(PREPROC) $$< charmap.txt | $$(CPP) -I include - | $$(AS) $$(ASFLAGS) -o $$@
endef
$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src))))
endif
@ -329,7 +349,8 @@ $(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(LD_SCRIPT_DEPS)
cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../$(LD_SCRIPT) > ld_script.ld
$(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) berry_fix libagbsyscall
cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB)
@echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ <objects> <lib>"
@cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB)
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent
$(ROM): $(ELF)

View File

@ -1,11 +1,19 @@
#!/bin/bash
OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb"
if [[ -d "$DEVKITARM/bin/" ]]; then
OBJDUMP_BIN="$DEVKITARM/bin/arm-none-eabi-objdump"
else
OBJDUMP_BIN="arm-none-eabi-objdump"
fi
OBJDUMP="$OBJDUMP_BIN -D -bbinary -marmv4t -Mforce-thumb"
if [ $(($1)) -ge $((0x8000000)) ]; then
OPTIONS="--adjust-vma=0x8000000 --start-address=$(($1)) --stop-address=$(($1 + $2))"
else
OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))"
fi
$OBJDUMP $OPTIONS baserom.gba > baserom.dump
$OBJDUMP $OPTIONS pokeemerald.gba > pokeemerald.dump
diff -u baserom.dump pokeemerald.dump

View File

@ -1,29 +1,28 @@
TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0
ifeq ($(CC),)
HOSTCC := gcc
else
HOSTCC := $(CC)
endif
# don't use dkP's base_tools anymore
# because the redefinition of $(CC) conflicts
# with when we want to use $(CC) to preprocess files
# thus, manually create the variables for the bin
# files, or use arm-none-eabi binaries on the system
# if dkP is not installed on tihs system
ifeq ($(CXX),)
HOSTCXX := g++
else
HOSTCXX := $(CXX)
endif
ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
include $(TOOLCHAIN)/base_tools
else
ifneq (,$(TOOLCHAIN))
ifneq ($(wildcard $(TOOLCHAIN)/bin),)
export PATH := $(TOOLCHAIN)/bin:$(PATH)
endif
endif
PREFIX := arm-none-eabi-
OBJCOPY := $(PREFIX)objcopy
export CC := $(PREFIX)gcc
export AS := $(PREFIX)as
endif
export CPP := $(PREFIX)cpp
export LD := $(PREFIX)ld
AS := $(PREFIX)as
CPP := $(CC) -E
LD := $(PREFIX)ld
# note: the makefile must be set up so MODERNCC is never called
# if MODERN=0
MODERNCC := $(PREFIX)gcc
ifeq ($(OS),Windows_NT)
EXE := .exe

View File

@ -1,29 +1,28 @@
TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0
ifeq ($(CC),)
HOSTCC := gcc
else
HOSTCC := $(CC)
endif
# don't use dkP's base_tools anymore
# because the redefinition of $(CC) conflicts
# with when we want to use $(CC) to preprocess files
# thus, manually create the variables for the bin
# files, or use arm-none-eabi binaries on the system
# if dkP is not installed on tihs system
ifeq ($(CXX),)
HOSTCXX := g++
else
HOSTCXX := $(CXX)
endif
ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
include $(TOOLCHAIN)/base_tools
else
ifneq (,$(TOOLCHAIN))
ifneq ($(wildcard $(TOOLCHAIN)/bin),)
export PATH := $(TOOLCHAIN)/bin:$(PATH)
endif
endif
PREFIX := arm-none-eabi-
OBJCOPY := $(PREFIX)objcopy
export CC := $(PREFIX)gcc
export AS := $(PREFIX)as
endif
export CPP := $(PREFIX)cpp
export LD := $(PREFIX)ld
AS := $(PREFIX)as
CPP := $(CC) -E
LD := $(PREFIX)ld
# note: the makefile must be set up so MODERNCC is never called
# if MODERN=0
MODERNCC := $(PREFIX)gcc
ifeq ($(OS),Windows_NT)
EXE := .exe

View File

@ -1,29 +1,28 @@
TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0
ifeq ($(CC),)
HOSTCC := gcc
else
HOSTCC := $(CC)
endif
# don't use dkP's base_tools anymore
# because the redefinition of $(CC) conflicts
# with when we want to use $(CC) to preprocess files
# thus, manually create the variables for the bin
# files, or use arm-none-eabi binaries on the system
# if dkP is not installed on tihs system
ifeq ($(CXX),)
HOSTCXX := g++
else
HOSTCXX := $(CXX)
endif
ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
include $(TOOLCHAIN)/base_tools
else
ifneq (,$(TOOLCHAIN))
ifneq ($(wildcard $(TOOLCHAIN)/bin),)
export PATH := $(TOOLCHAIN)/bin:$(PATH)
endif
endif
PREFIX := arm-none-eabi-
OBJCOPY := $(PREFIX)objcopy
export CC := $(PREFIX)gcc
export AS := $(PREFIX)as
endif
export CPP := $(PREFIX)cpp
export LD := $(PREFIX)ld
AS := $(PREFIX)as
CPP := $(CC) -E
LD := $(PREFIX)ld
# note: the makefile must be set up so MODERNCC is never called
# if MODERN=0
MODERNCC := $(PREFIX)gcc
ifeq ($(OS),Windows_NT)
EXE := .exe

View File

@ -9,9 +9,9 @@ MAP_EVENTS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/events.inc,$(MAP_DIRS))
MAP_HEADERS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/header.inc,$(MAP_DIRS))
$(DATA_ASM_BUILDDIR)/maps.o: $(DATA_ASM_SUBDIR)/maps.s $(LAYOUTS_DIR)/layouts.inc $(LAYOUTS_DIR)/layouts_table.inc $(MAPS_DIR)/headers.inc $(MAPS_DIR)/groups.inc $(MAPS_DIR)/connections.inc $(MAP_CONNECTIONS) $(MAP_HEADERS)
$(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@
$(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
$(DATA_ASM_BUILDDIR)/map_events.o: $(DATA_ASM_SUBDIR)/map_events.s $(MAPS_DIR)/events.inc $(MAP_EVENTS)
$(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@
$(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
$(MAPS_DIR)/%/header.inc: $(MAPS_DIR)/%/map.json
$(MAPJSON) map emerald $< $(LAYOUTS_DIR)/layouts.json

View File

@ -6,12 +6,18 @@ LIBS = -lm
SRCS = main.c extended.c
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
.PHONY: all clean
all: aif2pcm
all: aif2pcm$(EXE)
@:
aif2pcm: $(SRCS)
aif2pcm$(EXE): $(SRCS)
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
clean:

View File

@ -6,10 +6,16 @@ CFLAGS = -Wall -Wextra -Werror -std=c11 -O2
SRCS = bin2c.c
all: bin2c
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
all: bin2c$(EXE)
@:
bin2c: $(SRCS)
bin2c$(EXE): $(SRCS)
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean:

View File

@ -3,10 +3,16 @@ CC ?= gcc
SRCS = gbafix.c
all: gbafix
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
all: gbafix$(EXE)
@:
gbafix: $(SRCS)
gbafix$(EXE): $(SRCS)
$(CC) $(SRCS) -o $@ $(LDFLAGS)
clean:

View File

@ -6,15 +6,21 @@ LIBS = -lpng -lz
SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c rl.c util.c font.c huff.c
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
.PHONY: all clean
all: gbagfx
all: gbagfx$(EXE)
@:
gbagfx-debug: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
gbagfx-debug$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
$(CC) $(CFLAGS) -DDEBUG $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
gbagfx$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
clean:

View File

@ -8,12 +8,18 @@ SRCS := jsonproc.cpp
HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
.PHONY: all clean
all: jsonproc
all: jsonproc$(EXE)
@:
jsonproc: $(SRCS) $(HEADERS)
jsonproc$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS)
clean:

View File

@ -6,12 +6,18 @@ SRCS := json11.cpp mapjson.cpp
HEADERS := mapjson.h
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
.PHONY: all clean
all: mapjson
all: mapjson$(EXE)
@:
mapjson: $(SRCS) $(HEADERS)
mapjson$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean:

View File

@ -6,12 +6,18 @@ SRCS := agb.cpp error.cpp main.cpp midi.cpp tables.cpp
HEADERS := agb.h error.h main.h midi.h tables.h
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
.PHONY: all clean
all: mid2agb
all: mid2agb$(EXE)
@:
mid2agb: $(SRCS) $(HEADERS)
mid2agb$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean:

View File

@ -8,12 +8,18 @@ SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \
HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \
utf8.h
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
.PHONY: all clean
all: preproc
all: preproc$(EXE)
@:
preproc: $(SRCS) $(HEADERS)
preproc$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean:

View File

@ -8,10 +8,16 @@ HEADERS := ramscrgen.h sym_file.h elf.h char_util.h
.PHONY: all clean
all: ramscrgen
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
all: ramscrgen$(EXE)
@:
ramscrgen: $(SRCS) $(HEADERS)
ramscrgen$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean:

View File

@ -8,10 +8,16 @@ SRCS = main.c convert_png.c util.c font.c
.PHONY: all clean
all: rsfont
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
all: rsfont$(EXE)
@:
rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h
rsfont$(EXE): $(SRCS) convert_png.h gfx.h global.h util.h font.h
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
clean:

View File

@ -8,10 +8,16 @@ HEADERS := scaninc.h asm_file.h c_file.h source_file.h
.PHONY: all clean
all: scaninc
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
all: scaninc$(EXE)
@:
scaninc: $(SRCS) $(HEADERS)
scaninc$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean: