diff --git a/etc/defaults/make.conf b/etc/defaults/make.conf index f909dfd37081..be729cf3f493 100644 --- a/etc/defaults/make.conf +++ b/etc/defaults/make.conf @@ -13,18 +13,20 @@ # You have to find the things you can put here in the Makefiles and # documentation of the source tree. # -# -# MACHINE_CPU controls which processor-specific optimizations will be -# used by certain components of FreeBSD (currently only OpenSSL). -# This should be set to a list of your CPU type, plus all previous -# generations of the CPU architecture. The reason for using a list is -# because not all programs which use the MACHINE_CPU variable may have -# optimizations for your specific CPU generation (e.g. Pentium Pro), -# but may have optimizations for the previous generation (e.g. Pentium). -# Currently only the following CPU generations are used: -# i686 i585 i386 # -#MACHINE_CPU=i686 i586 i386 +# The CPUTYPE variable controls which processor should be targetted for +# generated code. This controls processor-specific optimizations in +# certain code (currently only OpenSSL) as well as modifying the value +# of CFLAGS to contain the appropriate optimization directive to gcc. +# The automatic setting of CFLAGS may be overridden using the +# NO_CPU_CFLAGS variable below. +# Currently the following CPU types are recognised: +# Intel x86 architecture: k7 k6 k5 i686 i585 i486 i386 +# Alpha/AXP architecture: ev6 pca56 ev56 ev5 ev45 ev4 +# Intel ia64 architecture: itanium +# +#CPUTYPE=i686 +#NO_CPU_CFLAGS= true # Don't add -march= to CFLAGS automatically # # CFLAGS controls the compiler settings used when compiling C code. # Note that optimization settings above -O (-O2, ...) are not recommended diff --git a/share/examples/etc/make.conf b/share/examples/etc/make.conf index f909dfd37081..be729cf3f493 100644 --- a/share/examples/etc/make.conf +++ b/share/examples/etc/make.conf @@ -13,18 +13,20 @@ # You have to find the things you can put here in the Makefiles and # documentation of the source tree. # -# -# MACHINE_CPU controls which processor-specific optimizations will be -# used by certain components of FreeBSD (currently only OpenSSL). -# This should be set to a list of your CPU type, plus all previous -# generations of the CPU architecture. The reason for using a list is -# because not all programs which use the MACHINE_CPU variable may have -# optimizations for your specific CPU generation (e.g. Pentium Pro), -# but may have optimizations for the previous generation (e.g. Pentium). -# Currently only the following CPU generations are used: -# i686 i585 i386 # -#MACHINE_CPU=i686 i586 i386 +# The CPUTYPE variable controls which processor should be targetted for +# generated code. This controls processor-specific optimizations in +# certain code (currently only OpenSSL) as well as modifying the value +# of CFLAGS to contain the appropriate optimization directive to gcc. +# The automatic setting of CFLAGS may be overridden using the +# NO_CPU_CFLAGS variable below. +# Currently the following CPU types are recognised: +# Intel x86 architecture: k7 k6 k5 i686 i585 i486 i386 +# Alpha/AXP architecture: ev6 pca56 ev56 ev5 ev45 ev4 +# Intel ia64 architecture: itanium +# +#CPUTYPE=i686 +#NO_CPU_CFLAGS= true # Don't add -march= to CFLAGS automatically # # CFLAGS controls the compiler settings used when compiling C code. # Note that optimization settings above -O (-O2, ...) are not recommended diff --git a/share/mk/bsd.cpu.mk b/share/mk/bsd.cpu.mk new file mode 100644 index 000000000000..bbf3080da0a1 --- /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 8ce6a8cbd699..4fac78f54745 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 .endif +.include + .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