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