changelog, etc.: Finalise 1.5.1.
[adns] / 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,2014-2016 Ian Jackson
5 # Copyright (C) 2014 Mark Wooding
6 # Copyright (C) 1999-2000,2003,2006 Tony Finch
7 # Copyright (C) 1991 Massachusetts Institute of Technology
8 # (See the file INSTALL for full details.)
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3, or (at your option)
13 # any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software Foundation.
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 common.make settings.make Makefile
152 src/Makefile client/Makefile dynamic/Makefile regress/Makefile
153 )