diff --git a/Makefile b/Makefile index 8d15526c2..f54ebe8d2 100644 --- a/Makefile +++ b/Makefile @@ -317,6 +317,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 @@ -348,15 +353,31 @@ 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 + + ifeq ($(call bin_path, $(CC)),) + $(error Unable to find osxcross $(CC)) endif endif endif