diff --git a/.gitignore b/.gitignore index 3f5b924db..7f8744048 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,6 @@ build/ *.pyc __pycache__/ *.syms +.cache +build-cmake-* +compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..fd74b8c3d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required (VERSION 3.15) +set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") +# Override the default system to cross-compile for ARM processors +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR ARM) +project(pmd-red) + +enable_language(ASM) + +if(APPLE) + include_directories(/usr/local/include) +endif(APPLE) + +file(GLOB_RECURSE c_srcs src/*.c) +file(GLOB_RECURSE asm_srcs asm/*.s) +add_executable(pmd-red ${c_srcs} ${asm_srcs}) +target_include_directories(pmd-red PUBLIC tools/agbcc/include) +target_include_directories(pmd-red PRIVATE include) +target_compile_definitions(pmd-red PRIVATE __APPLE__) diff --git a/include/globaldata.h b/include/globaldata.h index ae2f0ff8a..60e42ed83 100644 --- a/include/globaldata.h +++ b/include/globaldata.h @@ -5,5 +5,10 @@ // Later, we can move this into "global.h" before the #ifdef guard. But we can only do this if "global.h" isn't included outside of .c files... #include "gba/defines.h" +#include "gba/types.h" + +#if (defined(__APPLE__) || defined(__CYGWIN__)) && !defined(_) +#define _(x) x +#endif ALIGNED(4) static const u8 sFill[] = _("pksdir0"); diff --git a/ld_script.ld b/ld_script.ld index daa6b5ad4..3f3be2834 100755 --- a/ld_script.ld +++ b/ld_script.ld @@ -359,9 +359,9 @@ SECTIONS { src/m4a_1.o(.text); src/m4a.o(.text); *libagbsyscall.a:CpuSet.o(.text); - *libagbsyscall.a:SoundBiasReset.o(.text); + *libagbsyscall.a:SoundBiasReset.*(.text); *libagbsyscall.a:SoundBiasSet.o(.text); - *libagbsyscall.a:VBlankIntrWait.o(.text); + *libagbsyscall.a:VBlankIntrWait.*(.text); src/agb_flash.o(.text); src/agb_flash_1m.o(.text); src/agb_flash_mx.o(.text); @@ -925,7 +925,7 @@ SECTIONS { data/monster_sbin.o(.rodata); src/monster_sbin_palet.o(.rodata); } > ROM =0 - + unk_96BD7AC_section : ALIGN(4) { diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index 911cdb237..92739f137 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -24,6 +24,7 @@ export AS := $(PREFIX)as endif export CPP := $(PREFIX)cpp export LD := $(PREFIX)ld +export RANLIB := $(PREFIX)ranlib ifeq ($(OS),Windows_NT) EXE := .exe @@ -93,6 +94,7 @@ clean: $(LIB): $(ASM_OBJS) $(AR) $(ARFLAGS) $@ $^ + $(RANLIB) $@ $(ASM_OBJS): libagbsyscall.s $(AS) $(ASFLAGS) --defsym L_$(*F)=1 -o $@ $<