chiark / gitweb /
Fix typo in changelog entry for 1.6.1
[adns.git] / configure.in
1 # configure.in - input to autoconf
2 #  
3 #  This file is part of adns, which is Copyright Ian Jackson
4 #  and contributors (see the file INSTALL for full details).
5 #  
6 #  This program is free software; you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation; either version 3, or (at your option)
9 #  any later version.
10 #  
11 #  This program is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #  
16 #  You should have received a copy of the GNU General Public License
17 #  along with this program; if not, write to the Free Software Foundation.
18
19 AC_INIT(src/adns.h)
20 AC_CONFIG_HEADER(src/config.h)
21
22 dnl DPKG_CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>)
23 define([DPKG_CACHED_TRY_COMPILE],[
24  AC_MSG_CHECKING($1)
25  AC_CACHE_VAL($2,[
26   AC_TRY_COMPILE([$3],[$4],[$2=yes],[$2=no])
27  ])
28  if test "x$$2" = xyes; then
29   true
30   $5
31  else
32   true
33   $6
34  fi
35 ])
36
37 AC_MSG_CHECKING(whether you requested dynamic linking)
38 AC_SUBST(ENABLE_DYNAMIC)
39 AC_ARG_ENABLE(dynamic,
40 [  --disable-dynamic       use static linking
41   --enable-dynamic[=elf]  create and use ELF dynamic library (default)],
42 [       case "$enableval" in
43         elf|yes)
44                 ENABLE_DYNAMIC=elf
45                 AC_MSG_RESULT([yes (ELF)])
46                 ;;
47         no)     ENABLE_DYNAMIC=no
48                 AC_MSG_RESULT(no)
49                 ;;
50         *)      AC_MSG_ERROR(
51 ["invalid value $enableval for --enable-dynamic, try yes or elf"])
52                 ;;
53         esac
54 ],[
55                 ENABLE_DYNAMIC=elf
56                 AC_MSG_RESULT([yes, by default])
57 ])
58
59 AC_PROG_CC
60 AC_PROG_CPP
61 AC_PROG_RANLIB
62 AC_PROG_INSTALL
63
64 AC_CHECK_FUNCS(poll)
65 ADNS_C_GETFUNC(socket,socket)
66 ADNS_C_GETFUNC(inet_ntoa,nsl)
67
68 PROGS_IF_TSEARCH=adnsresfilter
69 AC_SUBST(PROGS_HAVE_TSEARCH)
70 AC_CHECK_FUNC(tsearch,[
71  PROGS_HAVE_TSEARCH=$PROGS_IF_TSEARCH
72 ],[
73  PROGS_HAVE_TSEARCH='';
74  AC_MSG_WARN([tsearch missing - not building client program(s) $PROGS_IF_TSEARCH])
75 ])
76
77 AC_MSG_CHECKING(for INADDR_LOOPBACK)
78 AC_CACHE_VAL(adns_cv_decl_inaddrloopback,[
79  AC_TRY_COMPILE([
80 #include <sys/socket.h>
81 #include <netinet/in.h>
82 #include <arpa/inet.h>
83  ],[
84   INADDR_LOOPBACK;
85  ],
86  adns_cv_decl_inaddrloopback=yes,
87  adns_cv_decl_inaddrloopback=no)])
88 if test "$adns_cv_decl_inaddrloopback" = yes; then
89  AC_MSG_RESULT(found)
90 else
91  AC_MSG_RESULT([not in standard headers, urgh...])
92  AC_CHECK_HEADER(rpc/types.h,[
93   AC_DEFINE(HAVEUSE_RPCTYPES_H)
94  ],[
95   AC_MSG_ERROR([cannot find INADDR_LOOPBACK or rpc/types.h])
96  ])
97 fi
98
99 ADNS_C_GETFUNC(inet_aton,resolv,[
100  LIBS="-lresolv $LIBS";
101  AC_MSG_WARN([inet_aton is in libresolv, urgh.  Must use -lresolv.])
102 ])
103
104 DPKG_CACHED_TRY_COMPILE(inlines,dpkg_cv_c_inline,,
105  [} inline int foo (int x) {],
106  AC_MSG_RESULT(yes)
107  AC_DEFINE(HAVE_INLINE),
108  AC_MSG_RESULT(no))
109
110 AC_SUBST(WARNS)
111
112 if test "${GCC-no}" = yes; then
113         WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
114         saved_cflags="$CFLAGS"
115         CFLAGS="$CFLAGS -Wno-pointer-sign"
116         DPKG_CACHED_TRY_COMPILE(-Wno-pointer-sign,adns_cv_c_wnoptrsign,,
117          [],
118          AC_MSG_RESULT(yes)
119          WARNS="$WARNS -Wno-pointer-sign",
120          AC_MSG_RESULT(no))
121         CFLAGS="$saved_cflags"
122 else
123         WARNS=
124 fi
125
126 ADNS_C_GCCATTRIB
127
128 AC_SUBST(SHLIBCC)
129 AC_SUBST(MKSHLIB_1)
130 AC_SUBST(MKSHLIB_2)
131 AC_SUBST(MKSHLIB_3)
132
133 AC_SUBST(SHLIBFORLINK)
134 AC_SUBST(SHLIBFILE)
135 AC_SUBST(SHLIBSONAME)
136
137 SHLIBFORLINK='libadns.so'
138 SHLIBSONAME='$(SHLIBFORLINK).$(MAJOR)'
139 SHLIBFILE='$(SHLIBSONAME).$(MINOR)'
140
141 SHLIBCC='$(CC) $(CFLAGS) -fpic'
142 MKSHLIB_1='$(CC) $(LDFLAGS) -shared -Wl,-soname=$(SHLIBSONAME) -o'
143 MKSHLIB_2=''
144 MKSHLIB_3='-lc'
145
146 AC_OUTPUT(
147         common.make settings.make Makefile
148         src/Makefile client/Makefile dynamic/Makefile regress/Makefile
149 )