summaryrefslogtreecommitdiffstats
path: root/share/mk
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2001-02-22 11:14:25 +0000
committerkris <kris@FreeBSD.org>2001-02-22 11:14:25 +0000
commita1e08c4bceeab3ea235300b57bfc9903dbc17a35 (patch)
tree0c56e7e5da1b140c14062e886f90ee32ade8e5cb /share/mk
parent31ead84953f4dc2496c35a6fea77bd19d6ee62f8 (diff)
downloadFreeBSD-src-a1e08c4bceeab3ea235300b57bfc9903dbc17a35.zip
FreeBSD-src-a1e08c4bceeab3ea235300b57bfc9903dbc17a35.tar.gz
Overhaul the MACHINE_CPU behaviour:
* Rip out MACHINE_CPU stuff from sys.mk and include a new <bsd.cpu.mk> after we pull in /etc/make.conf. We need to do it afterwards so we can react to the user setting of the: * CPUTYPE variable, which contains the CPU type which the user wants to optimize for. For example, if you want your binaries to only run on an i686-class machine (or higher), set this to i686. If you want to support running binaries on a variety of CPU generations, set this to the lowest common denominator. Supported values are listed in make.conf. * bsd.cpu.mk does the expansion of CPUTYPE into MACHINE_CPU using the (hopefully) correct unordered list of CPU types which should be used on that CPU. For example, an AMD k6 CPU wants any of the following: k6 k5 i586 i486 i386 This is still an unordered list so the client makefile logic is simple - client makefiles need to test for the various elements of the set in decreasing order of priority using ${MACHINE_CPU:M<foo>}, as before. The various MACHINE_CPU lists are believed to be correct, but should be checked. * If NO_CPU_CFLAGS is not defined, add relevant gcc compiler optimization settings by default (e.g. -karch=k6 for CPUTYPE=k6, etc). Release builders and developers of third-party software need to make sure not to enable CPU-specific optimization when generating code intended to be portable. We probably need to move to an /etc/world.conf to allow the optimization stuff to be applied separately to world/kernel and external compilations, but it's not any worse a problem than it was before. * Add coverage for the ia64/itanium MACHINE_ARCH/CPUTYPE. * Add CPUTYPE support for all of the CPU types supported by FreeBSD and gcc (only i386, alpha and ia64 first, since those are the minimally-working ports. Other architecture porters, please feel free to add the relevant gunk for your platform). Reviewed by: jhb, obrien
Diffstat (limited to 'share/mk')
-rw-r--r--share/mk/bsd.cpu.mk101
-rw-r--r--share/mk/sys.mk12
2 files changed, 103 insertions, 10 deletions
diff --git a/share/mk/bsd.cpu.mk b/share/mk/bsd.cpu.mk
new file mode 100644
index 0000000..bbf3080
--- /dev/null
+++ b/share/mk/bsd.cpu.mk
@@ -0,0 +1,101 @@
+# $FreeBSD$
+
+# Set default baseline values of CPUTYPE based on MACHINE_ARCH -- this is
+# the minimum CPU type we support for each architecture
+
+.if ${MACHINE_ARCH} == "i386"
+CPUTYPE ?= i386
+.elif ${MACHINE_ARCH} == "alpha"
+CPUTYPE ?= ev4
+.elif ${MACHINE_ARCH} == "ia64"
+CPUTYPE ?= itanium
+.endif
+
+# Handle aliases (not documented in make.conf to avoid user confusion
+# between e.g. i586 and pentium)
+
+.if ${MACHINE_ARCH} == "i386"
+. if ${CPUTYPE} == "pentiumpro"
+CPUTYPE = i686
+. elif ${CPUTYPE} == "pentium"
+CPUTYPE = i586
+. elif ${CPUTYPE} == "athlon"
+CPUTYPE = k7
+. endif
+.endif
+
+# Logic to set up correct gcc optimization flag. This must be included
+# after /etc/make.conf so it can react to the local value of CPUTYPE
+# defined therein.
+
+.if !defined(NO_CPU_CFLAGS)
+. if ${MACHINE_ARCH} == "i386"
+. if ${CPUTYPE} == "k7"
+CFLAGS += -march=k6 # gcc doesn't support athlon yet, but it will
+. elif ${CPUTYPE} == "k6"
+CFLAGS += -march=k6
+. elif ${CPUTYPE} == "k5"
+CFLAGS += -march=pentium
+. elif ${CPUTYPE} == "i686"
+CFLAGS += -march=pentiumpro
+. elif ${CPUTYPE} == "i586"
+CFLAGS += -march=pentium
+. elif ${CPUTYPE} == "i486"
+CFLAGS += -m486
+. endif
+. elif ${MACHINE_ARCH} == "alpha"
+. if ${CPUTYPE} == "ev6"
+CFLAGS += -mcpu=ev6
+. elif ${CPUTYPE} == "pca56"
+CFLAGS += -mcpu=pca56
+. elif ${CPUTYPE} == "ev56"
+CFLAGS += -mcpu=ev56
+. elif ${CPUTYPE} == "ev5"
+CFLAGS += -mcpu=ev5
+. elif ${CPUTYPE} == "ev45"
+CFLAGS += -mcpu=ev4 # No -mcpu=ev45 for gcc
+. elif ${CPUTYPE} == "ev4"
+CFLAGS += -mcpu=ev4
+. endif
+. endif
+.endif
+
+# Set up the list of CPU features based on the CPU type. This is an
+# unordered list to make it easy for client makefiles to test for the
+# presence of a CPU feature.
+
+.if ${MACHINE_ARCH} == "i386"
+. if ${CPUTYPE} == "k7"
+MACHINE_CPU = k7 k6 k5 i586 i486 i386
+. elif ${CPUTYPE} == "k6"
+MACHINE_CPU = k6 k5 i586 i486 i386
+. elif ${CPUTYPE} == "k5"
+MACHINE_CPU = k5 i586 i486 i386
+. elif ${CPUTYPE} == "i686"
+MACHINE_CPU = i686 i586 i486 i386
+. elif ${CPUTYPE} == "i586"
+MACHINE_CPU = i586 i486 i386
+. elif ${CPUTYPE} == "i486"
+MACHINE_CPU = i486 i386
+. elif ${CPUTYPE} == "i386"
+MACHINE_CPU = i386
+. endif
+.elif ${MACHINE_ARCH} == "alpha"
+. if ${CPUTYPE} == "ev6"
+MACHINE_CPU = ev6 ev56 pca56 ev5 ev45 ev4
+. elif ${CPUTYPE} == "pca56"
+MACHINE_CPU = pca56 ev56 ev5 ev45 ev4
+. elif ${CPUTYPE} == "ev56"
+MACHINE_CPU = ev56 ev5 ev45 ev4
+. elif ${CPUTYPE} == "ev5"
+MACHINE_CPU = ev5 ev45 ev4
+. elif ${CPUTYPE} == "ev45"
+MACHINE_CPU = ev45 ev4
+. elif ${CPUTYPE} == "ev4"
+MACHINE_CPU = ev4
+. endif
+.elif ${MACHINE_ARCH} == "ia64"
+. if ${CPUTYPE} == "itanium"
+MACHINE_CPU = itanium
+. endif
+.endif
diff --git a/share/mk/sys.mk b/share/mk/sys.mk
index 8ce6a8c..4fac78f 100644
--- a/share/mk/sys.mk
+++ b/share/mk/sys.mk
@@ -104,16 +104,6 @@ YFLAGS ?= -d
# as an i386 architecture.
MACHINE_ARCH ?= i386
-# MACHINE_CPU contains a list of CPU generations for which
-# CPU-specific optimizations are desired. This must be set here
-# to allow bootstrapping from old versions of make which do not
-# set MACHINE_CPU.
-.if ${MACHINE_ARCH} == "i386"
-MACHINE_CPU ?= i386
-.elif ${MACHINE_ARCH} == "alpha"
-MACHINE_CPU ?= ev4
-.endif
-
# For tags rule.
GTAGSFLAGS= -o
HTAGSFLAGS=
@@ -254,6 +244,8 @@ HTAGSFLAGS=
.include </etc/make.conf>
.endif
+.include <bsd.cpu.mk>
+
.if exists(/etc/make.conf.local)
.error Error, original /etc/make.conf should be moved to the /etc/defaults/ directory and /etc/make.conf.local should be renamed to /etc/make.conf.
.include </etc/make.conf.local>
OpenPOWER on IntegriCloud