summaryrefslogtreecommitdiff
path: root/devel/cpuflags
diff options
context:
space:
mode:
authorabs <abs>2001-06-07 09:59:28 +0000
committerabs <abs>2001-06-07 09:59:28 +0000
commit6b6e9afb847cd4585c1f7ee362c6fdf13cdf5e42 (patch)
tree1f582100f16f399614663ffa3767a0a0f27413a1 /devel/cpuflags
parent46d92dbca48b74179e998eceb58b140d61151d4c (diff)
downloadpkgsrc-6b6e9afb847cd4585c1f7ee362c6fdf13cdf5e42.tar.gz
Re-import cpuflags under devel
Diffstat (limited to 'devel/cpuflags')
-rw-r--r--devel/cpuflags/Makefile25
-rw-r--r--devel/cpuflags/files/cpuflags.138
-rwxr-xr-xdevel/cpuflags/files/cpuflags.Linux18
-rwxr-xr-xdevel/cpuflags/files/cpuflags.NetBSD58
-rw-r--r--devel/cpuflags/pkg/DESCR2
-rw-r--r--devel/cpuflags/pkg/PLIST3
6 files changed, 144 insertions, 0 deletions
diff --git a/devel/cpuflags/Makefile b/devel/cpuflags/Makefile
new file mode 100644
index 00000000000..61eaa057a7e
--- /dev/null
+++ b/devel/cpuflags/Makefile
@@ -0,0 +1,25 @@
+# $NetBSD: Makefile,v 1.1.1.1 2001/06/07 09:59:28 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
+
+ONLY_FOR_PLATFORM= NetBSD-*-* Linux-*-*
+
+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/devel/cpuflags/files/cpuflags.1 b/devel/cpuflags/files/cpuflags.1
new file mode 100644
index 00000000000..ea9a509f106
--- /dev/null
+++ b/devel/cpuflags/files/cpuflags.1
@@ -0,0 +1,38 @@
+.\" $NetBSD: cpuflags.1,v 1.1.1.1 2001/06/07 09:59:28 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/devel/cpuflags/files/cpuflags.Linux b/devel/cpuflags/files/cpuflags.Linux
new file mode 100755
index 00000000000..dad3176fbc2
--- /dev/null
+++ b/devel/cpuflags/files/cpuflags.Linux
@@ -0,0 +1,18 @@
+#!/bin/sh
+# $NetBSD: cpuflags.Linux,v 1.1.1.1 2001/06/07 09:59:28 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/devel/cpuflags/files/cpuflags.NetBSD b/devel/cpuflags/files/cpuflags.NetBSD
new file mode 100755
index 00000000000..9f8157395f5
--- /dev/null
+++ b/devel/cpuflags/files/cpuflags.NetBSD
@@ -0,0 +1,58 @@
+#!/bin/sh
+# $NetBSD: cpuflags.NetBSD,v 1.1.1.1 2001/06/07 09:59:28 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/devel/cpuflags/pkg/DESCR b/devel/cpuflags/pkg/DESCR
new file mode 100644
index 00000000000..bd9da12fa8c
--- /dev/null
+++ b/devel/cpuflags/pkg/DESCR
@@ -0,0 +1,2 @@
+cpuflags returns the appropriate gcc flags to optimise compilation for the
+current CPU.
diff --git a/devel/cpuflags/pkg/PLIST b/devel/cpuflags/pkg/PLIST
new file mode 100644
index 00000000000..f051d357004
--- /dev/null
+++ b/devel/cpuflags/pkg/PLIST
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2001/06/07 09:59:28 abs Exp $
+bin/cpuflags
+man/man1/cpuflags.1