Fix error when cross-compiling for macOS arm64 using Makefile

Fix "Architecture arm64 is not supported when cross compiling" and
also be more be more flexible for manually specifying CC or the
osxcross darwin version (which corresponds with a macOS SDK version
to build against).
This commit is contained in:
Zack Middleton 2021-11-06 23:37:36 -04:00
parent 7dd90123b7
commit 68ac81316d

View file

@ -467,6 +467,11 @@ ifeq ($(PLATFORM),darwin)
BASE_CFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN) \ BASE_CFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN) \
-DMAC_OS_X_VERSION_MIN_REQUIRED=$(MAC_OS_X_VERSION_MIN_REQUIRED) -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) ifeq ($(ARCH),ppc)
BASE_CFLAGS += -arch ppc BASE_CFLAGS += -arch ppc
ALTIVEC_CFLAGS = -faltivec ALTIVEC_CFLAGS = -faltivec
@ -498,15 +503,31 @@ ifeq ($(PLATFORM),darwin)
endif endif
ifeq ($(CROSS_COMPILING),1) ifeq ($(CROSS_COMPILING),1)
ifeq ($(ARCH),x86_64) # If CC is already set to something generic, we probably want to use
CC=x86_64-apple-darwin13-cc # something more specific
RANLIB=x86_64-apple-darwin13-ranlib ifneq ($(findstring $(strip $(CC)),cc gcc),)
else CC=
ifeq ($(ARCH),x86) endif
CC=i386-apple-darwin13-cc
RANLIB=i386-apple-darwin13-ranlib ifndef CC
else ifndef DARWIN
$(error Architecture $(ARCH) is not supported when cross compiling) # 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
ifeq ($(call bin_path, $(CC)),)
$(error Unable to find osxcross $(CC))
endif endif
endif endif
endif endif