Detect target platform consistently with $(CC) -dumpmachine
We already used this for Windows, now use it for all platforms to simplify cross compilation in general.
This commit is contained in:
parent
1137cca2fa
commit
1dc4219bcb
1 changed files with 27 additions and 38 deletions
|
|
@ -430,38 +430,33 @@ endif
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
### platform detection #########################################################
|
### target platform detection ##################################################
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
# Let (native or cross-) compiler report target triplet and isolate individual
|
||||||
|
# words therein to facilitate later processing.
|
||||||
|
target.triplet := $(subst -, ,$(shell $(CC) -dumpmachine))
|
||||||
|
|
||||||
|
|
||||||
#=== operating system ==========================================================
|
#=== operating system ==========================================================
|
||||||
|
|
||||||
|
|
||||||
# The following systems are defined: Linux, Darwin, Windows. GNU and
|
# The following systems are defined: Linux, Darwin, Windows. GNU and
|
||||||
# GNU/kFreeBSD are treated as Linux to get the same options.
|
# GNU/kFreeBSD are treated as Linux to get the same options.
|
||||||
|
|
||||||
uname := $(shell uname)
|
ifneq ($(filter linux gnu% kfreebsd, $(target.triplet)),)
|
||||||
|
|
||||||
ifeq ($(findstring $(uname), Linux GNU GNU/kFreeBSD), $(uname))
|
|
||||||
system = Linux
|
system = Linux
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(uname), Darwin)
|
ifneq ($(filter darwin%, $(target.triplet)),)
|
||||||
system = Darwin
|
system = Darwin
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(filter MINGW% MSYS%, $(uname)), $(uname))
|
ifneq ($(filter mingw% cygwin%, $(target.triplet)),)
|
||||||
system = Windows
|
system = Windows
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Unfortunately not all Mingw versions provide a link cc > gcc, therefore
|
|
||||||
# gcc is hardcoded here (but not if CC is redefined).
|
|
||||||
ifeq ($(system), Windows)
|
|
||||||
ifeq ($(origin CC), default)
|
|
||||||
CC = gcc
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# evaluate possible system-specific multiline defines from library makefile
|
# evaluate possible system-specific multiline defines from library makefile
|
||||||
$(eval $(for$(system)))
|
$(eval $(for$(system)))
|
||||||
|
|
||||||
|
|
@ -472,24 +467,13 @@ $(eval $(for$(system)))
|
||||||
#=== architecture ==============================================================
|
#=== architecture ==============================================================
|
||||||
|
|
||||||
|
|
||||||
# native architecture of the build machine
|
# The following CPU names can be processed by pdlibbuilder:
|
||||||
build.arch := $(shell uname -m)
|
# i*86 Intel 32 bit
|
||||||
|
# x86_64 Intel 64 bit
|
||||||
|
# arm ARM 32 bit
|
||||||
|
# aarch64 ARM 64 bit
|
||||||
|
|
||||||
# Target architecture as reported by compiler. Give precedence to eventual
|
target.arch := $(firstword $(target.triplet))
|
||||||
# user-defined compiler. The first field of <cpu>-<vendor>-<os> is extracted.
|
|
||||||
ifneq ($(origin CXX), default)
|
|
||||||
dumpmachine.cpu = $(firstword $(subst -, ,$(shell $(CXX) -dumpmachine)))
|
|
||||||
else
|
|
||||||
dumpmachine.cpu = $(firstword $(subst -, ,$(shell $(CC) -dumpmachine)))
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Target architecture as reported by compiler is only used for Windows at the
|
|
||||||
# moment. For other systems this still has to be tested.
|
|
||||||
ifeq ($(system), Windows)
|
|
||||||
target.arch = $(dumpmachine.cpu)
|
|
||||||
else
|
|
||||||
target.arch = $(build.arch)
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
@ -501,22 +485,27 @@ endif
|
||||||
|
|
||||||
|
|
||||||
# Set architecture-dependent cflags, mainly for Linux. For Mac and Windows,
|
# Set architecture-dependent cflags, mainly for Linux. For Mac and Windows,
|
||||||
# arch.c.flags are overriden below.
|
# arch.c.flags are overriden below. To see gcc's default architecture flags:
|
||||||
|
# $ gcc -Q --help=target
|
||||||
|
|
||||||
# Raspberry Pi 1st generation
|
# ARMv6: Raspberry Pi 1st gen, not detectable from target.arch
|
||||||
ifeq ($(target.arch), armv6l)
|
ifeq ($(shell uname), armv6l)
|
||||||
arch.c.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard
|
arch.c.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard
|
||||||
|
|
||||||
# Beagle, Udoo, RPi2 etc.
|
# ARMv7: Beagle, Udoo, RPi2 etc.
|
||||||
else ifeq ($(target.arch), armv7l)
|
else ifeq ($(target.arch), arm)
|
||||||
arch.c.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard
|
arch.c.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard
|
||||||
|
|
||||||
|
# ARMv8 64 bit, not tested yet
|
||||||
|
else ifeq ($(target.arch), aarch64)
|
||||||
|
arch.c.flags = -mcpu=cortex-a53
|
||||||
|
|
||||||
# Intel 32 bit, build with SSE and SSE2 instructions
|
# Intel 32 bit, build with SSE and SSE2 instructions
|
||||||
else ifeq ($(findstring $(target.arch), i386 i686), $(target.arch))
|
else ifneq ($(filter i%86, $(target.arch)),)
|
||||||
arch.c.flags = -march=pentium4 -mfpmath=sse -msse -msse2
|
arch.c.flags = -march=pentium4 -mfpmath=sse -msse -msse2
|
||||||
|
|
||||||
# Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions
|
# Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions
|
||||||
else ifeq ($(findstring $(target.arch), x86_64), $(target.arch))
|
else ifeq ($(target.arch), x86_64)
|
||||||
arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3
|
arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3
|
||||||
|
|
||||||
# if none of the above architectures detected
|
# if none of the above architectures detected
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue