Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / ntp / dist / scripts / cvo.sh
blobe0932bf6a78c8848fb133cae701cbcbb568fac70
1 #! /bin/sh
3 # Copyright 2002, 2009, Harlan Stenn. Used by NTP with permission.
4 # Author: Harlan Stenn <harlan+cvo@pfcs.com>
6 # Possible output formats:
8 # CVO=... Shell variable
9 # CVO=... ; export CVO Old-style exported envariable
10 # export CVO=... New-style exported envariable
11 # setenv CVO ... csh-style exported envariable
13 TS="$*"
15 CVO_raw=`config.guess`
16 CVO=$CVO_raw
18 set 1 `echo $CVO | tr '-' ' '`
19 shift
21 case "$#" in
22 4) # eg: i686-pc-linux-gnu
23 CVO_CPU=$1
24 CVO_VENDOR=$2
25 cvo_KERN=$3 # Note the capitalization...
26 CVO_OS=$4
27 case "$cvo_KERN" in
28 linux) # Braindamage. We want OS, not kernel info
29 if false
30 then
32 elif test -f /etc/debian_version
33 then
34 set `cat /etc/debian_version`
35 CVO_OS=debian$1
36 CVO_KOSVER=`uname -r`
37 elif test -f /etc/mandrake-release
38 then
39 set `cat /etc/mandrake-release`
40 CVO_OS=mandrake$4
41 CVO_KOSVER=`uname -r`
42 elif test -f /etc/redhat-release
43 then
44 set `cat /etc/redhat-release`
45 case "$1" in
46 CentOS)
47 CVO_OS=centos$3
49 Fedora)
50 CVO_OS=fedora$3
53 case "$3" in
54 Enterprise)
55 CVO_OS=redhat$7.E
57 Linux)
58 CVO_OS=redhat$5
60 esac
62 esac
63 CVO_KOSVER=`uname -r`
64 elif test -f /etc/slackware-version
65 then
66 set `cat /etc/slackware-version`
67 CVO_OS=slackware$2
68 CVO_KOSVER=`uname -r`
69 elif test -f /etc/SuSE-release
70 then
71 set `cat /etc/SuSE-release`
72 CVO_OS=suse$9
73 CVO_KOSVER=`uname -r`
74 else
75 CVO_OS=$cvo_KERN`uname -r`
79 nto) # QNX
80 CVO_KOSVER=`uname -r`
83 echo "gronk - I don't understand <$CVO>!"
84 exit 1
86 esac
88 3) CVO_CPU=$1
89 CVO_VENDOR=$2
90 CVO_OS=$3
92 *) echo "gronk - config.guess returned $# pieces, not 3 pieces!"
93 exit 1
95 esac
97 case "$CVO_OS" in
98 cygwin)
99 # Decisions, decisions.
100 # uname -r is the cygwin version #, eg: 1.3.3(0.46/3/2)
101 # uname -s returns something like CYGWIN_NT-5.0
102 CVO_OS="$CVO_OS`uname -r | sed 's/(.*//'`"
104 esac
105 set `echo $CVO_OS | sed 's/\([0-9]\)/ \1/'`
107 case "$#" in
108 2) ;;
109 *) echo "gronk - <$CVO_OS> expanded to $#, not 2 pieces!"
110 exit 1
112 esac
114 CVO_OSNAME=$1
115 CVO_OSVER=$2
117 case "$CVO_OSNAME" in
118 solaris)
119 CVO_KOSVER=`uname -v`
121 esac
123 CVO=$CVO_CPU-$CVO_VENDOR-$CVO_OS
125 case "$TS" in
127 set | grep CVO
130 # keys['cvo'] = "cvo.CVO['CVO']"
131 TS=`echo $TS | sed -e s/@cvo@/$CVO/g`
132 # keys['cpu'] = "cvo.CVO['CVO_CPU']"
133 TS=`echo $TS | sed -e s/@cpu@/$CVO_CPU/g`
134 # keys['kosver'] = "cvo.CVO['CVO_KOSVER']"
135 TS=`echo $TS | sed -e s/@kosver@/$CVO_KOSVER/g`
136 # keys['os'] = "cvo.CVO['CVO_OS']"
137 TS=`echo $TS | sed -e s/@os@/$CVO_OS/g`
138 # keys['osname'] = "cvo.CVO['CVO_OSNAME']"
139 TS=`echo $TS | sed -e s/@osname@/$CVO_OSNAME/g`
140 # keys['osver'] = "cvo.CVO['CVO_OSVER']"
141 TS=`echo $TS | sed -e s/@osver@/$CVO_OSVER/g`
142 # keys['vendor'] = "cvo.CVO['CVO_VENDOR']"
143 TS=`echo $TS | sed -e s/@vendor@/$CVO_VENDOR/g`
144 # keys['raw'] = "cvo.CVO['CVO_raw']"
145 TS=`echo $TS | sed -e s/@raw@/$CVO_raw/g`
147 echo $TS
149 esac