Support building on macOS with homebrew binutils

This commit is contained in:
PikalaxALT 2025-05-23 20:15:46 -04:00
parent a81f477d6b
commit e4daabfc04
No known key found for this signature in database
GPG Key ID: 7774E96AA69E5B61
5 changed files with 34 additions and 3 deletions

3
.gitignore vendored
View File

@ -43,3 +43,6 @@ build/
*.pyc
__pycache__/
*.syms
.cache
build-cmake-*
compile_commands.json

21
CMakeLists.txt Normal file
View File

@ -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__)

View File

@ -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");

View File

@ -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)
{

View File

@ -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 $@ $<