diff options
author | abs <abs@pkgsrc.org> | 2001-05-31 11:29:17 +0000 |
---|---|---|
committer | abs <abs@pkgsrc.org> | 2001-05-31 11:29:17 +0000 |
commit | a8367637715432d722683665ed968161053ff1bb (patch) | |
tree | 39022663edb8e03fbccdbab49f9bdfa988dd285a /sysutils | |
parent | bed5d4f4fbb2a654aee0ab6a1c3297c35219a1b6 (diff) | |
download | pkgsrc-a8367637715432d722683665ed968161053ff1bb.tar.gz |
Import cpuflags-0.1
Script to determine compiler flags to best target current cpu
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/cpuflags/Makefile | 23 | ||||
-rw-r--r-- | sysutils/cpuflags/files/cpuflags.1 | 38 | ||||
-rwxr-xr-x | sysutils/cpuflags/files/cpuflags.Linux | 18 | ||||
-rwxr-xr-x | sysutils/cpuflags/files/cpuflags.NetBSD | 58 | ||||
-rw-r--r-- | sysutils/cpuflags/pkg/DESCR | 2 | ||||
-rw-r--r-- | sysutils/cpuflags/pkg/PLIST | 3 |
6 files changed, 142 insertions, 0 deletions
diff --git a/sysutils/cpuflags/Makefile b/sysutils/cpuflags/Makefile new file mode 100644 index 00000000000..f2285c15900 --- /dev/null +++ b/sysutils/cpuflags/Makefile @@ -0,0 +1,23 @@ +# $NetBSD: Makefile,v 1.1.1.1 2001/05/31 11:29:17 abs Exp $ +# + +DISTNAME= cpuflags-0.1 +CATEGORIES= sysutils +MASTER_SITES= # empty +DISTFILES= # empty + +MAINTAINER= abs@netbsd.org +COMMENT= Determine compiler flags to best target current cpu + +EXTRACT_ONLY= # empty +NO_WRKSUBDIR= yes +NO_CHECKSUM= yes +NO_PATCH= yes +NO_CONFIGURE= yes +NO_BUILD= yes + +do-install: + ${INSTALL_SCRIPT} ${FILESDIR}/cpuflags.${OPSYS} ${PREFIX}/bin/cpuflags + ${INSTALL_MAN} ${FILESDIR}/cpuflags.1 ${PREFIX}/man/man1/cpuflags.1 + +.include "../../mk/bsd.pkg.mk" diff --git a/sysutils/cpuflags/files/cpuflags.1 b/sysutils/cpuflags/files/cpuflags.1 new file mode 100644 index 00000000000..11a13a643aa --- /dev/null +++ b/sysutils/cpuflags/files/cpuflags.1 @@ -0,0 +1,38 @@ +.\" $NetBSD: cpuflags.1,v 1.1.1.1 2001/05/31 11:29:17 abs Exp $ + +.Dd May 31, 2001 +.Dt CPUFLAGS 1 +.Os +.Sh NAME +.Nm cpuflags +.Nd determine compiler flags to best target current cpu +.Sh SYNOPSIS +.Nm +.Sh DESCRIPTION +.Nm +queries the current cpu type and gcc version, then outputs appropriate +compiler options to best target code for that cpu. If no options exist +to target the current cpu then nothing is output. +.Pp +In the event of the cpu not being recognised, a warning is sent to stderr. +.Pp +.Sh EXAMPLES +.Nm +can be used to set default flags for building entries from pkgsrc and +recompiling the NetBSD kernel or userland by adding the following to +.Pa /etc/mk.conf +.Bd -literal -offset indent + .if ! defined(CPU_FLAGS) && exists(/usr/pkg/bin/cpuflags) + CPU_FLAGS!=/usr/pkg/bin/cpuflags + MAKE_ENV+=CPU_FLAGS=${CPU_FLAGS} + CFLAGS+=${CPU_FLAGS} + CXXFLAGS+=${CPU_FLAGS} + .endif +.Ed +.Sh BUGS +.Nm +does not know about many cpu types yet - updates welcomed to <abs@netbsd.org> +.Pp +Currently +.Nm +is also gcc specific. diff --git a/sysutils/cpuflags/files/cpuflags.Linux b/sysutils/cpuflags/files/cpuflags.Linux new file mode 100755 index 00000000000..ce762152b74 --- /dev/null +++ b/sysutils/cpuflags/files/cpuflags.Linux @@ -0,0 +1,18 @@ +#!/bin/sh +# $NetBSD: cpuflags.Linux,v 1.1.1.1 2001/05/31 11:29:17 abs Exp $ + +hw_model=`uname -m` + +case $hw_model in + # i386 + i386*) FLAGS='-march=i386' ;; + i486*) FLAGS='-march=i486' ;; + i586*) FLAGS='-march=pentium' ;; + i686*) FLAGS='-march=pentiumpro' ;; + # + *) echo "Unknown hw.model '$hw_model'" >&2 +esac + +echo $FLAGS + +exit 0 diff --git a/sysutils/cpuflags/files/cpuflags.NetBSD b/sysutils/cpuflags/files/cpuflags.NetBSD new file mode 100755 index 00000000000..05e1dbabd73 --- /dev/null +++ b/sysutils/cpuflags/files/cpuflags.NetBSD @@ -0,0 +1,58 @@ +#!/bin/sh +# $NetBSD: cpuflags.NetBSD,v 1.1.1.1 2001/05/31 11:29:17 abs Exp $ + +gcc_ver=`gcc -v 2>&1 | awk '/gcc version/ {print $3}'` +hw_model=`sysctl -n hw.model` + +case $gcc_ver in + egcs* ) + gcc_ver=2.8 ;; +esac + +if [ "$gcc_ver" \< 2.8 ];then # Old gcc, such as in NetBSD 1.3 + + case $hw_model in + # i386 + *386-class*) FLAGS='-mno-486' ;; + *486-class*) FLAGS='-m486' ;; + *586-class*) FLAGS='-m486' ;; + *686-class*) FLAGS='-m486' ;; + # + # sparc + MB86904* | MB86907*) FLAGS="-msupersparc" ;; # ss5 + TMS390Z50*) FLAGS="-msupersparc" ;; # ss10/ss20 + MB86930* | MB86934*) FLAGS="-msparclite" ;; # from gcc + MB86900/1A*) FLAGS="-mcypress" ;; # ss1+ + # + # arm + SA-110*) FLAGS="" ;; # shark + # + *) echo "Unknown hw.model '$hw_model'" >&2 + esac + +else # Modern gcc + + case $hw_model in + # i386 + *386-class*) FLAGS='-march=i386' ;; + *486-class*) FLAGS='-march=i486' ;; + *586-class*) FLAGS='-march=pentium' ;; + *686-class*) FLAGS='-march=pentiumpro' ;; + # + # sparc + MB86904* | MB86907*) FLAGS="-mcpu=supersparc" ;; # ss5 + TMS390Z50*) FLAGS="-mcpu=supersparc" ;; # ss10/ss20 + MB86930* | MB86934*) FLAGS="-mcpu=sparclite" ;; # from gcc + MB86900/1A*) FLAGS="-mcpu=cypress" ;; # ss1+ + # + # arm - commented until issue with identifying SA based RiscPCs solved + # SA-110*) FLAGS="-mcpu=strongarm110" ;; # shark + SA-110*) FLAGS="" ;; + # + *) echo "Unknown hw.model '$hw_model'" >&2 + esac + +fi +echo $FLAGS + +exit 0 diff --git a/sysutils/cpuflags/pkg/DESCR b/sysutils/cpuflags/pkg/DESCR new file mode 100644 index 00000000000..bd9da12fa8c --- /dev/null +++ b/sysutils/cpuflags/pkg/DESCR @@ -0,0 +1,2 @@ +cpuflags returns the appropriate gcc flags to optimise compilation for the +current CPU. diff --git a/sysutils/cpuflags/pkg/PLIST b/sysutils/cpuflags/pkg/PLIST new file mode 100644 index 00000000000..f16dfe87409 --- /dev/null +++ b/sysutils/cpuflags/pkg/PLIST @@ -0,0 +1,3 @@ +@comment $NetBSD: PLIST,v 1.1.1.1 2001/05/31 11:29:17 abs Exp $ +bin/cpuflags +man/man1/cpuflags.1 |