summaryrefslogtreecommitdiff
path: root/devel/cpuflags/files/cpuflags.NetBSD
blob: 797a46bfc8ca22a4a8b812dbb1d236f45f71587e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# $NetBSD: cpuflags.NetBSD,v 1.7 2001/07/02 22:14:56 abs Exp $

hw_model=`/sbin/sysctl -n hw.model`

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+
    CY7C601*)		FLAGS="-mcpu=cypress"		;; # ss2
    # under 1.5.1 -mcpu=ultrasparc chokes egcs-2.91.66 compiling perl
    SUNW,UltraSPARC*)	FLAGS="-mcpu=v9"		;; # Ultra
    #
    # arm32
    ARM610*)		FLAGS="-mcpu=arm610"		;; # risc pc
    ARM710*)		FLAGS="-mcpu=arm710"		;; # risc pc
    SA-110*)	
	# The memorybus in strongarm risc pc machines cannot support
	# certain strongarm instructions, but we cannot tell a shark
	# from such a risc pc via uname or sysctl (Certainly for 1.5)
	if grep -q ofbus0 /var/run/dmesg.boot 2>/dev/null ; then
	    FLAGS="-mcpu=strongarm110"			   # shark
	else
	    FLAGS="-march=armv3m -mtune=strongarm"	   # risc pc
	fi						;;
    #
    *)			echo "Unknown hw.model '$hw_model'" >&2
esac

if [ -n "$FLAGS" ]; then
    gcc_ver=`gcc -v 2>&1 | awk '/gcc version/ {print $3}'`
    case $gcc_ver in
	egcs* )
	    gcc_ver=2.8 ;;
    esac

    # Old gcc, such as 2.7.x in NetBSD 1.3
    if [ "$gcc_ver" \< 2.8 ]; then
	FLAGS=`awk -v "flags=$FLAGS" '
{map["-m"$1] = "-m"$2}
END{print map[flags]}' <<EOD
arch=i386		no-486
arch=i486		486
arch=pentium		486
arch=pentiumpro		486
cpu=supersparc		supersparc
cpu=sparclite		sparclite
cpu=cypress		cypress
cpu=v9			v8
EOD
`
    fi
fi

echo $FLAGS

exit 0