summaryrefslogtreecommitdiffstats
path: root/share/mk
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2010-02-03 21:29:06 +0000
committerimp <imp@FreeBSD.org>2010-02-03 21:29:06 +0000
commitde1c0e3861ebfc261230fdfbdd6314a40203f185 (patch)
treef8862b6f83ffc50e16f16cd536c523effb558582 /share/mk
parentccc086d6ffcb0e32a24935bb3571f200d26ac6c9 (diff)
downloadFreeBSD-src-de1c0e3861ebfc261230fdfbdd6314a40203f185.zip
FreeBSD-src-de1c0e3861ebfc261230fdfbdd6314a40203f185.tar.gz
Introduce MACHINE_CPUARCH.
MACHINE is the specific kernel architecture for this machine. MACHINE_ARCH is the specific CPU type (abi, word size, etc). MACHINE_CPUARCH is the family of CPUs that's supported. Most of the tree conflates MACHINE_ARCH and MACHINE_CPUARCH since historically they have been identical. However, there's now a reason to to split the two concepts. NetBSD calls this MACHINE_CPU, but that's already used for something else in FreeBSD, so MACHINE_CPUARCH was selected instead. However, the sources in the tree have had a KLUDGE in the tree called TARGET_BIG_ENDIAN to select which endian to compile the code for. However, this is a cumbersome and awkward solution. MACHINE_ARCH really does need to be different for different endian because users use it for things like their path. Yet, the source tree also used MACHINE_ARCH to figure out the MD code to use. This source often supports multiple MACHINE_ARCHs. 'mips' supports 32 (and soon 64) bit word sizes as well as big and little endian. 'arm' support both endians. powerpc will soon support both 32-bit and 64-bit. These patches start to unwind this confusion. It implements MACHINE_ARCH of mipsel, mipseb for the two endians of MIPS, as well as arm and armeb for ARM. The names for ARM are historical accidents (ARM was primarily little endian until relatively recently). These names follow the NetBSD convetions. With these changes, "make buildworld TARGET=mips TARGET_ARCH=mipsel" finishes. armeb and mipseb should work, but haven't been tested yet. Committed as one big chunk so that people can comment on the patches as a whole and suggest improvements.
Diffstat (limited to 'share/mk')
-rw-r--r--share/mk/bsd.cpu.mk67
-rw-r--r--share/mk/bsd.endian.mk8
-rw-r--r--share/mk/bsd.lib.mk2
-rw-r--r--share/mk/bsd.sys.mk4
-rw-r--r--share/mk/sys.mk14
5 files changed, 54 insertions, 41 deletions
diff --git a/share/mk/bsd.cpu.mk b/share/mk/bsd.cpu.mk
index 8278d47..06b7af1 100644
--- a/share/mk/bsd.cpu.mk
+++ b/share/mk/bsd.cpu.mk
@@ -6,18 +6,18 @@
.if !defined(CPUTYPE) || empty(CPUTYPE)
_CPUCFLAGS =
-. if ${MACHINE_ARCH} == "i386"
+. if ${MACHINE_CPUARCH} == "i386"
MACHINE_CPU = i486
-. elif ${MACHINE_ARCH} == "amd64"
+. elif ${MACHINE_CPUARCH} == "amd64"
MACHINE_CPU = amd64 sse2 sse
-. elif ${MACHINE_ARCH} == "ia64"
+. elif ${MACHINE_CPUARCH} == "ia64"
MACHINE_CPU = itanium
-. elif ${MACHINE_ARCH} == "powerpc"
+. elif ${MACHINE_CPUARCH} == "powerpc"
MACHINE_CPU = aim
-. elif ${MACHINE_ARCH} == "sparc64"
-. elif ${MACHINE_ARCH} == "arm"
+. elif ${MACHINE_CPUARCH} == "sparc64"
+. elif ${MACHINE_CPUARCH} == "arm"
MACHINE_CPU = arm
-. elif ${MACHINE_ARCH} == "mips"
+. elif ${MACHINE_CPUARCH} == "mips"
MACHINE_CPU = mips
. endif
.else
@@ -25,7 +25,7 @@ MACHINE_CPU = mips
# Handle aliases (not documented in make.conf to avoid user confusion
# between e.g. i586 and pentium)
-. if ${MACHINE_ARCH} == "i386"
+. if ${MACHINE_CPUARCH} == "i386"
. if ${CPUTYPE} == "nocona"
CPUTYPE = prescott
. elif ${CPUTYPE} == "core" || ${CPUTYPE} == "core2"
@@ -54,7 +54,7 @@ CPUTYPE = athlon-mp
. elif ${CPUTYPE} == "k7"
CPUTYPE = athlon
. endif
-. elif ${MACHINE_ARCH} == "amd64"
+. elif ${MACHINE_CPUARCH} == "amd64"
. if ${CPUTYPE} == "prescott" || ${CPUTYPE} == "core2"
CPUTYPE = nocona
. endif
@@ -71,7 +71,7 @@ CPUTYPE = nocona
# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html
# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html
-. if ${MACHINE_ARCH} == "i386"
+. if ${MACHINE_CPUARCH} == "i386"
. if ${CPUTYPE} == "crusoe"
_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0
. elif ${CPUTYPE} == "k5"
@@ -104,9 +104,9 @@ _ICC_CPUCFLAGS = -tpp5
. else
_ICC_CPUCFLAGS =
. endif # ICC on 'i386'
-. elif ${MACHINE_ARCH} == "amd64"
+. elif ${MACHINE_CPUARCH} == "amd64"
_CPUCFLAGS = -march=${CPUTYPE}
-. elif ${MACHINE_ARCH} == "arm"
+. elif ${MACHINE_CPUARCH} == "arm"
. if ${CPUTYPE} == "xscale"
#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself
#_CPUCFLAGS = -mcpu=xscale
@@ -114,14 +114,14 @@ _CPUCFLAGS = -march=armv5te -D__XSCALE__
. else
_CPUCFLAGS = -mcpu=${CPUTYPE}
. endif
-. elif ${MACHINE_ARCH} == "powerpc"
+. elif ${MACHINE_CPUARCH} == "powerpc"
. if ${CPUTYPE} == "e500"
MACHINE_CPU = booke
_CPUCFLAGS = -Wa,-me500 -msoft-float
. else
_CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64
. endif
-. elif ${MACHINE_ARCH} == "mips"
+. elif ${MACHINE_CPUARCH} == "mips"
. if ${CPUTYPE} == "mips32"
_CPUCFLAGS = -march=mips32
. elif ${CPUTYPE} == "mips32r2"
@@ -141,7 +141,7 @@ _CPUCFLAGS = -march=24kc
# unordered list to make it easy for client makefiles to test for the
# presence of a CPU feature.
-. if ${MACHINE_ARCH} == "i386"
+. if ${MACHINE_CPUARCH} == "i386"
. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64"
MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386
. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
@@ -180,37 +180,38 @@ MACHINE_CPU = i486 i386
. elif ${CPUTYPE} == "i386"
MACHINE_CPU = i386
. endif
-. elif ${MACHINE_ARCH} == "amd64"
+. elif ${MACHINE_CPUARCH} == "amd64"
. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8"
MACHINE_CPU = k8 3dnow
. elif ${CPUTYPE} == "nocona"
MACHINE_CPU = sse3
. endif
MACHINE_CPU += amd64 sse2 sse mmx
-. elif ${MACHINE_ARCH} == "ia64"
+. elif ${MACHINE_CPUARCH} == "ia64"
. if ${CPUTYPE} == "itanium"
MACHINE_CPU = itanium
. endif
. endif
.endif
-.if ${MACHINE_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
-CFLAGS += -mbig-endian
-LDFLAGS += -mbig-endian
-LD += -EB
-.endif
+##XXXimp: These are bogus
+#.if ${MACHINE_CPUARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
+#CFLAGS += -mbig-endian
+#LDFLAGS += -mbig-endian
+#LD += -EB
+#.endif
-.if ${MACHINE_ARCH} == "mips"
-. if defined(TARGET_BIG_ENDIAN)
-CFLAGS += -EB
-LDFLAGS += -Wl,-EB
-LD += -EB
-. else
-CFLAGS += -EL
-LDFLAGS += -Wl,-EL
-LD += -EL
-. endif
-CFLAGS += -msoft-float -G0 -mno-dsp -mabicalls
+.if ${MACHINE_CPUARCH} == "mips"
+#. if defined(TARGET_BIG_ENDIAN)
+#CFLAGS += -EB
+#LDFLAGS += -Wl,-EB
+#LD += -EB
+#. else
+#CFLAGS += -EL
+#LDFLAGS += -Wl,-EL
+#LD += -EL
+#. endif
+CFLAGS += -msoft-float -G0 -mabicalls
.endif
# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
diff --git a/share/mk/bsd.endian.mk b/share/mk/bsd.endian.mk
index c2b141f..158554b 100644
--- a/share/mk/bsd.endian.mk
+++ b/share/mk/bsd.endian.mk
@@ -3,12 +3,12 @@
.if ${MACHINE_ARCH} == "amd64" || \
${MACHINE_ARCH} == "i386" || \
${MACHINE_ARCH} == "ia64" || \
- (${MACHINE_ARCH} == "arm" && !defined(TARGET_BIG_ENDIAN)) || \
- (${MACHINE_ARCH} == "mips" && !defined(TARGET_BIG_ENDIAN))
+ ${MACHINE_ARCH} == "arm" || \
+ ${MACHINE_ARCH} == "mipsel"
TARGET_ENDIANNESS= 1234
.elif ${MACHINE_ARCH} == "powerpc" || \
${MACHINE_ARCH} == "sparc64" || \
- ${MACHINE_ARCH} == "arm" || \
- ${MACHINE_ARCH} == "mips"
+ ${MACHINE_ARCH} == "armeb" || \
+ ${MACHINE_ARCH} == "mipseb"
TARGET_ENDIANNESS= 4321
.endif
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index 470d9d4..54de4e9 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -53,7 +53,7 @@ STRIP?= -s
.SUFFIXES: .out .o .po .So .S .asm .s .c .cc .cpp .cxx .m .C .f .y .l .ln
.if !defined(PICFLAG)
-.if ${MACHINE_ARCH} == "sparc64"
+.if ${MACHINE_CPUARCH} == "sparc64"
PICFLAG=-fPIC
.else
PICFLAG=-fpic
diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
index afce044..4d8b76b 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -76,8 +76,8 @@ CWARNFLAGS += -Werror
CWARNFLAGS += -Wno-unknown-pragmas
.endif
-.if ${MK_SSP} != "no" && ${CC} != "icc" && ${MACHINE_ARCH} != "ia64" && \
- ${MACHINE_ARCH} != "arm" && ${MACHINE_ARCH} != "mips"
+.if ${MK_SSP} != "no" && ${CC} != "icc" && ${MACHINE_CPUARCH} != "ia64" && \
+ ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
# Don't use -Wstack-protector as it breaks world with -Werror.
SSP_CFLAGS ?= -fstack-protector
CFLAGS += ${SSP_CFLAGS}
diff --git a/share/mk/sys.mk b/share/mk/sys.mk
index e0527e4..042c7b9 100644
--- a/share/mk/sys.mk
+++ b/share/mk/sys.mk
@@ -4,6 +4,18 @@
unix ?= We run FreeBSD, not UNIX.
.FreeBSD ?= true
+.if !defined(%POSIX)
+#
+# MACHINE_CPUARCH defines a collection of MACHINE_ARCH. Machines with
+# the same MACHINE_ARCH can run reach-other's binaries, so it
+# necessarily has word size and endian swizzled in. However, support
+# files for these machines often are shared amongst all combinations
+# of size and/or endian. This is called MACHINE_CPU in NetBSD, but
+# that's used for something different in FreeBSD.
+#
+MACHINE_CPUARCH=${MACHINE_ARCH:C/mipse[lb]/mips/:C/armeb/arm/}
+.endif
+
# If the special target .POSIX appears (without prerequisites or
# commands) before the first noncomment line in the makefile, make shall
# process the makefile as specified by the Posix 1003.2 specification.
@@ -35,7 +47,7 @@ CC ?= c89
CFLAGS ?= -O
.else
CC ?= cc
-.if ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "mips"
+.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips"
CFLAGS ?= -O -pipe
.else
CFLAGS ?= -O2 -pipe
OpenPOWER on IntegriCloud