root/common/trunk/configure @ 98

Revision 98, 7.3 KB (checked in by ucacoxh, 15 years ago)

Fixes for FreeBSD 2.x:

a) cannot output files into /dev/null when compiling on FreeBSD 2.x (?)
Not sure whether this is just a feature of the machine being used or not.

b) For inet_pton test, arpa/inet.h must have sys/types.h sys/socket.h

and netinet/in.h in front of it because it references undefined
structure.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/bin/sh
2#
3# Copyright (c) 1998-99 University College London
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14# 3. All advertising materials mentioning features or use of this software
15#    must display the following acknowledgement:
16#      This product includes software developed by the Computer Science
17#      Department at University College London
18# 4. Neither the name of the University nor of the Department may be used
19#    to endorse or promote products derived from this software without
20#    specific prior written permission.
21# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
22# ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
25# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31# SUCH DAMAGE.
32#
33
34VERSION=`cat VERSION`
35
36OSTYPE=`uname -s`
37case $OSTYPE in
38  SunOS                  ) OSTYPE=`uname -s`_`uname -r | awk -F. '{print $1}'`
39                           if [ $OSTYPE = SunOS_4 ]; then
40                                OSTYPE=SunOS
41                           elif [ $OSTYPE = SunOS_5 ]; then
42                                OSTYPE=Solaris
43                           fi
44                           ;;
45  HP-UX                  ) OSTYPE=HPUX
46                           ;;
47  Linux | IRIX | FreeBSD | NetBSD )
48                           ;;
49  *                      ) echo "$OSTYPE not supported. Sorry."
50                           exit
51                           ;;
52esac
53
54echo "Configuring common code library v$VERSION for $OSTYPE"
55
56GCCWFLAGS="-W -Wall -Wbad-function-cast -Wmissing-prototypes -Werror"
57DEFS=""
58
59AR="ar"
60RANLIB="ranlib"
61ECHO="echo"
62
63case $OSTYPE in
64  SunOS   ) CC="gcc"
65            WFLAGS=$GCCWFLAGS
66            INCLUDE=""
67            LDLIBS="-laudio -lm"
68            DEBUG="-g"
69            CHAR="-fsigned-char"
70            OPTIMIZE="-O4"
71            PROFILE="-pg"
72            ;;
73  Solaris ) CC="gcc -pipe"
74            WFLAGS=$GCCWFLAGS
75            INCLUDE=""
76            LDLIBS="-lsocket -ldl -lnsl -lm"
77            DEBUG="-g"
78            CHAR="-fsigned-char"
79            OPTIMIZE="-O4"
80            PROFILE="-pg"
81            ECHO=/usr/bin/echo
82            ;;
83  IRIX    ) CC="cc"
84            WFLAGS="-fullwarn -w2"
85            INCLUDE=""
86            LDLIBS="-lm"
87            DEBUG="-g"
88            CHAR="-signed"
89            OPTIMIZE="-O2"
90            PROFILE=""
91            ;;
92  Linux   ) CC="gcc"
93            WFLAGS=$GCCWFLAGS
94            INCLUDE=""
95            LDLIBS="-lm -ldl"
96            DEBUG="-g"
97            CHAR="-fsigned-char"
98            OPTIMIZE="-O4"
99            PROFILE="-pg"
100            ECHO="echo -e"
101            ;;
102  FreeBSD ) CC="gcc"
103            WFLAGS=$GCCWFLAGS
104            INCLUDE="-I/usr/local/include"
105            LDLIBS="-lm"
106            DEBUG="-g"
107            CHAR="-fsigned-char"
108            OPTIMIZE="-O4"
109            PROFILE="-pg"
110            ECHO=/bin/echo
111            ;;
112  HPUX    ) CC="gcc"
113            WFLAGS=$GCCWFLAGS
114            INCLUDE=""
115            LDLIBS="-lm -ldld"
116            DEBUG="-g"
117            CHAR="-fsigned-char"
118            OPTIMIZE="-O4"
119            PROFILE="-pg"
120            ;;
121  NetBSD )  CC="gcc"
122            WFLAGS=$GCCWFLAGS
123            INCLUDE="-I/usr/local/include"
124            LDLIBS="-lm"
125            DEBUG="-g"
126            CHAR="-fsigned-char"
127            OPTIMIZE="-O4"
128            PROFILE="-pg"
129            ;;
130esac
131
132${ECHO} "Searching for in_addr_t in <netinet/in.h>... \c"
133T1=`grep -c in_addr_t /usr/include/netinet/in.h`
134if [ $T1 = 0 ]; then
135        DEFS="$DEFS -DNEED_IN_ADDR_T"
136        ${ECHO} "no"
137else 
138        ${ECHO} "yes"
139fi
140
141# This is the usual place for inet_pton()...
142${ECHO} "Searching for inet_pton in <arpa/inet.h>... \c"
143T2=`grep -c inet_pton /usr/include/arpa/inet.h`
144if [ $T2 = 0 ]; then
145        ${ECHO} "no"
146        DEFS="$DEFS -DNEED_INET_PTON -DNEED_INET_PTON_STATIC"
147else 
148        # Okay, we have a header for inet_pton(), but is the function
149        # really there?
150        cat > configure.inet_pton.c <<EOF
151                #include <sys/types.h>
152                #include <sys/socket.h>
153                #include <netinet/in.h>
154                #include <arpa/inet.h>
155                int main()               
156                {                       
157                        inet_pton(0,0,0);
158                        return 0;       
159                }                       
160EOF
161        ${CC} ${LDLIBS} -o configure.inet_pton.bin configure.inet_pton.c 2> configure.inet_pton.out
162        T3=`wc -l configure.inet_pton.out | awk '{print $1}'`
163        if [ $T3 = 0 ]; then
164                ${ECHO} "yes"
165        else 
166                ${ECHO} "header, no implementation"
167                DEFS="$DEFS -DNEED_INET_PTON"
168        fi
169        rm -f configure.inet_pton.c configure.inet_pton.out configure.inet_pton.bin
170fi
171
172# This is the usual place for inet_aton()...
173${ECHO} "Searching for inet_aton in <arpa/inet.h>... \c"
174T2=`grep -c inet_aton /usr/include/arpa/inet.h`
175if [ $T2 = 0 ]; then
176        ${ECHO} "no"
177        DEFS="$DEFS -DNEED_INET_ATON -DNEED_INET_ATON_STATIC"
178else 
179        # Okay, we have a header for inet_aton(), but is the function
180        # really there?
181        cat > configure.inet_aton.c <<EOF
182                #include <sys/types.h>
183                #include <sys/socket.h>
184                #include <netinet/in.h>
185                #include <arpa/inet.h> 
186                int main()             
187                {                     
188                        inet_aton(0,0);
189                        return 0;     
190                }                     
191EOF
192        ${CC} ${LDLIBS} -o configure.inet_aton.bin configure.inet_aton.c 2> configure.inet_aton.out
193        T3=`wc -l configure.inet_aton.out | awk '{print $1}'`
194        if [ $T3 = 0 ]; then
195                ${ECHO} "yes"
196        else 
197                ${ECHO} "header, no implementation"
198                DEFS="$DEFS -DNEED_INET_ATON"
199        fi
200        rm -f configure.inet_aton.c configure.inet_aton.out configure.inet_aton.bin
201fi
202
203${ECHO} "Searching for getipnodebyname in <netdb.h>... \c"
204T1=`grep -c getipnodebyname /usr/include/netdb.h`
205if [ $T1 = 0 ]; then
206        ${ECHO} "no"
207else 
208        DEFS="$DEFS -DHAVE_IPv6"
209        ${ECHO} "yes"
210fi
211
212
213# Process options to the configure script...
214DEBUG2=""
215OPTIMIZE2=""
216PROFILE2=""
217CHECK_FLAG=""
218CHECK_LIB=""
219while test $# -gt 0
220do
221        if [ $1 = "-debug" ]; then
222                DEBUG2=$DEBUG
223                DEFS="$DEFS -DDEBUG"
224                echo "Enabled debug option"
225        elif [ $1 = "-optimize" ]; then
226                OPTIMIZE2=$OPTIMIZE
227                DEFS="$DEFS -DNDEBUG"
228                echo "Enabled optimize option"
229        elif [ $1 = "-profile" ]; then
230                PROFILE2=$PROFILE
231                echo "Enabled profile option"
232        elif [ $1 = "-bounds" ]; then
233                CHECK_FLAG=-fbounds-checking
234                CHECK_LIB=-lcheck
235                echo "Enabled bounds checking option" 
236        else 
237                DEFS="$DEFS $1"
238                echo "Added $1 compile flag"
239        fi
240        shift
241done
242
243# Create Makefile
244echo "Generating Makefile"
245echo "# Generated automatically from Makefile.in" > Makefile
246echo "# DO NOT EDIT THIS FILE" >> Makefile
247
248cat > Makefile.sed <<EOF
249s@__OSTYPE__@$OSTYPE@
250s@__CC__@$CC@
251s@__AR__@$AR@
252s@__RANLIB__@$RANLIB@
253s@__WFLAGS__@$WFLAGS@
254s@__INCLUDE__@$INCLUDE@
255s@__LDLIBS__@$LDLIBS@
256s@__CHAR__@$CHAR@
257s@__DEBUG__@$DEBUG2@
258s@__OPTIMIZE__@$OPTIMIZE2@
259s@__PROFILE__@$PROFILE2@
260s@__DEFS__@$DEFS@
261s@__CHECK_FLAG__@$CHECK_FLAG@
262s@__CHECK_LIB__@$CHECK_LIB@
263EOF
264
265sed -f Makefile.sed Makefile.in >> Makefile
266rm -f Makefile.sed
267
268# Create version.h
269echo "Generating version.h"
270echo \#define CCL_VERSION \"CCL v$VERSION $OSTYPE\" > version.h
Note: See TracBrowser for help on using the browser.