root/common/trunk/configure @ 49

Revision 49, 5.7 KB (checked in by ucaccsp, 15 years ago)

Detect the need for -DNEED_INET_PTON on Linux libc 5.x
Colin

  • 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 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"
50                           echo "Not supported."
51                           exit
52                           ;;
53esac
54
55echo "Configuring common code library v$VERSION for $OSTYPE"
56
57GCCWFLAGS="-W -Wall -Wbad-function-cast -Wmissing-prototypes -Werror"
58DEFS=""
59
60AR="ar"
61RANLIB="ranlib"
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            ;;
82  IRIX    ) CC="cc"
83            WFLAGS="-fullwarn -w2"
84            INCLUDE=""
85            LDLIBS="-lm"
86            DEBUG="-g"
87            CHAR="-signed"
88            OPTIMIZE="-O2"
89            PROFILE=""
90            ;;
91  Linux   ) CC="gcc"
92            WFLAGS=$GCCWFLAGS
93            INCLUDE=""
94            LDLIBS="-lm -ldl"
95            DEBUG="-g"
96            CHAR="-fsigned-char"
97            OPTIMIZE="-O4"
98            PROFILE="-pg"
99            ;;
100  FreeBSD ) CC="gcc"
101            WFLAGS=$GCCWFLAGS
102            INCLUDE="-I/usr/local/include"
103            LDLIBS="-lm"
104            DEBUG="-g"
105            CHAR="-fsigned-char"
106            OPTIMIZE="-O4"
107            PROFILE="-pg"
108            ;;
109  HPUX    ) CC="gcc"
110            WFLAGS=$GCCWFLAGS
111            INCLUDE=""
112            LDLIBS="-lm -ldld"
113            DEBUG="-g"
114            CHAR="-fsigned-char"
115            OPTIMIZE="-O4"
116            PROFILE="-pg"
117            ;;
118  NetBSD )  CC="gcc"
119            WFLAGS=$GCCWFLAGS
120            INCLUDE="-I/usr/local/include"
121            LDLIBS="-lm"
122            DEBUG="-g"
123            CHAR="-fsigned-char"
124            OPTIMIZE="-O4"
125            PROFILE="-pg"
126            ;;
127esac
128
129echo -n "Searching for in_addr_t in <netinet/in.h>... "
130T1=`grep -c in_addr_t /usr/include/netinet/in.h`
131if [ $T1 = 0 ]; then
132        DEFS="$DEFS -DNEED_IN_ADDR_T"
133        echo "no"
134else 
135        echo "yes"
136fi
137
138# This is the usual place for inet_pton()...
139echo -n "Searching for inet_pton in <arpa/inet.h>... "
140T2=`grep -c inet_pton /usr/include/arpa/inet.h`
141if [ $T2 = 0 ]; then
142        echo "no"
143        # ...but Solaris 2.6 has in it resolv.h...
144        echo -n "Searching for inet_pton in <resolv.h>... "
145        T2=`grep -c inet_pton /usr/include/resolv.h`
146        if [ $T2 = 0 ]; then
147                DEFS="$DEFS -DNEED_INET_PTON"
148                echo "no"
149        else 
150                echo "yes"
151        fi
152else 
153        echo "yes"
154fi
155
156# Process options to the configure script...
157DEBUG2=""
158OPTIMIZE2=""
159PROFILE2=""
160CHECK_FLAG=""
161CHECK_LIB=""
162while test $# -gt 0
163do
164        if [ $1 = "-debug" ]; then
165                DEBUG2=$DEBUG
166                DEFS="$DEFS -DDEBUG"
167                echo "Enabled debug option"
168        elif [ $1 = "-optimize" ]; then
169                OPTIMIZE2=$OPTIMIZE
170                DEFS="-DNDEBUG"
171                echo "Enabled optimize option"
172        elif [ $1 = "-profile" ]; then
173                PROFILE2=$PROFILE
174                echo "Enabled profile option"
175        elif [ $1 = "-bounds" ]; then
176                CHECK_FLAG=-fbounds-checking
177                CHECK_LIB=-lcheck
178                echo "Enabled bounds checking option" 
179        else 
180                DEFS="$DEFS $1"
181                echo "Added $1 compile flag"
182        fi
183        shift
184done
185
186# Create Makefile
187echo "Generating Makefile"
188echo "# Generated automatically from Makefile.in" > Makefile
189echo "# DO NOT EDIT THIS FILE" >> Makefile
190
191cat > Makefile.sed <<EOF
192s@__OSTYPE__@$OSTYPE@
193s@__CC__@$CC@
194s@__AR__@$AR@
195s@__RANLIB__@$RANLIB@
196s@__WFLAGS__@$WFLAGS@
197s@__INCLUDE__@$INCLUDE@
198s@__LDLIBS__@$LDLIBS@
199s@__CHAR__@$CHAR@
200s@__DEBUG__@$DEBUG2@
201s@__OPTIMIZE__@$OPTIMIZE2@
202s@__PROFILE__@$PROFILE2@
203s@__DEFS__@$DEFS@
204s@__CHECK_FLAG__@$CHECK_FLAG@
205s@__CHECK_LIB__@$CHECK_LIB@
206EOF
207
208sed -f Makefile.sed Makefile.in >> Makefile
209
210# Create version.h
211echo "Generating version.h"
212echo \#define CCL_VERSION \"CCL v$VERSION $OSTYPE\" > version.h
Note: See TracBrowser for help on using the browser.