From 0502906e2807756eefb03fe1d7559df305d73ea1 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Tue, 7 Apr 2026 12:49:39 -0500 Subject: [PATCH] incomplete support for macOS builds --- .gitignore | 5 ++++- Makefile | 15 +++++++++++++-- src/file.cpp | 14 +++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index de46c10..6254842 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ *.spv *.o main -*.pack \ No newline at end of file +*.pack +tool/pack_file +*.zip +*.tar \ No newline at end of file diff --git a/Makefile b/Makefile index 8bdfd35..ac6029f 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,9 @@ AS=$(PREFIX)as OBJARCH = elf64-x86-64 -OPT = -O0 -march=x86-64-v3 +UNAME := $(shell uname -s) + +OPT += -O0 -march=x86-64-v3 DEBUG = -g @@ -25,9 +27,13 @@ CFLAGS += -fpic FLAGS += -fstack-protector -fstack-protector-all -fno-omit-frame-pointer -fsanitize=address LDFLAGS += -lm -ifeq ($(shell uname),Linux) +ifeq ($(UNAME),Linux) LDFLAGS += -Wl,-z noexecstack endif +ifeq ($(UNAME),Darwin) +LDFLAGS += -framework Foundation -framework Cocoa -framework IOKit -framework AVFoundation -framework CoreVideo -framework CoreAudio -framework CoreMedia -framework CoreHaptics -framework AudioToolbox -framework GameController -framework ForceFeedback -framework Carbon -framework Metal -framework QuartzCore -framework UniformTypeIdentifiers +LDFLAGS += -lstdc++ +endif OBJS = \ src/main.o \ @@ -35,8 +41,13 @@ OBJS = \ src/file.o \ src/pack.o +ifeq ($(UNAME),Darwin) +LIBS = \ + ../SDL3-dist/lib/libSDL3.a +else LIBS = \ ../SDL3-dist/lib64/libSDL3.a +endif all: main diff --git a/src/file.cpp b/src/file.cpp index 2f14cbb..1cc6afc 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -8,8 +8,17 @@ #include "file.h" extern "C" { +#ifdef __APPLE__ + extern uint8_t const files_pack_start[]; + extern uint8_t const files_pack_end[]; + #define files_pack_start files_pack_start + #define files_pack_end files_pack_end +#else extern uint8_t const _files_pack_start[]; extern uint8_t const _files_pack_end[]; + #define files_pack_start _files_pack_start + #define files_pack_end _files_pack_end +#endif }; namespace file { @@ -18,12 +27,12 @@ namespace file { { fprintf(stderr, "(pack) filename: %s\n", r_filename); - pack::header const * header = (pack::header const *)&_files_pack_start[0]; + pack::header const * header = (pack::header const *)&files_pack_start[0]; if (header->magic != pack::magic_value) { fprintf(stderr, "invalid header magic: %08x expected magic value: %08x\n", header->magic, pack::magic_value); exit(EXIT_FAILURE); } - ptrdiff_t data = (ptrdiff_t)&_files_pack_start[header->header_size]; + ptrdiff_t data = (ptrdiff_t)&files_pack_start[header->header_size]; for (unsigned int i = 0; i < header->entry_count; i++) { if (strcmp(header->entry[i].filename, r_filename) == 0) { @@ -35,5 +44,4 @@ namespace file { fprintf(stderr, "filename not found in pack file %s\n", r_filename); exit(EXIT_FAILURE); } - }