mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
Update Makefiles to handle both platforms
This commit is contained in:
parent
e4959618fa
commit
3bf32d1e2e
12 changed files with 120 additions and 44 deletions
|
@ -1,6 +1,6 @@
|
|||
# Only used for standalone compilation, usually inherits these from the main makefile
|
||||
|
||||
CXX := g++-mp-devel
|
||||
CXX := g++-12
|
||||
AR := ar
|
||||
FORMAT := clang-format-11
|
||||
|
||||
|
|
|
@ -7,15 +7,9 @@ DEBUG ?= 0
|
|||
COPYCHECK_ARGS ?=
|
||||
LLD ?= 0
|
||||
WERROR ?= 0
|
||||
UNAME := $(shell uname)
|
||||
|
||||
# Use clang++ if available, else use g++
|
||||
ifeq ($(shell command -v clang++ >/dev/null 2>&1; echo $$?),0)
|
||||
CXX := clang++
|
||||
else
|
||||
CXX := g++
|
||||
endif
|
||||
|
||||
CXX := g++-mp-devel
|
||||
CXX := g++-12
|
||||
|
||||
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
|
||||
|
@ -47,10 +41,13 @@ endif
|
|||
# CXXFLAGS += -DTEXTURE_DEBUG
|
||||
|
||||
LDFLAGS := -lm -ldl -lpng \
|
||||
-L../external -L../libultraship -lz -lbz2 -pthread -lpulse -lultraship -lstorm $(shell pkg-config --libs glew x11 libpng) $(shell sdl2-config --libs)
|
||||
|
||||
|
||||
-L../external -L../libultraship -lz -lbz2 -pthread -lpulse -lultraship -lstorm -lSDL2 -lGLEW -lX11
|
||||
|
||||
ifeq ($(UNAME), Darwin)
|
||||
LDFLAGS += $(shell pkg-config --libs glew x11 libpng) $(shell sdl2-config --libs) -framework OpenGL
|
||||
else
|
||||
LDFLAGS += -lGL
|
||||
endif
|
||||
|
||||
# Use LLD if available. Set LLD=0 to not use it
|
||||
ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0)
|
||||
|
@ -61,7 +58,6 @@ ifneq ($(LLD),0)
|
|||
LDFLAGS += -fuse-ld=lld
|
||||
endif
|
||||
|
||||
UNAME := $(shell uname)
|
||||
UNAMEM := $(shell uname -m)
|
||||
ifneq ($(UNAME), Darwin)
|
||||
LDFLAGS += -Wl,-export-dynamic -lstdc++fs
|
||||
|
@ -69,8 +65,8 @@ ifneq ($(UNAME), Darwin)
|
|||
else
|
||||
EXPORTERS := -Wl,-force_load ../OTRExporter/OTRExporter/OTRExporter.a
|
||||
ifeq ($(UNAMEM),arm64)
|
||||
LDFLAGS += $(shell pkg-config --libs libpng)
|
||||
INC += $(shell pkg-config --cflags libpng)
|
||||
LDFLAGS += $(shell pkg-config --libs libpng)
|
||||
INC += $(shell pkg-config --cflags libpng)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Only used for standalone compilation, usually inherits these from the main makefile
|
||||
CXX := g++-mp-devel
|
||||
CXX := g++-12
|
||||
CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17
|
||||
|
||||
SRC_DIRS := $(shell find . -type d -not -path "*build*")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CC := gcc-mp-devel
|
||||
CC := gcc-12
|
||||
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)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
# Only used for standalone compilation, usually inherits these from the main makefile
|
||||
|
||||
CXX := g++-mp-devel
|
||||
CC := gcc-mp-devel
|
||||
CXX := g++-12
|
||||
CC := gcc-12
|
||||
AR := ar
|
||||
FORMAT := clang-format-11
|
||||
UNAME := $(shell uname)
|
||||
|
||||
ASAN ?= 0
|
||||
DEBUG ?= 1
|
||||
|
@ -18,9 +19,20 @@ WARN := -Wall -Wextra -Werror \
|
|||
-Wno-narrowing \
|
||||
-Wno-missing-field-initializers
|
||||
|
||||
CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 -Wno-deprecated-enum-enum-conversion
|
||||
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)
|
||||
CPPFLAGS := -MMD
|
||||
|
||||
ifeq ($(UNAME), Linux) #LINUX
|
||||
CXXFLAGS += -m32
|
||||
CFLAGS += -m32
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME), Darwin) #APPLE
|
||||
CXXFLAGS += -Wno-deprecated-enum-enum-conversion
|
||||
CPPFLAGS += -framework OpenGL
|
||||
CPPFLAGS += $(shell pkg-config --cflags sdl2 glew)
|
||||
endif
|
||||
|
||||
ifneq ($(DEBUG),0)
|
||||
CXXFLAGS += -g -D_DEBUG
|
||||
|
|
|
@ -105,7 +105,7 @@ static bool current_depth_mask;
|
|||
|
||||
static uint32_t frame_count;
|
||||
|
||||
static vector<Framebuffer> framebuffers;
|
||||
static std::vector<Framebuffer> framebuffers;
|
||||
static size_t current_framebuffer;
|
||||
static float current_noise_scale;
|
||||
static FilteringMode current_filter_mode = THREE_POINT;
|
||||
|
@ -637,7 +637,7 @@ static uint32_t gfx_cm_to_opengl(uint32_t val) {
|
|||
|
||||
static void gfx_opengl_set_sampler_parameters(int tile, bool linear_filter, uint32_t cms, uint32_t cmt) {
|
||||
const GLint filter = linear_filter && current_filter_mode == LINEAR ? GL_LINEAR : GL_NEAREST;
|
||||
GL_CHECK(glActiveTexture(GL_TEXTURE0 + tile));
|
||||
glActiveTexture(GL_TEXTURE0 + tile);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, gfx_cm_to_opengl(cms));
|
||||
|
@ -750,6 +750,7 @@ static int gfx_opengl_create_framebuffer() {
|
|||
glGenFramebuffers(1, &fbo);
|
||||
|
||||
size_t i = framebuffers.size();
|
||||
printf("framebuffers size %ld\n", i);
|
||||
framebuffers.resize(i + 1);
|
||||
|
||||
framebuffers[i].fbo = fbo;
|
||||
|
@ -892,7 +893,7 @@ static std::map<std::pair<float, float>, uint16_t> gfx_opengl_get_pixel_depth(in
|
|||
}
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, pixel_depth_fb);
|
||||
vector<uint32_t> depth_stencil_values(coordinates.size());
|
||||
std::vector<uint32_t> depth_stencil_values(coordinates.size());
|
||||
glReadPixels(0, 0, coordinates.size(), 1, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, depth_stencil_values.data());
|
||||
|
||||
{
|
||||
|
|
|
@ -66,11 +66,15 @@
|
|||
|
||||
// SDL
|
||||
// (the multi-viewports feature requires SDL features supported from SDL 2.0.4+. SDL 2.0.5+ is highly recommended)
|
||||
#if defined(__APPLE__)
|
||||
#include "SDL.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "SDL_stdinc.h"
|
||||
#include <TargetConditionals.h>
|
||||
#else
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_syswm.h>
|
||||
#include <SDL2/SDL_stdinc.h>
|
||||
#if defined(__APPLE__)
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2,0,4) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS)
|
||||
|
@ -865,7 +869,11 @@ static void ImGui_ImplSDL2_SwapBuffers(ImGuiViewport* viewport, void*)
|
|||
// Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface)
|
||||
// SDL is graceful enough to _not_ need <vulkan/vulkan.h> so we can safely include this.
|
||||
#if SDL_HAS_VULKAN
|
||||
#if defined(__APPLE__)
|
||||
#include "SDL_vulkan.h"
|
||||
#else
|
||||
#include <SDL2/SDL_vulkan.h>
|
||||
#endif
|
||||
static int ImGui_ImplSDL2_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
|
||||
{
|
||||
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#pragma once
|
||||
#include "AudioPlayer.h"
|
||||
#if __APPLE__
|
||||
#include <SDL.h>
|
||||
#else
|
||||
#include <SDL2/SDL.h>
|
||||
#endif
|
||||
|
||||
namespace Ship {
|
||||
class SDLAudioPlayer : public AudioPlayer {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#pragma once
|
||||
#include "Controller.h"
|
||||
#if __APPLE__
|
||||
#include <SDL.h>
|
||||
#else
|
||||
#include <SDL2/SDL.h>
|
||||
#endif
|
||||
|
||||
#define INVALID_SDL_CONTROLLER_GUID (std::string("00000000000000000000000000000000"))
|
||||
|
||||
|
|
|
@ -153,11 +153,7 @@ namespace SohImGui {
|
|||
void ImGuiBackendInit() {
|
||||
switch (impl.backend) {
|
||||
case Backend::SDL:
|
||||
#if __APPLE__
|
||||
ImGui_ImplOpenGL3_Init("#version 420");
|
||||
#else
|
||||
ImGui_ImplOpenGL3_Init("#version 120");
|
||||
#endif
|
||||
break;
|
||||
|
||||
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
||||
|
|
|
@ -18,7 +18,11 @@
|
|||
#include "Lib/Fast3D/gfx_sdl.h"
|
||||
#include "Lib/Fast3D/gfx_opengl.h"
|
||||
#include "stox.h"
|
||||
#if __APPLE__
|
||||
#include <SDL.h>
|
||||
#else
|
||||
#include <SDL2/SDL.h>
|
||||
#endif
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
|
|
79
soh/Makefile
79
soh/Makefile
|
@ -1,9 +1,10 @@
|
|||
CXX := g++-mp-devel
|
||||
CC := gcc-mp-devel
|
||||
CXX := g++-12
|
||||
CC := gcc-12
|
||||
LD := lld
|
||||
AR := ar
|
||||
FORMAT := clang-format-11
|
||||
ZAPD := ../ZAPDTR/ZAPD.out
|
||||
UNAME := $(shell uname)
|
||||
|
||||
LIBULTRASHIP := ../libultraship/libultraship.a
|
||||
ZAPDUTILS := ../ZAPDTR/ZAPDUtils/ZAPDUtils.a
|
||||
|
@ -18,9 +19,21 @@ WARN := \
|
|||
-funsigned-char \
|
||||
-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 $(shell pkg-config --cflags sdl2 x11)
|
||||
CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib $(shell pkg-config --cflags sdl2 x11)
|
||||
CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib
|
||||
CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib
|
||||
LDFLAGS :=
|
||||
|
||||
ifeq ($(UNAME), Linux) #LINUX
|
||||
CXXFLAGS += -march=i386 -m32 -mhard-float
|
||||
CFLAGS += $(WARN) -march=i386
|
||||
LDFLAGS += -m32
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME), Darwin) #APPLE
|
||||
CXXFLAGS += $(shell pkg-config --cflags sdl2 x11) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) -framework OpenGL
|
||||
CFLAGS += $(shell pkg-config --cflags sdl2 x11) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) -framework OpenGL
|
||||
endif
|
||||
|
||||
CPPFLAGS := -MMD
|
||||
|
||||
ifneq ($(DEBUG),0)
|
||||
|
@ -28,9 +41,6 @@ ifneq ($(DEBUG),0)
|
|||
CFLAGS += -g
|
||||
endif
|
||||
|
||||
CXXFLAGS += -g
|
||||
CFLAGS += -g
|
||||
|
||||
ifneq ($(ASAN),0)
|
||||
CXXFLAGS += -fsanitize=address
|
||||
LDFLAGS += -fsanitize=address
|
||||
|
@ -43,6 +53,14 @@ endif
|
|||
|
||||
TARGET := soh.arm64
|
||||
|
||||
# ifeq ($(UNAME), Linux) #LINUX
|
||||
# TARGET := soh.elf
|
||||
# endif
|
||||
|
||||
# ifeq ($(UNAME), Darwin) #APPLE
|
||||
# TARGET := soh.arm64
|
||||
# endif
|
||||
|
||||
INC_DIRS := $(addprefix -I, \
|
||||
. \
|
||||
assets \
|
||||
|
@ -54,18 +72,37 @@ INC_DIRS := $(addprefix -I, \
|
|||
../libultraship/libultraship/Lib/spdlog/include \
|
||||
../libultraship/libultraship/Lib/Fast3D/U64 \
|
||||
../libultraship/libultraship/Lib/Fast3D/U64/PR \
|
||||
/opt/X11/include \
|
||||
)
|
||||
CFLAGS := $(CFLAGS) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew)
|
||||
CXXFLAGS := $(CXXFLAGS) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew)
|
||||
|
||||
ifeq ($(UNAME), Linux) #LINUX
|
||||
INC_DIRS += $(addprefix -I, \
|
||||
/opt/X11/include \
|
||||
)
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME), Darwin) #APPLE
|
||||
INC_DIRS += $(addprefix -I, \
|
||||
/opt/homebrew/Cellar/libx11/1.8/include \
|
||||
)
|
||||
endif
|
||||
|
||||
LDDIRS := $(addprefix -L, \
|
||||
../external \
|
||||
../libultraship/ \
|
||||
/opt/X11/lib \
|
||||
)
|
||||
|
||||
ifeq ($(UNAME), Linux) #LINUX
|
||||
LDDIRS += $(addprefix -L, \
|
||||
/opt/X11/lib \
|
||||
)
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME), Darwin) #APPLE
|
||||
LDDIRS += $(addprefix -L, \
|
||||
/opt/homebrew/Cellar/libx11/1.8/lib \
|
||||
)
|
||||
endif
|
||||
|
||||
LDLIBS := \
|
||||
$(ZAPDUTILS) \
|
||||
$(addprefix -l, \
|
||||
|
@ -75,12 +112,26 @@ LDLIBS := \
|
|||
z \
|
||||
pthread \
|
||||
atomic \
|
||||
GL \
|
||||
storm \
|
||||
ultraship \
|
||||
) \
|
||||
)
|
||||
|
||||
LDLIBS := $(LDLIBS) $(shell sdl2-config --libs) $(shell pkg-config --libs glew)
|
||||
ifeq ($(UNAME), Linux) #LINUX
|
||||
LDLIBS += \
|
||||
$(addprefix -l, \
|
||||
GL \
|
||||
pulse \
|
||||
)
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME), Darwin) #APPLE
|
||||
LDLIBS += \
|
||||
$(addprefix -framework, \
|
||||
OpenGL \
|
||||
CoreFoundation \
|
||||
) \
|
||||
$(shell sdl2-config --libs) $(shell pkg-config --libs glew)
|
||||
endif
|
||||
|
||||
ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*")
|
||||
ASSET_FILES_XML := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.xml))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue