From 001b23410aa9ee45522844a8010a73fd852bd653 Mon Sep 17 00:00:00 2001 Date: Mon, 15 Aug 2016 13:10:21 +0200 Subject: [PATCH] FIX: Compiling for SDL2 on Mac OS X & making distributable bundles --- .gitignore | 2 ++ Makefile | 18 +++++++++++------- OSX/osx.mk | 10 +++++++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index f69e15c..93e29f6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ *.log *.out *.exe +*.app *.vcxproj.filters *.zip* *.7z @@ -33,6 +34,7 @@ ipch /makeobj/makeobj *sim /binaries +/OSX/getversion /save /screenshot /maps diff --git a/Makefile b/Makefile index ae6ab7e..2315cf5 100755 --- a/Makefile +++ b/Makefile @@ -59,6 +59,11 @@ else endif endif +ifeq ($(OSTYPE),mac) + CFLAGS += -std=c++11 -stdlib=libstdc++ + LDFLAGS += -stdlib=libstdc++ +endif + ifeq ($(OSTYPE),mingw) SOURCES += clipboard_w32.cc else @@ -512,8 +517,8 @@ ifeq ($(BACKEND),sdl2) endif ifeq ($(SDL2_CONFIG),) ifeq ($(OSTYPE),mac) - SDL_CFLAGS := -I/System/Libraries/Frameworks/SDL2/Headers -Dmain=SDL_main - SDL_LDFLAGS := -framework SDL2 -framework Cocoa -I/System/Libraries/Frameworks/SDL2/Headers SDLMain.m + SDL_CFLAGS := -I/Library/Frameworks/SDL2.framework/Headers + SDL_LDFLAGS := -framework SDL2 else SDL_CFLAGS := -I$(MINGDIR)/include/SDL2 -Dmain=SDL_main SDL_LDFLAGS := -lSDL2main -lSDL2 @@ -565,12 +570,11 @@ ifeq ($(BACKEND),opengl) endif CFLAGS += $(SDL_CFLAGS) LIBS += $(SDL_LDFLAGS) - ifeq ($(OSTYPE),mingw) - LIBS += -lglew32 -lopengl32 + ifeq ($(OSTYPE),mac) + LIBS += -framework OpenGL else - LIBS += -lGL - ifeq ($(OSTYPE),mac) - LIBS += -framework OpenGL + ifeq ($(OSTYPE),mingw) + LIBS += -lglew32 -lopengl32 else LIBS += -lglew32 -lGL endif diff --git a/OSX/osx.mk b/OSX/osx.mk index 24d4551..4b080e6 100644 --- a/OSX/osx.mk +++ b/OSX/osx.mk @@ -8,6 +8,7 @@ # BINARY_i386 path to the binary for i386 (default $(PROGDIR)/$(PROG)) # SDL_PPC path to SDL.framwork for PPC # SDL_i386 path to SDL.framwork for i386 (default ../Frameworks/SDL.framework) +# SDL2_i386 path to SDL2.framework for i386 (default /Library/Frameworks/SDL2.framework); PPC no longer officially supported # The name of the project is simutrans => thus we want to build the default bundle under simutrans @@ -20,6 +21,7 @@ endif CXXHOST ?= $(CXX) BINARY_i386 ?= "$(PROGDIR)/$(PROG).app/Contents/MacOS/$(PROG)" SDL_i386 ?= "../Frameworks/SDL.framework" +SDL2_i386 ?= "/Library/Frameworks/SDL2.framework" .PHONY: bundle bundle_dist @@ -42,7 +44,13 @@ bundle_dist: bundle @echo "===> Changing bundle to be distributable" $(Q)mkdir -p "$(PROGDIR)/$(PROG).app/Contents/Frameworks" $(Q)cp "$(BINARY_i386)" "$(PROGDIR)/$(PROG).app/Contents/MacOS/$(PROG).i386" - $(Q)cp "$(BINARY_PPC)" "$(PROGDIR)/$(PROG).app/Contents/MacOS/$(PROG).ppc" + $(Q)cp "$(BINARY_PPC)" "$(PROGDIR)/$(PROG).app/Contents/MacOS/$(PROG).ppc" || echo "Couldn't copy PowerPC binary (not important if not targeting PowerPC)" $(Q)cp "OSX/binary_picker.sh" "$(PROGDIR)/$(PROG).app/Contents/MacOS/$(PROG)" + $(Q)install_name_tool -add_rpath "@loader_path/../Frameworks" "$(PROGDIR)/$(PROG).app/Contents/MacOS/$(PROG).i386" +ifeq ($(BACKEND),sdl) $(Q)cp -r "$(SDL_PPC)" "$(PROGDIR)/$(PROG).app/Contents/Frameworks/SDL-ppc.framework" $(Q)cp -r "$(SDL_i386)" "$(PROGDIR)/$(PROG).app/Contents/Frameworks/SDL-i386.framework" +endif +ifeq ($(BACKEND),sdl2) + $(Q)cp -r "$(SDL2_i386)" "$(PROGDIR)/$(PROG).app/Contents/Frameworks/SDL2.framework" +endif --