Fix CFLAGS/LDFLAGS syntax
[platform/upstream/lrzsz.git] / systype.in
1 #! /bin/sh
2
3 CC="@CC@"
4 CFLAGS="@CFLAGS@"
5 GCC="@GCC@"
6
7 srcdir=@srcdir@
8
9 # oper-:arch-:syst-:chip-:kern-
10 # oper = operating system type; e.g., sunos-4.1.4
11 # arch = machine language; e.g., sparc
12 # syst = which binaries can run; e.g., sun4
13 # chip = chip model; e.g., micro-2-80
14 # kern = kernel version; e.g., sun4m
15 # dependence: arch --- chip
16 #                 \        \
17 #          oper --- syst --- kern
18 # so, for example, syst is interpreted in light of oper, but chip is not.
19 # anyway, no slashes, no extra colons, no uppercase letters.
20 # the point of the extra -'s is to ease parsing: can add hierarchies later.
21 # e.g., *:i386-*:*:pentium-*:* would handle pentium-100 as well as pentium,
22 # and i386-486 (486s do have more instructions, you know) as well as i386.
23 # the idea here is to include ALL useful available information.
24
25 sys="`uname -s 2>/dev/null | tr '/:[A-Z]' '..[a-z]'`"
26 if [ x"$sys" != x ]
27 then
28   unamer="`uname -r 2>/dev/null | tr /: ..`"
29   unamem="`uname -m 2>/dev/null | tr /: ..`"
30   unamev="`uname -v 2>/dev/null | tr /: ..`"
31
32   case "$sys" in
33   bsd.os)
34     # in bsd 4.4, uname -v does not have useful info.
35     # in bsd 4.4, uname -m is arch, not chip.
36     oper="$sys-$unamer"
37     arch="$unamem"
38     syst=""
39     chip="`sysctl -n hw.model 2>/dev/null`"
40     kern=""
41     ;;
42   freebsd)
43     # see above about bsd 4.4
44     oper="$sys-$unamer"
45     arch="$unamem"
46     syst=""
47     chip="`sysctl -n hw.model 2>/dev/null`" # hopefully
48     kern=""
49     ;;
50   netbsd)
51     # see above about bsd 4.4
52     oper="$sys-$unamer"
53     arch="$unamem"
54     syst=""
55     chip="`sysctl -n hw.model 2>/dev/null`" # hopefully
56     kern=""
57     ;;
58   linux)
59     # i'd really like to know what distribution the user has ...
60
61     # as in bsd 4.4, uname -v does not have useful info.
62     oper="$sys-$unamer" # not oper!
63     syst=""
64     chip="$unamem"
65     case "$chip" in
66     i386|i486|i586|i686)
67       arch="i386"
68       ;;
69     alpha)
70       arch="alpha"
71       ;;
72     esac
73     ;;
74   aix)
75     # naturally IBM has to get uname -r and uname -v backwards. dorks.
76     oper="$sys-$unamev-$unamer"
77     arch="`arch  2>/dev/null | tr /: ..`"
78     syst=""
79     chip="$unamem"
80     kern=""
81     ;;
82   sunos)
83     oper="$sys-$unamer-$unamev"
84     arch="`(uname -p 2>/dev/null || mach 2>/dev/null ) | tr /: ..`"
85     syst="`arch 2>/dev/null | tr /: ..`"
86     chip="$unamem" # this is wrong; is there any way to get the real info?
87     kern="`arch -k 2>/dev/null | tr /: ..`"
88     ;;
89   unix_sv)
90     oper="$sys-$unamer-$unamev"
91     arch="`uname -m 2>/dev/null`"
92     syst=""
93     chip="$unamem"
94     kern=""
95     ;;
96   beos)
97         oper="$sys-$unamer-$unamev"
98         case "$unamem" in
99         *BePC*) 
100                 arch="i386";
101                 chip="";
102                 if /bin/sysinfo -cpu 2>/dev/null >/dev/null ; then
103                         (/bin/sysinfo -cpu 2>/dev/null |grep PentiumPro >/dev/null) && chip=ppro; 
104                         test "$chip" = "" && \
105                                 (/bin/sysinfo -cpu 2>/dev/null |grep Pentium >/dev/null) && chip=pentium; 
106                 fi
107                 ;;
108         esac
109         ;;
110   *)
111     need_config_guess=1;
112     ;;
113   esac
114 else
115         need_config_guess=1;
116 fi
117
118 if test "x$need_config_guess" = x1 ; then
119         cg=`$srcdir/config.guess` # cpu-company-system
120         if test "x$cg" = x ; then
121                 # damned, config.guess does nothing if it doesn't support the
122                 # system.
123                 oper="`uname -s 2>/dev/null | tr '/:[A-Z]' '..[a-z]'`"
124                 chip="`uname -m 2>/dev/null | tr /: ..`"
125                 if test "x$oper" = x ; then
126                         oper="unknown"
127                 fi
128         else
129                 # cpu-company-system
130                 # chip-useless-oper+version
131                 # i586-unknown-sco3.2v4.2
132                 # m68k-hp-hpux9.00
133                 # i486-unknown-linux
134                 chip="`echo $cg | sed s/-.*//`"
135                 oper="`echo $cg | sed s/.*-// | tr '[A-Z]' '[a-z]'`"
136                 case "$oper" in
137                 *[0-9]*)
138                         # sco3.2v4.2
139                         # hpux9.00
140                         x="`echo $oper|sed 's/[0-9].*//'`"
141                         y="`echo $oper|sed 's/^[a-z]*//'`"
142                         oper="$x-$y";
143                         ;;
144                 *linux*)        
145                         oper=linux-"`uname -r`"
146                         ;;
147                 esac
148         fi
149 fi
150
151
152 case "$chip" in
153 80486)
154   # let's try to be consistent here. (BSD/OS)
155   chip=i486
156   ;;
157 i486DX)
158   # respect the hyphen hierarchy. (FreeBSD)
159   chip=i486-dx
160   ;;
161 i486.DX2)
162   # respect the hyphen hierarchy. (FreeBSD)
163   chip=i486-dx2
164   ;;
165 Intel.586)
166   # no, you nitwits, there is no such chip. (NeXTStep)
167   chip=pentium
168   ;;
169 i586)
170   # no, you nitwits, there is no such chip. (Linux)
171   chip=pentium
172   # djb, stop bashing linux alone, bash to GNU people too ...
173   # config.guess also does this!
174   ;;
175 i686)
176   # STOP SAYING THAT! (Linux)
177   chip=ppro
178 esac
179 if test "x$arch" = x ; then
180         if test "x$chip" = i386 -o "x$chip" = i486 -o "x$chip" = "pentium" \
181                 -o "x$chip" = "ppro" ; then
182                 arch="i386";
183         fi
184 fi
185
186 x=`echo "$oper-:$arch-:$syst-:$chip-:$kern-" | tr ' [A-Z]' '.[a-z]'`
187
188 if test x"$@" = x ; then
189         echo "Future @PACKAGE@ versions will include a list of systems this version" >&2
190         echo "was compiled under (that's what you send this message for). In case" >&2 
191         echo "want to see a shorthand expression of your real name in this list" >&2
192         echo "you may provide it here:" >&2
193         echo "Realname: " >&2
194         read realname
195 else
196         realname="$@"
197 fi
198
199 echo # BeOS /bin/mail doesn't generate any header ...
200 echo ""
201 echo "SYS: $x"
202 echo "PACKAGE: @PACKAGE@ @VERSION@"
203 cc="`echo \"$CC\"|sed 's/ .*//'`" 
204 x=`$CC --version </dev/null 2>/dev/null`
205 echo "CC: $cc $x"
206 echo "CFLAGS: $CFLAGS"
207 if test "x$realname" = x ; then
208         :
209 else
210         echo "REALNAME: $realname"
211 fi