From f3496a0e11f3e29c1986031d2ed92b1da659a643 Mon Sep 17 00:00:00 2001 From: Jeffrey Crowell Date: Sun, 15 May 2022 15:24:32 -0400 Subject: [PATCH] add more makefile changes --- OTRExporter/OTRExporter/Makefile | 6 +++--- ZAPDTR/Makefile | 12 +++++------- ZAPDTR/ZAPD/ZRom.cpp | 6 ++++++ ZAPDTR/ZAPDUtils/Makefile | 3 ++- ZAPDTR/lib/libgfxd/Makefile | 1 + libultraship/Makefile | 14 +++++++------- .../libultraship/Lib/Fast3D/gfx_opengl.cpp | 5 ++++- libultraship/libultraship/Lib/Fast3D/gfx_pc.h | 1 + libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp | 8 +++++++- soh/Makefile | 10 +++++----- 10 files changed, 41 insertions(+), 25 deletions(-) diff --git a/OTRExporter/OTRExporter/Makefile b/OTRExporter/OTRExporter/Makefile index 954b183a3..d25f9930f 100644 --- a/OTRExporter/OTRExporter/Makefile +++ b/OTRExporter/OTRExporter/Makefile @@ -1,6 +1,6 @@ # Only used for standalone compilation, usually inherits these from the main makefile -CXX := g++ +CXX := g++-mp-devel AR := ar FORMAT := clang-format-11 @@ -30,7 +30,7 @@ ifneq ($(LTO),0) CXXFLAGS += -flto endif -SRC_DIRS := $(shell find -type d -not -path "*build*") +SRC_DIRS := $(shell find . -type d -not -path "*build*") CXX_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp)) H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h)) @@ -67,4 +67,4 @@ build/%.o: %.cpp $(LIB): $(O_FILES) $(AR) rcs $@ $^ --include $(D_FILES) \ No newline at end of file +-include $(D_FILES) diff --git a/ZAPDTR/Makefile b/ZAPDTR/Makefile index 13f0dce20..d1aa8c3cd 100644 --- a/ZAPDTR/Makefile +++ b/ZAPDTR/Makefile @@ -15,6 +15,8 @@ else CXX := g++ endif +CXX := g++-mp-devel + INC := -I ZAPD -I lib/elfio -I lib/libgfxd -I lib/tinyxml2 -I ZAPDUtils CXXFLAGS := -fpic -std=c++17 -Wall -Wextra -fno-omit-frame-pointer OPTFLAGS := @@ -45,7 +47,7 @@ endif # CXXFLAGS += -DTEXTURE_DEBUG LDFLAGS := -lm -ldl -lpng \ - -L../external -L../libultraship -lz -lbz2 -pthread -lpulse -lultraship -lstorm -lSDL2 -lGLEW -lGL -lX11 + -L../external -L../libultraship -lz -lbz2 -pthread -lpulse -lultraship -lstorm -lSDL2 $(shell pkg-config --libs glew) -lX11 # Use LLD if available. Set LLD=0 to not use it ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) @@ -64,12 +66,8 @@ ifneq ($(UNAME), Darwin) else EXPORTERS := -Wl,-force_load ../OTRExporter/OTRExporter/OTRExporter.a ifeq ($(UNAMEM),arm64) - ifeq ($(shell brew list libpng > /dev/null 2>&1; echo $$?),0) - LDFLAGS += -L $(shell brew --prefix)/lib - INC += -I $(shell brew --prefix)/include - else - $(error Please install libpng via Homebrew) - endif + LDFLAGS += $(shell pkg-config --libs libpng) + INC += $(shell pkg-config --cflags libpng) endif endif diff --git a/ZAPDTR/ZAPD/ZRom.cpp b/ZAPDTR/ZAPD/ZRom.cpp index 2a1d3c8a1..df97a0d26 100644 --- a/ZAPDTR/ZAPD/ZRom.cpp +++ b/ZAPDTR/ZAPD/ZRom.cpp @@ -5,8 +5,10 @@ #include "yaz0/yaz0.h" #ifndef _MSC_VER +#ifndef __APPLE__ #include #endif +#endif #include namespace fs = std::filesystem; @@ -17,6 +19,10 @@ namespace fs = std::filesystem; #define __bswap_32 _byteswap_ulong #define bswap_32 _byteswap_ulong #endif +#if defined __APPLE__ +#define __bswap32 __builtin_bswap32 +#define bswap32 __builtin_bswap32 +#endif // ROM DMA Table Start #define OOT_OFF_NTSC_10_RC 0x7430 diff --git a/ZAPDTR/ZAPDUtils/Makefile b/ZAPDTR/ZAPDUtils/Makefile index aef678031..01dac2a22 100644 --- a/ZAPDTR/ZAPDUtils/Makefile +++ b/ZAPDTR/ZAPDUtils/Makefile @@ -1,7 +1,8 @@ # Only used for standalone compilation, usually inherits these from the main makefile +CXX := g++-mp-devel CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17 -SRC_DIRS := $(shell find -type d -not -path "*build*") +SRC_DIRS := $(shell find . -type d -not -path "*build*") CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp)) H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h)) diff --git a/ZAPDTR/lib/libgfxd/Makefile b/ZAPDTR/lib/libgfxd/Makefile index b340ff5c0..a184cc80c 100644 --- a/ZAPDTR/lib/libgfxd/Makefile +++ b/ZAPDTR/lib/libgfxd/Makefile @@ -1,3 +1,4 @@ +CC := gcc-mp-devel CFLAGS = -Wall -O2 -g UC_OBJ = uc_f3d.o uc_f3db.o uc_f3dex.o uc_f3dexb.o uc_f3dex2.o OBJ = gfxd.o $(UC_OBJ) diff --git a/libultraship/Makefile b/libultraship/Makefile index d6789db0b..2d04a4ec3 100644 --- a/libultraship/Makefile +++ b/libultraship/Makefile @@ -1,7 +1,7 @@ # Only used for standalone compilation, usually inherits these from the main makefile -CXX := g++ -CC := gcc +CXX := g++-mp-devel +CC := gcc-mp-devel AR := ar FORMAT := clang-format-11 @@ -18,9 +18,9 @@ WARN := -Wall -Wextra -Werror \ -Wno-narrowing \ -Wno-missing-field-initializers -CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 -m32 -CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 -m32 -CPPFLAGS := -MMD +CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 +CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 +CPPFLAGS := -MMD $(shell pkg-config --cflags sdl2 glew) ifneq ($(DEBUG),0) CXXFLAGS += -g -D_DEBUG @@ -37,7 +37,7 @@ ifneq ($(LTO),0) CFLAGS += -flto endif -SRC_DIRS := $(shell find -type d -not -path "*build*") +SRC_DIRS := $(shell find . -type d -not -path "*build*") CXX_FILES := \ $(shell find libultraship/Factories -name *.cpp) \ @@ -93,4 +93,4 @@ build/%.o: %.c $(LIB): $(O_FILES) $(AR) rcs $@ $^ --include $(D_FILES) \ No newline at end of file +-include $(D_FILES) diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp index b2db3186a..99236c7a4 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp @@ -27,6 +27,9 @@ #include "SDL.h" #define GL_GLEXT_PROTOTYPES 1 #include "SDL_opengl.h" +#elif __APPLE__ +#include +#include #else #include #include @@ -496,7 +499,7 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad } for (int i = 0; i < cc_features.num_inputs; i++) { - char name[16]; + char name[32]; sprintf(name, "aInput%d", i + 1); prg->attrib_locations[cnt] = glGetAttribLocation(shader_program, name); prg->attrib_sizes[cnt] = cc_features.opt_alpha ? 4 : 3; diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.h b/libultraship/libultraship/Lib/Fast3D/gfx_pc.h index 62f80ab3c..f1f5ca21b 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.h +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.h @@ -2,6 +2,7 @@ #define GFX_PC_H #include +#include #include #include #include diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp index e80097c81..67846a598 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp @@ -13,6 +13,8 @@ #include "SDL.h" #define GL_GLEXT_PROTOTYPES 1 #include "SDL_opengl.h" +#elif __APPLE__ +#include #else #include #define GL_GLEXT_PROTOTYPES 1 @@ -120,8 +122,10 @@ static void set_fullscreen(bool on, bool call_callback) { static uint64_t previous_time; #ifndef __linux__ +#ifndef __APPLE__ static HANDLE timer; #endif +#endif static int frameDivisor = 1; @@ -136,7 +140,9 @@ static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen) { SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); #ifndef __linux +#ifndef __APPLE__ timer = CreateWaitableTimer(nullptr, false, nullptr); +#endif #endif //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); @@ -271,7 +277,7 @@ static inline void sync_framerate_with_timer(void) { const int64_t next = qpc_to_100ns(previous_time) + 10 * FRAME_INTERVAL_US_NUMERATOR / FRAME_INTERVAL_US_DENOMINATOR; const int64_t left = next - qpc_to_100ns(t); if (left > 0) { -#ifdef __linux__ +#if defined __linux__ || defined __APPLE__ const timespec spec = { 0, left * 100 }; nanosleep(&spec, nullptr); #else diff --git a/soh/Makefile b/soh/Makefile index be46f55e7..186c820ff 100644 --- a/soh/Makefile +++ b/soh/Makefile @@ -1,5 +1,5 @@ -CXX := g++ -CC := gcc +CXX := g++-mp-devel +CC := gcc-mp-devel LD := lld AR := ar FORMAT := clang-format-11 @@ -16,11 +16,11 @@ LTO ?= 0 WARN := \ -Wno-return-type \ -funsigned-char \ - -m32 -mhard-float -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -fno-toplevel-reorder -ffreestanding -fwrapv \ + -mhard-float -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -fno-toplevel-reorder -ffreestanding -fwrapv \ CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib -march=i386 CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib -march=i386 -LDFLAGS := -m32 +LDFLAGS := CPPFLAGS := -MMD ifneq ($(DEBUG),0) @@ -155,4 +155,4 @@ $(TARGET): $(LIBULTRASHIP) $(TARGET): $(O_FILES) $(CXX) $^ -o $@ $(LDFLAGS) -fuse-ld=$(LD) $(LDDIRS) $(LDLIBS) --include $(D_FILES) \ No newline at end of file +-include $(D_FILES)