chiark / gitweb /
+ Improvements for multithreaded programs:
[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 dnl DPKG_CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>)
27 define([DPKG_CACHED_TRY_COMPILE],[
28  AC_MSG_CHECKING($1)
29  AC_CACHE_VAL($2,[
30   AC_TRY_COMPILE([$3],[$4],[$2=yes],[$2=no])
31  ])
32  if test "x$$2" = xyes; then
33   true
34   $5
35  else
36   true
37   $6
38  fi
39 ])
40
41 AC_MSG_CHECKING(whether you requested dynamic linking)
42 AC_SUBST(ENABLE_DYNAMIC)
43 AC_ARG_ENABLE(dynamic,
44 [  --disable-dynamic       use static linking
45   --enable-dynamic[=elf]  create and use ELF dynamic library (default)],
46 [       case "$enableval" in
47         elf|yes)
48                 ENABLE_DYNAMIC=elf
49                 AC_MSG_RESULT([yes (ELF)])
50                 ;;
51         no)     ENABLE_DYNAMIC=no
52                 AC_MSG_RESULT(no)
53                 ;;
54         *)      AC_MSG_ERROR(
55 ["invalid value $enableval for --enable-dynamic, try yes or elf"])
56                 ;;
57         esac
58 ],[
59                 ENABLE_DYNAMIC=elf
60                 AC_MSG_RESULT([yes, by default])
61 ])
62
63 AC_PROG_CC
64 AC_PROG_CPP
65 AC_PROG_RANLIB
66 AC_PROG_INSTALL
67
68 AC_CHECK_FUNCS(poll)
69 ADNS_C_GETFUNC(socket,socket)
70 ADNS_C_GETFUNC(inet_ntoa,nsl)
71
72 PROGS_IF_TSEARCH=adnsresfilter
73 AC_SUBST(PROGS_HAVE_TSEARCH)
74 AC_CHECK_FUNC(tsearch,[
75  PROGS_HAVE_TSEARCH=$PROGS_IF_TSEARCH
76 ],[
77  PROGS_HAVE_TSEARCH='';
78  AC_MSG_WARN([tsearch missing - not building client program(s) $PROGS_IF_TSEARCH])
79 ])
80
81 AC_MSG_CHECKING(for INADDR_LOOPBACK)
82 AC_CACHE_VAL(adns_cv_decl_inaddrloopback,[
83  AC_TRY_COMPILE([
84 #include <sys/socket.h>
85 #include <netinet/in.h>
86 #include <arpa/inet.h>
87  ],[
88   INADDR_LOOPBACK;
89  ],
90  adns_cv_decl_inaddrloopback=yes,
91  adns_cv_decl_inaddrloopback=no)])
92 if test "$adns_cv_decl_inaddrloopback" = yes; then
93  AC_MSG_RESULT(found)
94 else
95  AC_MSG_RESULT([not in standard headers, urgh...])
96  AC_CHECK_HEADER(rpc/types.h,[
97   AC_DEFINE(HAVEUSE_RPCTYPES_H)
98  ],[
99   AC_MSG_ERROR([cannot find INADDR_LOOPBACK or rpc/types.h])
100  ])
101 fi
102
103 ADNS_C_GETFUNC(inet_aton,resolv,[
104  LIBS="-lresolv $LIBS";
105  AC_MSG_WARN([inet_aton is in libresolv, urgh.  Must use -lresolv.])
106 ])
107
108 DPKG_CACHED_TRY_COMPILE(inlines,dpkg_cv_c_inline,,
109  [} inline int foo (int x) {],
110  AC_MSG_RESULT(yes)
111  AC_DEFINE(HAVE_INLINE),
112  AC_MSG_RESULT(no))
113
114 AC_SUBST(WARNS)
115
116 if test "${GCC-no}" = yes; then
117         WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
118         saved_cflags="$CFLAGS"
119         CFLAGS="$CFLAGS -Wno-pointer-sign"
120         DPKG_CACHED_TRY_COMPILE(-Wno-pointer-sign,adns_cv_c_wnoptrsign,,
121          [],
122          AC_MSG_RESULT(yes)
123          WARNS="$WARNS -Wno-pointer-sign",
124          AC_MSG_RESULT(no))
125         CFLAGS="$saved_cflags"
126 else
127         WARNS=
128 fi
129
130 ADNS_C_GCCATTRIB
131
132 AC_SUBST(SHLIBCC)
133 AC_SUBST(MKSHLIB_1)
134 AC_SUBST(MKSHLIB_2)
135 AC_SUBST(MKSHLIB_3)
136
137 AC_SUBST(SHLIBFORLINK)
138 AC_SUBST(SHLIBFILE)
139 AC_SUBST(SHLIBSONAME)
140
141 SHLIBFORLINK='libadns.so'
142 SHLIBSONAME='$(SHLIBFORLINK).$(MAJOR)'
143 SHLIBFILE='$(SHLIBSONAME).$(MINOR)'
144
145 SHLIBCC='$(CC) $(CFLAGS) -fpic'
146 MKSHLIB_1='$(CC) $(LDFLAGS) -shared -Wl,-soname=$(SHLIBSONAME) -o'
147 MKSHLIB_2=''
148 MKSHLIB_3='-lc'
149
150 AC_OUTPUT(
151         settings.make Makefile
152         src/Makefile client/Makefile dynamic/Makefile regress/Makefile
153 )