Skip to content

Commit

Permalink
Makefile / library path modifications to make M1 building work (korea…
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrm committed Mar 22, 2023
1 parent 82e6c28 commit 2aa7ad9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
11 changes: 11 additions & 0 deletions Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ else
endif

UNAME:=$(shell uname -s)
UNAME_ARCH:=$(shell uname -m)

# use MAKEFILE_DIR instead of CURDIR for variables that are exported through -include
MAKEFILE_DIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
Expand Down Expand Up @@ -189,8 +190,14 @@ endif

ifneq (,$(filter $(UNAME), Darwin))
export DARWINHOST=1
ifneq (,$(filter $(UNAME_ARCH), arm64))
export DARWINM1HOST=1
endif
ifdef EMULATE_READER
export DARWIN=1
ifdef DARWINM1HOST
export DARWIN_M1=1
endif
endif
endif

Expand Down Expand Up @@ -500,6 +507,10 @@ ifdef MACOS
HOST_ARCH:=-mtune=generic
endif

ifdef DARWINM1HOST
HOST_ARCH:=-mcpu=apple-m1
endif

# Anything below GCC 6 gets to be forcefully switched to decent standards, because some of our deps require C11 & C++11 support.
# NOTE: Technically, this also means we require Clang >= 3.2, but that should more or less hold true on our end, because that's truly ancient.
# Tests heavily inspired from Linux's build system ;).
Expand Down
2 changes: 1 addition & 1 deletion Makefile.third
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ $(OPENSSL_LIB) $(OPENSSL_DIR): $(THIRDPARTY_DIR)/openssl/*.*
-DRANLIB="$(RANLIB)" \
-DCHOST="$(CHOST)" \
$(if $(ANDROID),-DNDKABI=$(NDKABI),) \
-DCONFIG_SCRIPT="$(if $(EMULATE_READER),$(if $(DARWIN),Configure darwin64-x86_64-cc,config),Configure $(if $(WIN32),mingw,))" \
-DCONFIG_SCRIPT="$(if $(EMULATE_READER),$(if $(DARWIN),Configure $(if $(DARWIN_M1),darwin64-arm64-cc,darwin64-x86_64-cc),config),Configure $(if $(WIN32),mingw,))" \
$(CURDIR)/$(THIRDPARTY_DIR)/openssl && \
$(CMAKE_MAKE_PROGRAM) $(CMAKE_MAKE_PROGRAM_FLAGS)

Expand Down
2 changes: 2 additions & 0 deletions ffi/SDL2_0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ require("ffi/linux_input_h")
-----------------------------------------------------------------

local SDL = util.ffiLoadCandidates{
"/usr/local/opt/lib/libSDL2.dylib",
"/opt/homebrew/lib/libSDL2.dylib",
"SDL2",
-- this unfortunately needs to be written in full due to the . in the name
"libSDL2-2.0.so",
Expand Down
2 changes: 1 addition & 1 deletion ffi/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ function util.haveSDL2()
if haveSDL2 == nil then
local candidates
if ffi.os == "OSX" then
candidates = {"libs/libSDL2.dylib", "SDL2"}
candidates = {"/opt/homebrew/lib/libSDL2.dylib", "libs/libSDL2.dylib", "SDL2"}
else
candidates = {"SDL2", "libSDL2-2.0.so", "libSDL2-2.0.so.0"}
end
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/glib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ endif()
if(NOT DEFINED ENV{DARWIN})
set(LDFLAGS "${LDFLAGS} -Wl,-rpath-link,${ZLIB_DIR}/lib -Wl,-rpath-link,${LIBFFI_DIR}/.libs -Wl,-rpath-link,${BINARY_DIR}/gmodule/.libs")
else()
set(CFLAGS "-I/usr/local/opt/gettext/include ${CFLAGS}")
set(LDFLAGS "${LDFLAGS} -L/usr/local/opt/gettext/lib -L${LIBICONV_DIR}/lib -L${ZLIB_DIR}/lib -L${LIBFFI_DIR}/.libs -L${BINARY_DIR}/gmodule/.libs")
set(CFLAGS "-I/usr/local/opt/gettext/include -I/opt/homebrew/include ${CFLAGS}")
set(LDFLAGS "${LDFLAGS} -L/usr/local/opt/gettext/lib -L/opt/homebrew/lib -L${LIBICONV_DIR}/lib -L${ZLIB_DIR}/lib -L${LIBFFI_DIR}/.libs -L${BINARY_DIR}/gmodule/.libs")
endif()

set(CFG_OPTS "${CFG_OPTS} CFLAGS=\"${CFLAGS}\" LDFLAGS=\"${LDFLAGS}\" ${HOST_OPTS}")
Expand Down

0 comments on commit 2aa7ad9

Please sign in to comment.