add more makefile changes

This commit is contained in:
Jeffrey Crowell 2022-05-15 15:24:32 -04:00
commit f3496a0e11
10 changed files with 41 additions and 25 deletions

View file

@ -1,6 +1,6 @@
# Only used for standalone compilation, usually inherits these from the main makefile # Only used for standalone compilation, usually inherits these from the main makefile
CXX := g++ CXX := g++-mp-devel
AR := ar AR := ar
FORMAT := clang-format-11 FORMAT := clang-format-11
@ -30,7 +30,7 @@ ifneq ($(LTO),0)
CXXFLAGS += -flto CXXFLAGS += -flto
endif 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)) CXX_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h)) H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h))
@ -67,4 +67,4 @@ build/%.o: %.cpp
$(LIB): $(O_FILES) $(LIB): $(O_FILES)
$(AR) rcs $@ $^ $(AR) rcs $@ $^
-include $(D_FILES) -include $(D_FILES)

View file

@ -15,6 +15,8 @@ else
CXX := g++ CXX := g++
endif endif
CXX := g++-mp-devel
INC := -I ZAPD -I lib/elfio -I lib/libgfxd -I lib/tinyxml2 -I ZAPDUtils 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 CXXFLAGS := -fpic -std=c++17 -Wall -Wextra -fno-omit-frame-pointer
OPTFLAGS := OPTFLAGS :=
@ -45,7 +47,7 @@ endif
# CXXFLAGS += -DTEXTURE_DEBUG # CXXFLAGS += -DTEXTURE_DEBUG
LDFLAGS := -lm -ldl -lpng \ 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 # Use LLD if available. Set LLD=0 to not use it
ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0)
@ -64,12 +66,8 @@ ifneq ($(UNAME), Darwin)
else else
EXPORTERS := -Wl,-force_load ../OTRExporter/OTRExporter/OTRExporter.a EXPORTERS := -Wl,-force_load ../OTRExporter/OTRExporter/OTRExporter.a
ifeq ($(UNAMEM),arm64) ifeq ($(UNAMEM),arm64)
ifeq ($(shell brew list libpng > /dev/null 2>&1; echo $$?),0) LDFLAGS += $(shell pkg-config --libs libpng)
LDFLAGS += -L $(shell brew --prefix)/lib INC += $(shell pkg-config --cflags libpng)
INC += -I $(shell brew --prefix)/include
else
$(error Please install libpng via Homebrew)
endif
endif endif
endif endif

View file

@ -5,8 +5,10 @@
#include "yaz0/yaz0.h" #include "yaz0/yaz0.h"
#ifndef _MSC_VER #ifndef _MSC_VER
#ifndef __APPLE__
#include <byteswap.h> #include <byteswap.h>
#endif #endif
#endif
#include <Globals.h> #include <Globals.h>
namespace fs = std::filesystem; namespace fs = std::filesystem;
@ -17,6 +19,10 @@ namespace fs = std::filesystem;
#define __bswap_32 _byteswap_ulong #define __bswap_32 _byteswap_ulong
#define bswap_32 _byteswap_ulong #define bswap_32 _byteswap_ulong
#endif #endif
#if defined __APPLE__
#define __bswap32 __builtin_bswap32
#define bswap32 __builtin_bswap32
#endif
// ROM DMA Table Start // ROM DMA Table Start
#define OOT_OFF_NTSC_10_RC 0x7430 #define OOT_OFF_NTSC_10_RC 0x7430

View file

@ -1,7 +1,8 @@
# Only used for standalone compilation, usually inherits these from the main makefile # Only used for standalone compilation, usually inherits these from the main makefile
CXX := g++-mp-devel
CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17 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)) CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h)) H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h))

View file

@ -1,3 +1,4 @@
CC := gcc-mp-devel
CFLAGS = -Wall -O2 -g CFLAGS = -Wall -O2 -g
UC_OBJ = uc_f3d.o uc_f3db.o uc_f3dex.o uc_f3dexb.o uc_f3dex2.o UC_OBJ = uc_f3d.o uc_f3db.o uc_f3dex.o uc_f3dexb.o uc_f3dex2.o
OBJ = gfxd.o $(UC_OBJ) OBJ = gfxd.o $(UC_OBJ)

View file

@ -1,7 +1,7 @@
# Only used for standalone compilation, usually inherits these from the main makefile # Only used for standalone compilation, usually inherits these from the main makefile
CXX := g++ CXX := g++-mp-devel
CC := gcc CC := gcc-mp-devel
AR := ar AR := ar
FORMAT := clang-format-11 FORMAT := clang-format-11
@ -18,9 +18,9 @@ WARN := -Wall -Wextra -Werror \
-Wno-narrowing \ -Wno-narrowing \
-Wno-missing-field-initializers -Wno-missing-field-initializers
CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 -m32 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 -m32 CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0
CPPFLAGS := -MMD CPPFLAGS := -MMD $(shell pkg-config --cflags sdl2 glew)
ifneq ($(DEBUG),0) ifneq ($(DEBUG),0)
CXXFLAGS += -g -D_DEBUG CXXFLAGS += -g -D_DEBUG
@ -37,7 +37,7 @@ ifneq ($(LTO),0)
CFLAGS += -flto CFLAGS += -flto
endif endif
SRC_DIRS := $(shell find -type d -not -path "*build*") SRC_DIRS := $(shell find . -type d -not -path "*build*")
CXX_FILES := \ CXX_FILES := \
$(shell find libultraship/Factories -name *.cpp) \ $(shell find libultraship/Factories -name *.cpp) \
@ -93,4 +93,4 @@ build/%.o: %.c
$(LIB): $(O_FILES) $(LIB): $(O_FILES)
$(AR) rcs $@ $^ $(AR) rcs $@ $^
-include $(D_FILES) -include $(D_FILES)

View file

@ -27,6 +27,9 @@
#include "SDL.h" #include "SDL.h"
#define GL_GLEXT_PROTOTYPES 1 #define GL_GLEXT_PROTOTYPES 1
#include "SDL_opengl.h" #include "SDL_opengl.h"
#elif __APPLE__
#include <SDL.h>
#include <GL/glew.h>
#else #else
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <GL/glew.h> #include <GL/glew.h>
@ -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++) { for (int i = 0; i < cc_features.num_inputs; i++) {
char name[16]; char name[32];
sprintf(name, "aInput%d", i + 1); sprintf(name, "aInput%d", i + 1);
prg->attrib_locations[cnt] = glGetAttribLocation(shader_program, name); prg->attrib_locations[cnt] = glGetAttribLocation(shader_program, name);
prg->attrib_sizes[cnt] = cc_features.opt_alpha ? 4 : 3; prg->attrib_sizes[cnt] = cc_features.opt_alpha ? 4 : 3;

View file

@ -2,6 +2,7 @@
#define GFX_PC_H #define GFX_PC_H
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <unordered_map> #include <unordered_map>
#include <list> #include <list>

View file

@ -13,6 +13,8 @@
#include "SDL.h" #include "SDL.h"
#define GL_GLEXT_PROTOTYPES 1 #define GL_GLEXT_PROTOTYPES 1
#include "SDL_opengl.h" #include "SDL_opengl.h"
#elif __APPLE__
#include <SDL.h>
#else #else
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#define GL_GLEXT_PROTOTYPES 1 #define GL_GLEXT_PROTOTYPES 1
@ -120,8 +122,10 @@ static void set_fullscreen(bool on, bool call_callback) {
static uint64_t previous_time; static uint64_t previous_time;
#ifndef __linux__ #ifndef __linux__
#ifndef __APPLE__
static HANDLE timer; static HANDLE timer;
#endif #endif
#endif
static int frameDivisor = 1; 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); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
#ifndef __linux #ifndef __linux
#ifndef __APPLE__
timer = CreateWaitableTimer(nullptr, false, nullptr); timer = CreateWaitableTimer(nullptr, false, nullptr);
#endif
#endif #endif
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); //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 next = qpc_to_100ns(previous_time) + 10 * FRAME_INTERVAL_US_NUMERATOR / FRAME_INTERVAL_US_DENOMINATOR;
const int64_t left = next - qpc_to_100ns(t); const int64_t left = next - qpc_to_100ns(t);
if (left > 0) { if (left > 0) {
#ifdef __linux__ #if defined __linux__ || defined __APPLE__
const timespec spec = { 0, left * 100 }; const timespec spec = { 0, left * 100 };
nanosleep(&spec, nullptr); nanosleep(&spec, nullptr);
#else #else

View file

@ -1,5 +1,5 @@
CXX := g++ CXX := g++-mp-devel
CC := gcc CC := gcc-mp-devel
LD := lld LD := lld
AR := ar AR := ar
FORMAT := clang-format-11 FORMAT := clang-format-11
@ -16,11 +16,11 @@ LTO ?= 0
WARN := \ WARN := \
-Wno-return-type \ -Wno-return-type \
-funsigned-char \ -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 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 CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib -march=i386
LDFLAGS := -m32 LDFLAGS :=
CPPFLAGS := -MMD CPPFLAGS := -MMD
ifneq ($(DEBUG),0) ifneq ($(DEBUG),0)
@ -155,4 +155,4 @@ $(TARGET): $(LIBULTRASHIP)
$(TARGET): $(O_FILES) $(TARGET): $(O_FILES)
$(CXX) $^ -o $@ $(LDFLAGS) -fuse-ld=$(LD) $(LDDIRS) $(LDLIBS) $(CXX) $^ -o $@ $(LDFLAGS) -fuse-ld=$(LD) $(LDDIRS) $(LDLIBS)
-include $(D_FILES) -include $(D_FILES)