Fix compiling on older macOS

ranlib errors on older macOS because of arm64 arch in code/libs/macosx/-
libSDL2main.a. Use lipo to extract the library for the specific arch
that is being linked.
This commit is contained in:
Zack Middleton 2021-10-24 04:38:34 -04:00
parent 75ae9119e6
commit 9543cf24df
1 changed files with 9 additions and 0 deletions

View File

@ -525,6 +525,7 @@ ifeq ($(PLATFORM),darwin)
CC=$(MACOSX_ARCH)-apple-darwin$(DARWIN)-cc CC=$(MACOSX_ARCH)-apple-darwin$(DARWIN)-cc
RANLIB=$(MACOSX_ARCH)-apple-darwin$(DARWIN)-ranlib RANLIB=$(MACOSX_ARCH)-apple-darwin$(DARWIN)-ranlib
LIPO=$(MACOSX_ARCH)-apple-darwin$(DARWIN)-lipo
ifeq ($(call bin_path, $(CC)),) ifeq ($(call bin_path, $(CC)),)
$(error Unable to find osxcross $(CC)) $(error Unable to find osxcross $(CC))
@ -532,6 +533,10 @@ ifeq ($(PLATFORM),darwin)
endif endif
endif endif
ifndef LIPO
LIPO=lipo
endif
BASE_CFLAGS += -fno-strict-aliasing -fno-common -pipe BASE_CFLAGS += -fno-strict-aliasing -fno-common -pipe
ifeq ($(USE_OPENAL),1) ifeq ($(USE_OPENAL),1)
@ -2275,7 +2280,11 @@ endif
ifneq ($(strip $(LIBSDLMAIN)),) ifneq ($(strip $(LIBSDLMAIN)),)
ifneq ($(strip $(LIBSDLMAINSRC)),) ifneq ($(strip $(LIBSDLMAINSRC)),)
$(LIBSDLMAIN) : $(LIBSDLMAINSRC) $(LIBSDLMAIN) : $(LIBSDLMAINSRC)
ifeq ($(PLATFORM),darwin)
$(LIPO) -extract $(MACOSX_ARCH) $< -o $@
else
cp $< $@ cp $< $@
endif
$(RANLIB) $@ $(RANLIB) $@
endif endif
endif endif