chiark / gitweb /
3eaf00fc11ce9c5d04f5707c9bcb1d907ab6bd93
[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 3, 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
22 AC_INIT(src/adns.h)
23 AC_CONFIG_HEADER(src/config.h)
24
25 dnl DPKG_CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>)
26 define([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 AC_CHECK_FUNCS(poll)
68 ADNS_C_GETFUNC(socket,socket)
69 ADNS_C_GETFUNC(inet_ntoa,nsl)
70
71 PROGS_IF_TSEARCH=adnsresfilter
72 AC_SUBST(PROGS_HAVE_TSEARCH)
73 AC_CHECK_FUNC(tsearch,[
74  PROGS_HAVE_TSEARCH=$PROGS_IF_TSEARCH
75 ],[
76  PROGS_HAVE_TSEARCH='';
77  AC_MSG_WARN([tsearch missing - not building client program(s) $PROGS_IF_TSEARCH])
78 ])
79
80 AC_MSG_CHECKING(for INADDR_LOOPBACK)
81 AC_CACHE_VAL(adns_cv_decl_inaddrloopback,[
82  AC_TRY_COMPILE([
83 #include <sys/socket.h>
84 #include <netinet/in.h>
85 #include <arpa/inet.h>
86  ],[
87   INADDR_LOOPBACK;
88  ],
89  adns_cv_decl_inaddrloopback=yes,
90  adns_cv_decl_inaddrloopback=no)])
91 if test "$adns_cv_decl_inaddrloopback" = yes; then
92  AC_MSG_RESULT(found)
93 else
94  AC_MSG_RESULT([not in standard headers, urgh...])
95  AC_CHECK_HEADER(rpc/types.h,[
96   AC_DEFINE(HAVEUSE_RPCTYPES_H)
97  ],[
98   AC_MSG_ERROR([cannot find INADDR_LOOPBACK or rpc/types.h])
99  ])
100 fi
101
102 ADNS_C_GETFUNC(inet_aton,resolv,[
103  LIBS="-lresolv $LIBS";
104  AC_MSG_WARN([inet_aton is in libresolv, urgh.  Must use -lresolv.])
105 ])
106
107 DPKG_CACHED_TRY_COMPILE(inlines,dpkg_cv_c_inline,,
108  [} inline int foo (int x) {],
109  AC_MSG_RESULT(yes)
110  AC_DEFINE(HAVE_INLINE),
111  AC_MSG_RESULT(no))
112
113 AC_SUBST(WARNS)
114
115 if test "${GCC-no}" = yes; then
116         WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
117         saved_cflags="$CFLAGS"
118         CFLAGS="$CFLAGS -Wno-pointer-sign"
119         DPKG_CACHED_TRY_COMPILE(-Wno-pointer-sign,adns_cv_c_wnoptrsign,,
120          [],
121          AC_MSG_RESULT(yes)
122          WARNS="$WARNS -Wno-pointer-sign",
123          AC_MSG_RESULT(no))
124         CFLAGS="$saved_cflags"
125 else
126         WARNS=
127 fi
128
129 ADNS_C_GCCATTRIB
130
131 AC_SUBST(SHLIBCC)
132 AC_SUBST(MKSHLIB_1)
133 AC_SUBST(MKSHLIB_2)
134 AC_SUBST(MKSHLIB_3)
135
136 AC_SUBST(SHLIBFORLINK)
137 AC_SUBST(SHLIBFILE)
138 AC_SUBST(SHLIBSONAME)
139
140 SHLIBFORLINK='libadns.so'
141 SHLIBSONAME='$(SHLIBFORLINK).$(MAJOR)'
142 SHLIBFILE='$(SHLIBSONAME).$(MINOR)'
143
144 SHLIBCC='$(CC) $(CFLAGS) -fpic'
145 MKSHLIB_1='$(CC) $(LDFLAGS) -shared -Wl,-soname=$(SHLIBSONAME) -o'
146 MKSHLIB_2=''
147 MKSHLIB_3='-lc'
148
149 AC_OUTPUT(
150         settings.make Makefile
151         src/Makefile client/Makefile dynamic/Makefile regress/Makefile
152 )