Fix package name in baselibs.conf
[platform/upstream/adns.git] / configure.in
1 # configure.in - input to autoconf
2 #  
3 #  This file is part of adns, which is
4 #    Copyright (C) 1997-2000,2003,2006  Ian Jackson
5 #    Copyright (C) 1999-2000,2003,2006  Tony Finch
6 #    Copyright (C) 1991 Massachusetts Institute of Technology
7 #  (See the file INSTALL for full details.)
8 #  
9 #  This program is free software; you can redistribute it and/or modify
10 #  it under the terms of the GNU General Public License as published by
11 #  the Free Software Foundation; either version 2, or (at your option)
12 #  any later version.
13 #  
14 #  This program is distributed in the hope that it will be useful,
15 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 #  GNU General Public License for more details.
18 #  
19 #  You should have received a copy of the GNU General Public License
20 #  along with this program; if not, write to the Free Software Foundation,
21 #  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
22
23 AC_INIT(src/adns.h)
24 AC_CONFIG_HEADER(src/config.h)
25
26 AC_DEFUN([DPKG_CACHED_TRY_COMPILE],[
27  AC_MSG_CHECKING($1)
28  AC_CACHE_VAL($2,[
29   AC_TRY_COMPILE([$3],[$4],[$2=yes],[$2=no])
30  ])
31  if test "x$$2" = xyes; then
32   true
33   $5
34  else
35   true
36   $6
37  fi
38 ])
39
40 AC_MSG_CHECKING(whether you requested dynamic linking)
41 AC_SUBST(ENABLE_DYNAMIC)
42 AC_ARG_ENABLE(dynamic,
43 [  --disable-dynamic       use static linking
44   --enable-dynamic[=elf]  create and use ELF dynamic library (default)],
45 [       case "$enableval" in
46         elf|yes)
47                 ENABLE_DYNAMIC=elf
48                 AC_MSG_RESULT([yes (ELF)])
49                 ;;
50         no)     ENABLE_DYNAMIC=no
51                 AC_MSG_RESULT(no)
52                 ;;
53         *)      AC_MSG_ERROR(
54 ["invalid value $enableval for --enable-dynamic, try yes or elf"])
55                 ;;
56         esac
57 ],[
58                 ENABLE_DYNAMIC=elf
59                 AC_MSG_RESULT([yes, by default])
60 ])
61
62 AC_PROG_CC_STDC
63 AC_USE_SYSTEM_EXTENSIONS
64 AC_SYS_LARGEFILE
65 AC_PROG_CPP
66 AC_PROG_RANLIB
67 AC_PROG_INSTALL
68
69 AH_TOP([
70 /*
71  *  This file is
72  *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
73  *
74  *  It is part of adns, which is
75  *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
76  *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
77  *  
78  *  This program is free software; you can redistribute it and/or modify
79  *  it under the terms of the GNU General Public License as published by
80  *  the Free Software Foundation; either version 2, or (at your option)
81  *  any later version.
82  *  
83  *  This program is distributed in the hope that it will be useful,
84  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
85  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
86  *  GNU General Public License for more details.
87  *  
88  *  You should have received a copy of the GNU General Public License
89  *  along with this program; if not, write to the Free Software Foundation,
90  *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
91  */
92 ])
93
94 AH_TEMPLATE([HAVE_INLINE],
95             [Define if inline functions a la GCC are available.])
96 AH_TEMPLATE([HAVE_GNUC25_ATTRIB],
97             [Define if function attributes a la GCC 2.5 and higher are available.])
98 AH_TEMPLATE([HAVE_GNUC25_CONST],
99             [Define if function attributes a la GCC 2.5 and higher are available.])
100 AH_TEMPLATE([HAVE_GNUC25_NORETURN],
101             [Define if nonreturning functions a la GCC 2.5 and higher are available.])
102 AH_TEMPLATE([HAVE_GNUC25_PRINTFFORMAT],
103             [Define if printf-format argument lists a la GCC are available.])
104 AH_TEMPLATE([HAVEUSE_RPCTYPES_H],
105             [Define if we want to include rpc/types.h.  Crap BSDs put INADDR_LOOPBACK there.])
106
107 AH_BOTTOM([
108 /* Use the definitions: */
109
110 #ifndef HAVE_INLINE
111 #define inline
112 #endif
113
114 #ifdef HAVE_POLL
115 #include <sys/poll.h>
116 #else
117 /* kludge it up */
118 struct pollfd { int fd; short events; short revents; };
119 #define POLLIN  1
120 #define POLLPRI 2
121 #define POLLOUT 4
122 #endif
123
124 /* GNU C attributes. */
125 #ifndef FUNCATTR
126 #ifdef HAVE_GNUC25_ATTRIB
127 #define FUNCATTR(x) __attribute__(x)
128 #else
129 #define FUNCATTR(x)
130 #endif
131 #endif
132
133 /* GNU C printf formats, or null. */
134 #ifndef ATTRPRINTF
135 #ifdef HAVE_GNUC25_PRINTFFORMAT
136 #define ATTRPRINTF(si,tc) format(printf,si,tc)
137 #else
138 #define ATTRPRINTF(si,tc)
139 #endif
140 #endif
141 #ifndef PRINTFFORMAT
142 #define PRINTFFORMAT(si,tc) FUNCATTR((ATTRPRINTF(si,tc)))
143 #endif
144
145 /* GNU C nonreturning functions, or null. */
146 #ifndef ATTRNORETURN
147 #ifdef HAVE_GNUC25_NORETURN
148 #define ATTRNORETURN noreturn
149 #else
150 #define ATTRNORETURN
151 #endif
152 #endif
153 #ifndef NONRETURNING
154 #define NONRETURNING FUNCATTR((ATTRNORETURN))
155 #endif
156
157 /* Combination of both the above. */
158 #ifndef NONRETURNPRINTFFORMAT
159 #define NONRETURNPRINTFFORMAT(si,tc) FUNCATTR((ATTRPRINTF(si,tc),ATTRNORETURN))
160 #endif
161
162 /* GNU C constant functions, or null. */
163 #ifndef ATTRCONST
164 #ifdef HAVE_GNUC25_CONST
165 #define ATTRCONST const
166 #else
167 #define ATTRCONST
168 #endif
169 #endif
170 #ifndef CONSTANT
171 #define CONSTANT FUNCATTR((ATTRCONST))
172 #endif
173
174 #ifdef HAVEUSE_RPCTYPES_H
175 #include <rpc/types.h>
176 #endif
177 ])
178
179 AC_CHECK_FUNCS(poll)
180 ADNS_C_GETFUNC(socket,socket)
181 ADNS_C_GETFUNC(inet_ntoa,nsl)
182
183 PROGS_IF_TSEARCH=adnsresfilter
184 AC_SUBST(PROGS_HAVE_TSEARCH)
185 AC_CHECK_FUNC(tsearch,[
186  PROGS_HAVE_TSEARCH=$PROGS_IF_TSEARCH
187 ],[
188  PROGS_HAVE_TSEARCH='';
189  AC_MSG_WARN([tsearch missing - not building client program(s) $PROGS_IF_TSEARCH])
190 ])
191
192 AC_MSG_CHECKING(for INADDR_LOOPBACK)
193 AC_CACHE_VAL(adns_cv_decl_inaddrloopback,[
194  AC_TRY_COMPILE([
195 #include <sys/socket.h>
196 #include <netinet/in.h>
197 #include <arpa/inet.h>
198  ],[
199   INADDR_LOOPBACK;
200  ],
201  adns_cv_decl_inaddrloopback=yes,
202  adns_cv_decl_inaddrloopback=no)])
203 if test "$adns_cv_decl_inaddrloopback" = yes; then
204  AC_MSG_RESULT(found)
205 else
206  AC_MSG_RESULT([not in standard headers, urgh...])
207  AC_CHECK_HEADER(rpc/types.h,[
208   AC_DEFINE(HAVEUSE_RPCTYPES_H)
209  ],[
210   AC_MSG_ERROR([cannot find INADDR_LOOPBACK or rpc/types.h])
211  ])
212 fi
213
214 ADNS_C_GETFUNC(inet_aton,resolv,[
215  LIBS="-lresolv $LIBS";
216  AC_MSG_WARN([inet_aton is in libresolv, urgh.  Must use -lresolv.])
217 ])
218
219 DPKG_CACHED_TRY_COMPILE(inlines,dpkg_cv_c_inline,,
220  [} inline int foo (int x) {],
221  AC_MSG_RESULT(yes)
222  AC_DEFINE(HAVE_INLINE),
223  AC_MSG_RESULT(no))
224
225 AC_SUBST(WARNS)
226
227 if test "${GCC-no}" = yes; then
228         WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
229         saved_cflags="$CFLAGS"
230         CFLAGS="$CFLAGS -Wno-pointer-sign"
231         DPKG_CACHED_TRY_COMPILE(-Wno-pointer-sign,adns_cv_c_wnoptrsign,,
232          [],
233          AC_MSG_RESULT(yes)
234          WARNS="$WARNS -Wno-pointer-sign",
235          AC_MSG_RESULT(no))
236         CFLAGS="$saved_cflags"
237 else
238         WARNS=
239 fi
240
241 ADNS_C_GCCATTRIB
242
243 AC_SUBST(SHLIBCC)
244 AC_SUBST(MKSHLIB_1)
245 AC_SUBST(MKSHLIB_2)
246 AC_SUBST(MKSHLIB_3)
247
248 AC_SUBST(SHLIBFORLINK)
249 AC_SUBST(SHLIBFILE)
250 AC_SUBST(SHLIBSONAME)
251
252 SHLIBFORLINK='libadns.so'
253 SHLIBSONAME='$(SHLIBFORLINK).$(MAJOR)'
254 SHLIBFILE='$(SHLIBSONAME).$(MINOR)'
255
256 SHLIBCC='$(CC) $(CFLAGS) -fpic'
257 MKSHLIB_1='$(CC) $(LDFLAGS) -shared -Wl,-soname=$(SHLIBSONAME) -o'
258 MKSHLIB_2=''
259 MKSHLIB_3='-lc'
260
261 AC_OUTPUT(
262         settings.make Makefile
263         src/Makefile client/Makefile dynamic/Makefile regress/Makefile
264 )