Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS universal binary #42

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
316bfb2
Simplify glsl -> C stringification
timangus Aug 29, 2020
a64ea92
Upgrades to Xcode project and Apple Silicon support
danielepantaleone-octo Oct 29, 2023
111ae59
Update SDL2 to 2.0.14
tomkidd Feb 26, 2021
4465e09
Update SDL2 to 2.0.14
tomkidd Mar 4, 2021
0b89415
Updated SDL2 include files to fix Mac build in GitHub Actions
tomkidd Mar 8, 2021
de0cfaf
Added another mention of arm64 to command line help
tomkidd Mar 16, 2021
ab5cf81
Restored original opus sse files, excluded from Xcode
tomkidd Mar 18, 2021
ec6b856
Added shell script to compile Universal 2 binary (x86_64+arm64)
tomkidd Jun 27, 2021
b848ccf
Reverting alert style to deprecated methods
tomkidd Jun 27, 2021
235e458
Add r_parallaxMapOffset.
SmileTheory Jul 6, 2021
e6bd729
Fix line not removed in previous commit.
SmileTheory Jul 6, 2021
f4e98cc
Removed signature from SDL dylib, enabled dark mode on macOS.
tomkidd Jul 11, 2021
3a078bd
spaces > tabs
tomkidd Jul 14, 2021
fc37a76
Ad-hoc signed libSDL2-2.0.0.dylib
tomkidd Jul 20, 2021
f34e19e
Fix compiling against SDL 2.0.17
zturtleman Aug 15, 2021
23a2b3a
UB2 now signs and notarizes, upgraded to SDL 2.0.16
tomkidd Sep 18, 2021
7472cd8
Architectures in libSDL2 restored for ppc and i386
tomkidd Sep 25, 2021
9e555de
Update SDL2 to 2.0.16
tomkidd Sep 26, 2021
af698cf
Updated SDL 2.0.16 headers and Mac version of libraries to fix GitHub…
tomkidd Oct 3, 2021
bf218ba
Addressed PR suggestions
tomkidd Oct 22, 2021
7bb3000
OpenGL2: Fix r_grayscale 1 making everything solid black
zturtleman Oct 23, 2021
40b77f2
Print full GL_EXTENSIONS list for OpenGL contexts before 3.0
zturtleman Oct 23, 2021
31fbadd
OpenGL2: GL_DEPTH_TEXTURE_MODE was removed from OpenGL 3.0/Core
zturtleman Oct 23, 2021
101c891
Make macOS arm64 default to target macOS 11 in Makefile
zturtleman Nov 7, 2021
d72af5b
Fix error when cross-compiling for macOS arm64 using Makefile
zturtleman Nov 7, 2021
cf9536c
Fix passing arguments to VM dylib on Apple M1
zturtleman Nov 19, 2021
464e709
Fix compiling on older macOS
zturtleman Oct 24, 2021
8abac6e
Fix hex digit
mjunix Feb 5, 2022
ea8a65e
Fix uninitialized variable
mjunix Feb 5, 2022
48e1e68
More predictable mesh normals generation
Mar 21, 2022
1791175
vm_x86.c: Add `defined(_M_IX86) || defined(_M_X64)` (fix for VS2019)
kungfooman Jan 4, 2022
d312437
Add keys for SDL 2.0.14's new gamepad buttons
zturtleman Sep 22, 2022
333ce91
Fix in_availableJoysticks cvar not updating
zturtleman Sep 22, 2022
1af4187
Fix (disabled) Wavelet sound decompression
zturtleman Nov 23, 2022
b35b710
Update to SDL 2.24.0 and add separate macOS UB2 dylib
zturtleman Sep 2, 2022
e888c7a
Update macOS UB1 to SDL 2.0.22
zturtleman Sep 3, 2022
2a51faa
Fix running make-macosx{,-ub2}.sh on Linux
zturtleman Sep 3, 2022
32efd50
Fix macOS client/server failing to start from terminal
zturtleman Jun 11, 2023
c5c8e6f
Don't list mod directories at Windows drive root
zturtleman Jul 6, 2023
642a10a
Fix merge due to different directory structure
danielepantaleone-octo Oct 29, 2023
5a0a39b
Revert "Simplify glsl -> C stringification"
danielepantaleone-octo Oct 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Makefile.local
.DS_Store
.LSOverride
Icon?
make-macosx-values.local

# Xcode
####################
Expand Down
124 changes: 106 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
COMPILE_PLATFORM=$(shell uname | sed -e 's/_.*//' | tr '[:upper:]' '[:lower:]' | sed -e 's/\//_/g')
COMPILE_ARCH=$(shell uname -m | sed -e 's/i.86/x86/' | sed -e 's/^arm.*/arm/')

#arm64 hack!
ifeq ($(shell uname -m), arm64)
COMPILE_ARCH=arm64
endif
ifeq ($(shell uname -m), aarch64)
COMPILE_ARCH=arm64
endif

ifeq ($(COMPILE_PLATFORM),sunos)
# Solaris uname and GNU uname differ
COMPILE_ARCH=$(shell uname -p | sed -e 's/i.86/x86/')
Expand Down Expand Up @@ -415,7 +423,34 @@ ifeq ($(PLATFORM),darwin)

# Default minimum Mac OS X version
ifeq ($(MACOSX_VERSION_MIN),)
MACOSX_VERSION_MIN=10.7
MACOSX_VERSION_MIN=10.9
ifneq ($(findstring $(ARCH),ppc ppc64),)
MACOSX_VERSION_MIN=10.5
endif
ifeq ($(ARCH),x86)
MACOSX_VERSION_MIN=10.6
endif
ifeq ($(ARCH),x86_64)
# trying to find default SDK version is hard
# macOS 10.15 requires -sdk macosx but 10.11 doesn't support it
# macOS 10.6 doesn't have -show-sdk-version
DEFAULT_SDK=$(shell xcrun -sdk macosx -show-sdk-version 2> /dev/null)
ifeq ($(DEFAULT_SDK),)
DEFAULT_SDK=$(shell xcrun -show-sdk-version 2> /dev/null)
endif
ifeq ($(DEFAULT_SDK),)
$(error Error: Unable to determine macOS SDK version. On macOS 10.6 to 10.8 run: make MACOSX_VERSION_MIN=10.6 On macOS 10.9 or later run: make MACOSX_VERSION_MIN=10.9 );
endif

ifneq ($(findstring $(DEFAULT_SDK),10.6 10.7 10.8),)
MACOSX_VERSION_MIN=10.6
else
MACOSX_VERSION_MIN=10.9
endif
endif
ifeq ($(ARCH),arm64)
MACOSX_VERSION_MIN=11.0
endif
endif

MACOSX_MAJOR=$(shell echo $(MACOSX_VERSION_MIN) | cut -d. -f1)
Expand All @@ -432,6 +467,11 @@ ifeq ($(PLATFORM),darwin)
BASE_CFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN) \
-DMAC_OS_X_VERSION_MIN_REQUIRED=$(MAC_OS_X_VERSION_MIN_REQUIRED)

MACOSX_ARCH=$(ARCH)
ifeq ($(ARCH),x86)
MACOSX_ARCH=i386
endif

ifeq ($(ARCH),ppc)
BASE_CFLAGS += -arch ppc
ALTIVEC_CFLAGS = -faltivec
Expand All @@ -450,6 +490,10 @@ ifeq ($(PLATFORM),darwin)
OPTIMIZEVM += -mfpmath=sse
BASE_CFLAGS += -arch x86_64
endif
ifeq ($(ARCH),arm64)
# HAVE_VM_COMPILED=false # TODO: implement compiled vm
BASE_CFLAGS += -arch arm64
endif

# When compiling on OSX for OSX, we're not cross compiling as far as the
# Makefile is concerned, as target architecture is specified as a compiler
Expand All @@ -459,19 +503,40 @@ ifeq ($(PLATFORM),darwin)
endif

ifeq ($(CROSS_COMPILING),1)
ifeq ($(ARCH),x86_64)
CC=x86_64-apple-darwin13-cc
RANLIB=x86_64-apple-darwin13-ranlib
else
ifeq ($(ARCH),x86)
CC=i386-apple-darwin13-cc
RANLIB=i386-apple-darwin13-ranlib
else
$(error Architecture $(ARCH) is not supported when cross compiling)
# If CC is already set to something generic, we probably want to use
# something more specific
ifneq ($(findstring $(strip $(CC)),cc gcc),)
CC=
endif

ifndef CC
ifndef DARWIN
# macOS 10.9 SDK
DARWIN=13
ifneq ($(findstring $(ARCH),ppc ppc64),)
# macOS 10.5 SDK, though as of writing osxcross doesn't support ppc/ppc64
DARWIN=9
endif
ifeq ($(ARCH),arm64)
# macOS 11.3 SDK
DARWIN=20.4
endif
endif

CC=$(MACOSX_ARCH)-apple-darwin$(DARWIN)-cc
RANLIB=$(MACOSX_ARCH)-apple-darwin$(DARWIN)-ranlib
LIPO=$(MACOSX_ARCH)-apple-darwin$(DARWIN)-lipo

ifeq ($(call bin_path, $(CC)),)
$(error Unable to find osxcross $(CC))
endif
endif
endif

ifndef LIPO
LIPO=lipo
endif

BASE_CFLAGS += -fno-strict-aliasing -fno-common -pipe

ifeq ($(USE_OPENAL),1)
Expand All @@ -496,20 +561,39 @@ ifeq ($(PLATFORM),darwin)
RENDERER_LIBS += -framework OpenGL

ifeq ($(USE_LOCAL_HEADERS),1)
# libSDL2-2.0.0.dylib for PPC is SDL 2.0.1 + changes to compile
ifneq ($(findstring $(ARCH),ppc ppc64),)
BASE_CFLAGS += -I$(SDLHDIR)/include-macppc
else
ifeq ($(shell test $(MAC_OS_X_VERSION_MIN_REQUIRED) -ge 1090; echo $$?),0)
# Universal Binary 2 - for running on macOS 10.9 or later
# x86_64 (10.9 or later), arm64 (11.0 or later)
MACLIBSDIR=$(LIBSDIR)/macosx-ub2
BASE_CFLAGS += -I$(SDLHDIR)/include
else
# Universal Binary - for running on Mac OS X 10.5 or later
# ppc (10.5/10.6), x86 (10.6 or later), x86_64 (10.6 or later)
#
# x86/x86_64 on 10.5 will run the ppc build.
#
# SDL 2.0.1, last with Mac OS X PowerPC
# SDL 2.0.4, last with Mac OS X 10.5 (x86/x86_64)
# SDL 2.0.22, last with Mac OS X 10.6 (x86/x86_64)
#
# code/libs/macosx-ub/libSDL2-2.0.0.dylib contents
# - ppc build is SDL 2.0.1 with a header change so it compiles
# - x86/x86_64 build are SDL 2.0.22
MACLIBSDIR=$(LIBSDIR)/macosx-ub
ifneq ($(findstring $(ARCH),ppc ppc64),)
BASE_CFLAGS += -I$(SDLHDIR)/include-macppc
else
BASE_CFLAGS += -I$(SDLHDIR)/include-2.0.22
endif
endif

# We copy sdlmain before ranlib'ing it so that subversion doesn't think
# the file has been modified by each build.
LIBSDLMAIN=$(B)/libSDL2main.a
LIBSDLMAINSRC=$(LIBSDIR)/macosx/libSDL2main.a
CLIENT_LIBS += $(LIBSDIR)/macosx/libSDL2-2.0.0.dylib
RENDERER_LIBS += $(LIBSDIR)/macosx/libSDL2-2.0.0.dylib
CLIENT_EXTRA_FILES += $(LIBSDIR)/macosx/libSDL2-2.0.0.dylib
LIBSDLMAINSRC=$(MACLIBSDIR)/libSDL2main.a
CLIENT_LIBS += $(MACLIBSDIR)/libSDL2-2.0.0.dylib
RENDERER_LIBS += $(MACLIBSDIR)/libSDL2-2.0.0.dylib
CLIENT_EXTRA_FILES += $(MACLIBSDIR)/libSDL2-2.0.0.dylib
else
BASE_CFLAGS += -I/Library/Frameworks/SDL2.framework/Headers
CLIENT_LIBS += -framework SDL2
Expand Down Expand Up @@ -1917,7 +2001,11 @@ endif
ifneq ($(strip $(LIBSDLMAIN)),)
ifneq ($(strip $(LIBSDLMAINSRC)),)
$(LIBSDLMAIN) : $(LIBSDLMAINSRC)
ifeq ($(PLATFORM),darwin)
$(LIPO) -extract $(MACOSX_ARCH) $< -o $@
else
cp $< $@
endif
$(RANLIB) $@
endif
endif
Expand Down
Loading