diff --git a/ChangeLog b/ChangeLog index 9eaaeb6e..98125f38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ v0.51.3 22-Mar-2003 were two different values for the same purpose. The removed one was not used. Moved doc directory from /opt/mbse/doc to /opt/mbse/share/doc. + Added configure test for CPU optimization flags. mbtask: Signal handler for sigchld set to sig_dfl, test for Fedora. diff --git a/Makefile b/Makefile index 20f8368d..2bf2ea99 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ include Makefile.global OTHER = AUTHORS ChangeLog COPYING DEBUG CRON.sh FILE_ID.DIZ.in \ - INSTALL.in Makefile Makefile.global.in NEWS \ + INSTALL.in Makefile Makefile.global.in NEWS cpuflags \ ChangeLog_1998 ChangeLog_1999 ChangeLog_2000 ChangeLog_2001 \ ChangeLog_2002 ChangeLog_2003 README SETUP.sh TODO UPGRADE \ aclocal.m4 checkbasic config.h.in configure configure.in paths.h.in diff --git a/configure b/configure index f1189746..1a3ba7b7 100755 --- a/configure +++ b/configure @@ -2900,7 +2900,7 @@ fi echo "$as_me:$LINENO: checking for cpuflags" >&5 echo $ECHO_N "checking for cpuflags... $ECHO_C" >&6 -for cpuflagsbin in /usr/bin /usr/local/bin /usr/pkg/bin NONE; do +for cpuflagsbin in /usr/bin /usr/local/bin /usr/pkg/bin `pwd` NONE; do if test "$cpuflagsbin" = "NONE"; then echo "$as_me:$LINENO: result: unknown" >&5 echo "${ECHO_T}unknown" >&6 diff --git a/configure.in b/configure.in index 89fe6fdc..4718f097 100644 --- a/configure.in +++ b/configure.in @@ -83,7 +83,7 @@ dnl Check if cpuflags program is installed, if so get CPU optimization flags dnl Currently this only works on NetBSD. dnl AC_MSG_CHECKING(for cpuflags) -for cpuflagsbin in /usr/bin /usr/local/bin /usr/pkg/bin NONE; do +for cpuflagsbin in /usr/bin /usr/local/bin /usr/pkg/bin `pwd` NONE; do if test "$cpuflagsbin" = "NONE"; then AC_MSG_RESULT(unknown) elif test -x $cpuflagsbin/cpuflags; then diff --git a/cpuflags b/cpuflags new file mode 100755 index 00000000..77aaf4b0 --- /dev/null +++ b/cpuflags @@ -0,0 +1,137 @@ +#!/bin/sh +# +# $Id$ +# +# Small script to try to find out the CPU optimisation flags. +# Based on ideas found in the NetBSD cpuflags script. +# +OS=`uname -s` + +case $OS in + FreeBSD | NetBSD) + + if [ -x /sbin/sysctl ]; then + SYSCTL=/sbin/sysctl + elif [ -x /usr/sbin/sysctl ]; then + SYSCTL=/usr/sbin/sysctl + elif [ -x /bin/sysctl ]; then + SYSCTL=/bin/sysctl + else + SYSCTL=/usr/bin/sysctl + fi + + hw_machine_arch=`$SYSCTL -n hw.machine_arch` + hw_model=`$SYSCTL -n hw.model` + + case $hw_machine_arch in + + alpha) + # cpu0 at mainbus0: ID 0 (primary), 21164A-0 (unknown ... + case "`egrep '^cpu0 ' /var/run/dmesg.boot`" in + *[\(\ ]2106[46][-\ \)]*) FLAGS="-mcpu=21064" ;; + *[\(\ ]21164[-\ \)]*) FLAGS="-mcpu=21164" ;; + *[\(\ ]21164A[-\ \)]*) FLAGS="-mcpu=21164a" ;; + *[\(\ ]21264B[-\ \)]*) FLAGS="-mcpu=21264" ;; + esac + ;; + + i386) + case $hw_model in + *386-class*) FLAGS='-march=i386' ;; + *486-class*) FLAGS='-march=i486' ;; + *AMD\ K6*) FLAGS='-march=k6' ;; + *Pentium*) FLAGS='-march=pentium' ;; + *586-class*) FLAGS='-march=pentium' ;; + *686-class*) FLAGS='-march=pentiumpro' ;; + esac + ;; + + sparc | sparc64) + case " $hw_model" in # Examples + *[\ \(]MB86900/1A*) FLAGS='-mcpu=cypress' ;; # ss1+ + *[\ \(]CY7C601*) FLAGS='-mcpu=cypress' ;; # ss2 + *[\ \(]W8601/8701*) FLAGS='-mcpu=cypress' ;; # elc + *[\ \(]MB86904*) FLAGS='-mcpu=supersparc' ;; # ss5 usparc + *[\ \(]MB86907*) FLAGS='-mcpu=supersparc' ;; # ss5 usparc + *[\ \(]TMS390S10*) FLAGS='-mcpu=supersparc' ;; # classic " + *[\ \(]TMS390Z50*) FLAGS='-mcpu=supersparc' ;; # ss10/ss20 + *[\ \(]RT620/625*) FLAGS='-mcpu=supersparc' ;; # ss20 ross + *[\ \(]MB86930*) FLAGS='-mcpu=sparclite' ;; # from gcc + *[\ \(]MB86934*) FLAGS='-mcpu=sparclite' ;; # from gcc + # under 1.5.1 -mcpu=ultrasparc chokes egcs-2.91.66 compiling perl + *[\ \(]SUNW,UltraSPARC*) FLAGS='-mcpu=v9' ;; # Ultra + esac + ;; + + esac + ;; + + Linux) + hw_machine_arch=`uname -m` + case $hw_machine_arch in + + parisc) + case "`egrep 'cpu family' /proc/cpuinfo | cut -d ' ' -f 4`" in + 1.0*) FLAGS='-march=1.0' ;; + 1.1*) FLAGS='-march=1.1' ;; + 2.0*) FLAGS='-march=2.0' ;; + esac + ;; + + i386) + FLAGS='-march=i386' + ;; + + i486) + FLAGS='-march=i486' + ;; + + i586) + FLAGS='-march=pentium' + ;; + + i686) + FLAGS='-march=pentiumpro' + ;; + + *) + echo "Unsupported Linux arch $hw_machine_arch" + exit 1 + ;; + esac + ;; + + *) + echo "Unsupported OS $OS" + exit 1 + ;; +esac + + +# Fixup flags for old gcc +if [ -n "$FLAGS" ]; then + gcc_ver=`gcc -v 2>&1 | awk '/gcc version/ {sub("egcs-","");print $3}'` + FLAGS=`awk -v "flags=$FLAGS" -v "gcc_ver=$gcc_ver" ' + {if (gcc_ver < $1){map[$2] = ""$3}} + END{if (flags in map) {print map[flags]}else {print flags}} + ' <