Forcing proper native arch build on darwin mainly due to arm64.

This commit is contained in:
David CARLIER 2022-05-14 16:16:14 +01:00
parent 9757d6fffc
commit 8e5d49e8f4

View file

@ -44,8 +44,12 @@ YQ2_ARCH ?= $(PROCESSOR_ARCHITECTURE)
endif endif
endif # windows but MINGW_CHOST not defined endif # windows but MINGW_CHOST not defined
else else
ifneq ($(YQ2_OSTYPE), Darwin)
# Normalize some abiguous YQ2_ARCH strings # Normalize some abiguous YQ2_ARCH strings
YQ2_ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/') YQ2_ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/')
else
YQ2_ARCH ?= $(shell uname -m)
endif
endif endif
# Detect the compiler # Detect the compiler
@ -81,7 +85,7 @@ endif
# -MMD to generate header dependencies. # -MMD to generate header dependencies.
ifeq ($(YQ2_OSTYPE), Darwin) ifeq ($(YQ2_OSTYPE), Darwin)
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \ CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
-Wall -pipe -g -fwrapv -arch i386 -arch x86_64 -Wall -pipe -g -fwrapv -arch $(YQ2_ARCH)
else else
CFLAGS := -O0 -fno-strict-aliasing -fomit-frame-pointer \ CFLAGS := -O0 -fno-strict-aliasing -fomit-frame-pointer \
-Wall -pipe -ggdb -MMD -fwrapv -Wall -pipe -ggdb -MMD -fwrapv
@ -122,7 +126,7 @@ CFLAGS += -DYQ2OSTYPE=\"$(YQ2_OSTYPE)\" -DYQ2ARCH=\"$(YQ2_ARCH)\"
# Base LDFLAGS. # Base LDFLAGS.
ifeq ($(YQ2_OSTYPE), Darwin) ifeq ($(YQ2_OSTYPE), Darwin)
LDFLAGS := -shared -arch i386 -arch x86_64 LDFLAGS := -shared -arch $(YQ2_ARCH)
else else
LDFLAGS := -shared LDFLAGS := -shared
endif endif
@ -164,6 +168,16 @@ zaero:
${Q}mkdir -p release ${Q}mkdir -p release
${MAKE} release/game.dll ${MAKE} release/game.dll
build/%.o: %.c
@echo "===> CC $<"
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) -o $@ $<
else ifeq ($(YQ2_OSTYPE), Darwin)
zaero:
@echo "===> Building game.dylib"
${Q}mkdir -p release
$(MAKE) release/game.dylib
build/%.o: %.c build/%.o: %.c
@echo "===> CC $<" @echo "===> CC $<"
${Q}mkdir -p $(@D) ${Q}mkdir -p $(@D)
@ -268,6 +282,10 @@ ifeq ($(YQ2_OSTYPE), Windows)
release/game.dll : $(ZAERO_OBJS) release/game.dll : $(ZAERO_OBJS)
@echo "===> LD $@" @echo "===> LD $@"
${Q}$(CC) $(LDFLAGS) -o $@ $(ZAERO_OBJS) ${Q}$(CC) $(LDFLAGS) -o $@ $(ZAERO_OBJS)
else ifeq ($(YQ2_OSTYPE), Darwin)
release/game.dylib : $(ZAERO_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(LDFLAGS) -o $@ $(ZAERO_OBJS)
else else
release/game.so : $(ZAERO_OBJS) release/game.so : $(ZAERO_OBJS)
@echo "===> LD $@" @echo "===> LD $@"