mirror of
https://github.com/yquake2/3zb2.git
synced 2024-11-21 19:40:59 +00:00
Fix architecture detection on Windows in Makefile
$PROCESSOR_ARCHITECTURE seems to contain the architecture of the host, but we need the architecture the current MinGW shell is targeting. $MINGW_CHOST seems to be just that, and on my system it's either i686-w64-mingw32 (mingw32.exe) or x86_64-w64-mingw32 (mingw64.exe) (No idea what it looks like for Windows on ARM...) Also enforce usage of SSE math on i386 and rename OSTYPE to YQ2_OSTYPE and ARCH to YQ2_ARCH in the Makefile for a little more consistence with the other Makefiles.
This commit is contained in:
parent
cc28c64fb7
commit
d84ffdee15
1 changed files with 35 additions and 17 deletions
52
Makefile
52
Makefile
|
@ -19,28 +19,36 @@
|
||||||
|
|
||||||
# Detect the OS
|
# Detect the OS
|
||||||
ifdef SystemRoot
|
ifdef SystemRoot
|
||||||
OSTYPE := Windows
|
YQ2_OSTYPE := Windows
|
||||||
else
|
else
|
||||||
OSTYPE := $(shell uname -s)
|
YQ2_OSTYPE := $(shell uname -s)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Special case for MinGW
|
# Special case for MinGW
|
||||||
ifneq (,$(findstring MINGW,$(OSTYPE)))
|
ifneq (,$(findstring MINGW,$(YQ2_OSTYPE)))
|
||||||
OSTYPE := Windows
|
YQ2_OSTYPE := Windows
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Detect the architecture
|
# Detect the architecture
|
||||||
ifeq ($(OSTYPE), Windows)
|
ifeq ($(YQ2_OSTYPE), Windows)
|
||||||
|
ifdef MINGW_CHOST
|
||||||
|
ifeq ($(MINGW_CHOST), x86_64-w64-mingw32)
|
||||||
|
YQ2_ARCH ?= x86_64
|
||||||
|
else # i686-w64-mingw32
|
||||||
|
YQ2_ARCH ?= i386
|
||||||
|
endif
|
||||||
|
else # windows, but MINGW_CHOST not defined
|
||||||
ifdef PROCESSOR_ARCHITEW6432
|
ifdef PROCESSOR_ARCHITEW6432
|
||||||
# 64 bit Windows
|
# 64 bit Windows
|
||||||
ARCH := $(PROCESSOR_ARCHITEW6432)
|
YQ2_ARCH ?= $(PROCESSOR_ARCHITEW6432)
|
||||||
else
|
else
|
||||||
# 32 bit Windows
|
# 32 bit Windows
|
||||||
ARCH := $(PROCESSOR_ARCHITECTURE)
|
YQ2_ARCH ?= $(PROCESSOR_ARCHITECTURE)
|
||||||
endif
|
endif
|
||||||
|
endif # windows but MINGW_CHOST not defined
|
||||||
else
|
else
|
||||||
# Normalize some abiguous ARCH strings
|
# Normalize some abiguous YQ2_ARCH strings
|
||||||
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/')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Detect the compiler
|
# Detect the compiler
|
||||||
|
@ -74,7 +82,7 @@ endif
|
||||||
# -fPIC for position independend code.
|
# -fPIC for position independend code.
|
||||||
#
|
#
|
||||||
# -MMD to generate header dependencies.
|
# -MMD to generate header dependencies.
|
||||||
ifeq ($(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 i386 -arch x86_64
|
||||||
else
|
else
|
||||||
|
@ -100,15 +108,25 @@ endif
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
|
# Using the default x87 float math on 32bit x86 causes rounding trouble
|
||||||
|
# -ffloat-store could work around that, but the better solution is to
|
||||||
|
# just enforce SSE - every x86 CPU since Pentium3 supports that
|
||||||
|
# and this should even improve the performance on old CPUs
|
||||||
|
ifeq ($(YQ2_ARCH), i386)
|
||||||
|
override CFLAGS += -msse -mfpmath=sse
|
||||||
|
endif
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
|
||||||
# Defines the operating system and architecture
|
# Defines the operating system and architecture
|
||||||
CFLAGS += -DOSTYPE=\"$(OSTYPE)\" -DARCH=\"$(ARCH)\"
|
CFLAGS += -DOSTYPE=\"$(YQ2_OSTYPE)\" -DARCH=\"$(YQ2_ARCH)\"
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
# Base LDFLAGS.
|
# Base LDFLAGS.
|
||||||
ifeq ($(OSTYPE), Darwin)
|
ifeq ($(YQ2_OSTYPE), Darwin)
|
||||||
LDFLAGS := -shared -arch i386 -arch x86_64
|
LDFLAGS := -shared -arch i386 -arch x86_64
|
||||||
else ifeq ($(OSTYPE), Windows)
|
else ifeq ($(YQ2_OSTYPE), Windows)
|
||||||
LDFLAGS := -shared -static-libgcc
|
LDFLAGS := -shared -static-libgcc
|
||||||
else
|
else
|
||||||
LDFLAGS := -shared -lm
|
LDFLAGS := -shared -lm
|
||||||
|
@ -145,12 +163,12 @@ clean:
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
# The 3zb2 game
|
# The 3zb2 game
|
||||||
ifeq ($(OSTYPE), Windows)
|
ifeq ($(YQ2_OSTYPE), Windows)
|
||||||
3zb2:
|
3zb2:
|
||||||
@echo "===> Building game.dll"
|
@echo "===> Building game.dll"
|
||||||
${Q}mkdir -p release
|
${Q}mkdir -p release
|
||||||
$(MAKE) release/game.dll
|
$(MAKE) release/game.dll
|
||||||
else ifeq ($(OSTYPE), Darwin)
|
else ifeq ($(YQ2_OSTYPE), Darwin)
|
||||||
3zb2:
|
3zb2:
|
||||||
@echo "===> Building game.dylib"
|
@echo "===> Building game.dylib"
|
||||||
${Q}mkdir -p release
|
${Q}mkdir -p release
|
||||||
|
@ -219,11 +237,11 @@ build/%.o: %.c
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
ifeq ($(OSTYPE), Windows)
|
ifeq ($(YQ2_OSTYPE), Windows)
|
||||||
release/game.dll : $(3ZB2_OBJS)
|
release/game.dll : $(3ZB2_OBJS)
|
||||||
@echo "===> LD $@"
|
@echo "===> LD $@"
|
||||||
${Q}$(CC) $(LDFLAGS) -o $@ $(3ZB2_OBJS)
|
${Q}$(CC) $(LDFLAGS) -o $@ $(3ZB2_OBJS)
|
||||||
else ifeq ($(OSTYPE), Darwin)
|
else ifeq ($(YQ2_OSTYPE), Darwin)
|
||||||
release/game.dylib : $(3ZB2_OBJS)
|
release/game.dylib : $(3ZB2_OBJS)
|
||||||
@echo "===> LD $@"
|
@echo "===> LD $@"
|
||||||
${Q}$(CC) $(LDFLAGS) -o $@ $(3ZB2_OBJS)
|
${Q}$(CC) $(LDFLAGS) -o $@ $(3ZB2_OBJS)
|
||||||
|
|
Loading…
Reference in a new issue