The first a bug in pax and should be commited to FBSD, too.
[dragonfly.git] / contrib / isc-dhcp / configure
1 #!/bin/sh
2
3 #sysname=$1
4
5 while [ $# != 0 ]; do
6   if [ x$1 = x--with-nsupdate ]; then
7     echo "nsupdate is always built now."
8   elif [ x$1 = x--print-sysname ]; then
9     print_sysname=yes
10   elif [ x$1 = x--work-dir ]; then
11     workname=$2
12     shift
13   elif [ x$1 = x--dirs ]; then
14     dirs=$2
15     shift
16   elif [ x$1 = x--no-links ]; then
17     nolinks=YES
18   elif [ x$1 = x--copts ]; then
19     copts=$2
20     shift
21   elif [ x$sysname = x ]; then
22     sysname=$1
23   else
24     echo "Unexpected argument: $1"
25   fi
26   shift
27 done
28
29 uname=`uname -s`
30 machine=`uname -m`
31
32 if [ "$sysname" = "" ]; then
33   case $uname in
34     SCO_SV)
35       IFS=":"
36       for foo in $PATH; do
37         if [ x$gcc_path = x ] && [ -x $foo/gcc ]; then
38           gcc_path=$foo/gcc
39         fi 
40       done
41       IFS=" "
42       if [ x$gcc_path = x ]; then
43         sysname=sco-cc
44         sysname_print=sco
45       else
46         sysname=sco-gcc
47         sysname_print=sco
48       fi
49     ;;
50     AIX)
51       sysname=aix;;
52     Darwin)
53       sysname=darwin;;
54     Rhapsody)
55       sysname=rhapsody;;
56     ULTRIX)
57       sysname=ultrix;;
58     BSD/OS)
59       release=`uname -r`
60       minor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'`
61       major=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
62       
63       case $major in
64         [123]) sysname=bsdos ;;
65         *) case $minor in
66              0) sysname=bsdos ;;
67              *) sysname=bsdos-4.1 ;;
68            esac;;
69       esac;;
70     OSF1)
71       if [ $machine = 'alpha' ]; then
72         sysname=alphaosf
73       fi;;
74     Linux)
75       release=`uname -r`
76       minor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'`
77       major=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
78       
79       case $major in
80         1) sysname=linux-1 ;;
81         2) case $minor in
82              0) sysname=linux-2.0 ;;
83              1) sysname=linux-2.1 ;;
84              2) sysname=linux-2.2 ;;
85              *) sysname=linux-2.2 ;;
86            esac;;
87       esac;;
88     SunOS)
89       release=`uname -r`
90       minor=`echo $release |sed -e 's/.*[0-9]*\.\([0-9][0-9]*\).*$/\1/'`
91       major=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
92       IFS=":"
93       for foo in $PATH; do
94         if [ x$gcc_path = x ] && [ -x $foo/gcc ]; then
95           gcc_path=$foo/gcc
96         fi
97       done
98       IFS=" "
99
100       case $major in
101         4) 
102           if [ x$gcc_path = x ]; then
103             echo SunOS 4 build will not work without the GNU C Compiler.
104             exit 1
105           fi
106           sysname=sunos4;;
107         5)
108           if [ x$gcc_path = x ]; then
109             sysname=sunos5-cc
110             sysname_print=sunos5
111           else
112             sysname=sunos5-gcc
113             sysname_print=sunos5
114           fi;;
115       esac;;
116     NetBSD)
117       hw=`uname -m`
118       case $hw in
119         arm32) sysname=netbsd-nocast;;
120         alpha) sysname=netbsd-nocast;;
121         sparc) sysname=netbsd-nocast;;
122         sparc64) sysname=netbsd-nocast;;
123         *) sysname=netbsd;;
124       esac;;
125     OpenBSD)
126       sysname=openbsd;;
127     FreeBSD)
128       sysname=freebsd;;
129     hpux)
130       IFS=":"
131       for foo in $PATH; do
132         if [ x$gcc_path = x ] && [ -x $foo/gcc ]; then
133           gcc_path=$foo/gcc
134         fi
135       done
136       IFS=" "
137
138       if [ x$gcc_path = x ]; then
139           sysname=hpux-cc
140           sysname_print=hpux
141         else
142           sysname=hpux-gcc
143           sysname_print=hpux
144         fi;;
145     HP-UX)
146       IFS=":"
147       for foo in $PATH; do
148         if [ x$gcc_path = x ] && [ -x $foo/gcc ]; then
149           gcc_path=$foo/gcc
150         fi
151       done
152       IFS=" "
153
154       if [ x$gcc_path = x ]; then
155           sysname=hpux-cc
156           sysname_print=hpux
157         else
158           sysname=hpux-gcc
159           sysname_print=hpux
160         fi;;
161     QNX)
162       release=`uname -r`
163       major=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
164       case $major in
165         6)
166           sysname=qnxnto;;
167         *)
168           sysname=qnx;;
169       esac;;      
170     NEXTSTEP)
171       sysname=nextstep;;
172     UnixWare)
173       sysname=uw7;;
174   esac
175 fi
176
177 if [ "$sysname" = "" ]; then
178   if [ x$print_sysname = xyes ]; then
179     echo "unknown"
180   else
181     echo "UNIX name: $uname    machine: $machine"
182     echo
183     echo "Unknown system.   If this is an SCO system running ODT 3.0 or"
184     echo "higher, type \`\`./configure sco''.   Otherwise, this is a"
185     echo "configuration that isn't supported or hasn't been tested."
186     echo
187     echo "Supported configurations are:"
188     echo "   aix                AIX 4.1.5.0"
189     echo "   ultrix     ULTRIX 4.2A or higher"
190     echo "   bsdos      BSDI BSD/OS 2.1"
191     echo "   alphaosf   DEC Alpha OSF/1"
192     echo "   linux      Linux"
193     echo "   sunos4     Sunos 4.1.4 (earlier releases may work)"
194     echo "   sunos5-cc  Solaris 2.4 or higher with Sun cc"
195     echo "   sunos5-gcc Solaris 2.4 or higher with gcc"
196     echo "   netbsd     NetBSD 1.1 or higher"
197     echo "   freebsd    FreeBSD"
198     echo "   openbsd      OpenBSD (i386/alpha)"
199     echo "   hpux               HP-UX"
200     echo "   qnx                QNX 4.2 or higher"
201     echo "   NEXTSTEP     NeXTSTEP"
202     echo "   sco        SCO Open Server"
203     exit 1;
204   fi
205 fi
206
207 if [ x$print_sysname = xyes ]; then
208   if [ x$sysname_print != x ]; then
209     echo $sysname_print
210   else
211     echo $sysname
212   fi
213   exit 0
214 fi
215
216 if [ x$workname = x ]; then
217   if [ x$sysname_print != x ]; then
218     workname=work.${sysname_print}
219   else
220     workname=work.${sysname}
221   fi
222 fi
223
224 echo "System Type: $sysname"
225
226 if [ x$major != x ] && [ x$minor != x ]; then
227   majversubst="-e /^##--majver--/,/^##--majver--/s/MajorVersion/$major/"
228   minversubst="-e /^##--minver--/,/^##--minver--/s/MinorVersion/$minor/"
229 fi
230
231 if [ ! -d $workname ]; then
232   mkdir $workname
233 fi
234
235 if [ x"$dirs" = x ]; then
236   dirs=". client server relay common omapip dhcpctl minires dst"
237 fi
238
239 for foo in $dirs; do
240         bar=`basename $foo`
241         if [ ! -d ${workname}/$bar ]; then
242           mkdir ${workname}/$bar
243         fi
244         (sed $majversubst $minversubst \
245               -e "/^##--${sysname}--/,/^##--${sysname}--/s/^#//" \
246                                 <Makefile.conf; \
247                 cat site.conf; \
248                 echo "TOP = `pwd`"; \
249                 echo CC_OPTIONS = $copts; \
250                 cat $foo/Makefile.dist) \
251                                 >${workname}/$bar/Makefile
252 done
253
254 # Make the link tree in which to actually build.
255 if [ x$nolinks = x ]; then
256   make links
257 fi
258
259 exit 0