]> git.meshlink.io Git - catta/blob - configure.ac
skeleton implementation of interface change event handling
[catta] / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 # This file is part of catta.
5 #
6 # catta is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation; either version 2 of the
9 # License, or (at your option) any later version.
10 #
11 # catta is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 # License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with catta; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 # USA.
20
21 AC_PREREQ(2.63)
22 AC_INIT([catta],[0.1],[])
23 AC_CONFIG_SRCDIR([src/server.c])
24 AC_CONFIG_MACRO_DIR([m4])
25 AC_CONFIG_HEADERS([config.h])
26 AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax subdir-objects])
27
28 AC_SUBST(PACKAGE_URL, [http://github.com/everbase/catta/])
29
30 AC_SUBST(LIBCATTA_VERSION_INFO, [0:0:0])
31
32 AC_CANONICAL_HOST
33
34 AM_SILENT_RULES([yes])
35
36 AC_CHECK_PROG([STOW], [stow], [yes], [no])
37
38 AS_IF([test "x$STOW" = "xyes" && test -d /usr/local/stow], [
39         AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
40         ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
41 ])
42
43 # Checks for programs.
44 AC_PROG_CC
45 AC_PROG_CC_C99
46 AM_PROG_CC_C_O
47 AC_USE_SYSTEM_EXTENSIONS
48 AC_PROG_MKDIR_P
49 AC_PROG_INSTALL
50 AC_PROG_LN_S
51 AC_PROG_MAKE_SET
52 AC_PROG_GCC_TRADITIONAL
53
54 if test x"$ac_cv_prog_cc_c99" = x"no"; then
55     AC_MSG_ERROR([C99 support is required])
56 fi
57
58 # Windows stuff
59 AC_CHECK_DECL(_WIN32)
60 AM_CONDITIONAL([WINDOWS], [ test "x$ac_cv_have_decl__WIN32" = "xyes" ])
61 if test "x$ac_cv_have_decl__WIN32" = "xyes" ; then
62     CPPFLAGS="$CPPFLAGS -I`pwd`/src/compat/windows/include"
63 fi
64 AC_CHECK_MEMBER([struct in_pktinfo.ipi_spec_dst],
65     AC_DEFINE([HAVE_IPI_SPEC_DST], [], [struct in_pktinfo has ipi_spec_dst member]),
66     [],
67     [[#include <netinet/in.h>]])
68
69 # -fstack-protector
70 AC_ARG_ENABLE([stack-protector],
71     [AS_HELP_STRING([--disable-stack-protector],
72         [Disable GCC's/libc's stack-smashing protection])],
73     [case "${enableval}" in
74          yes) enable_ssp=yes ;;
75           no) enable_ssp=no ;;
76            *) AC_MSG_ERROR([invalid value ${enableval} for --disable-stack-protector]) ;;
77      esac],
78     [enable_ssp=yes])
79
80 if test x"$enable_ssp" = x"yes" && test x"$GCC" != x"yes"; then
81     AC_MSG_NOTICE([Disabling stack-smashing protection because compiler is not GCC])
82     enable_ssp=no
83 fi
84
85 if test x"$enable_ssp" = x"yes"; then
86     # Check for broken ssp in libc: http://www.avahi.org/ticket/105
87     # libc's brokenness will get in the way regardless of whether -lssp is
88     # provided, but provide it anyway (otherwise non-libc ssp would wrongly
89     # break here)
90
91     # Get -lssp if it exists
92     GCC_STACK_PROTECT_LIB
93
94     AC_MSG_CHECKING([whether stack-smashing protection is available])
95     ssp_old_cflags="$CFLAGS"
96     ssp_old_ldflags="$LDFLAGS"
97     CFLAGS="$CFLAGS -Werror -fstack-protector-all -fPIC"
98     LDFLAGS="$LDFLAGS -Wl,-z,defs"
99     cat confdefs.h > conftest.c
100     cat >>conftest.c <<_ACEOF
101 void test_broken_ssp(c)
102     const char *c;
103 {
104     char arr[[123]], *p; /* beware of possible double-braces if copying this */
105     for (p = arr; *c; ++p) {
106         *p = *c;
107         ++c;
108     }
109 }
110 _ACEOF
111     rm -f conftest.o
112
113     if $CC -c $CFLAGS $CPPFLAGS -o conftest.o conftest.c >/dev/null 2>&1; then
114         AC_MSG_RESULT([yes])
115         AC_MSG_CHECKING([whether stack-smashing protection is buggy])
116         if $CC -o conftest.so $LDFLAGS -shared conftest.o $LIBS >/dev/null 2>&1; then
117             AC_MSG_RESULT([no])
118         else
119             AC_MSG_RESULT([yes])
120             enable_ssp=no
121         fi
122     else
123         AC_MSG_RESULT([no])
124     fi
125
126     rm -f conftest.c conftest.o conftest.so
127
128     CFLAGS="$ssp_old_cflags"
129     LDFLAGS="$ssp_old_ldflags"
130 fi
131
132 if test x"$enable_ssp" = x"yes"; then
133     # Do this the long way so we don't call GCC_STACK_PROTECT_LIB twice
134     GCC_STACK_PROTECT_CC
135 fi
136
137 # libtool stuff
138 LT_INIT([win32-dll])
139
140 ACX_PTHREAD(,AC_MSG_ERROR([Missing POSIX Threads support]))
141
142 #
143 # Check for netlink.h
144 #
145 AC_CHECK_HEADER(linux/netlink.h,
146 HAVE_NETLINK=yes
147 AC_DEFINE([HAVE_NETLINK],[],[Support for Linux netlink])
148 , [], [
149 #include <sys/socket.h>
150 #include <asm/types.h>
151 ])
152
153 AM_CONDITIONAL(HAVE_NETLINK, [ test x"$HAVE_NETLINK" = xyes ])
154
155 if test "x$HAVE_NETLINK" = "xyes" ; then
156     # Test whether rtnetlink.h can be included when compiled with -std=c99
157     # some distributions (e.g. archlinux) have broken headers that dont
158     # define __u64 with -std=c99
159     AC_MSG_CHECKING([checking whether rtnetlink.h can be included with -std=c99])
160     AC_TRY_COMPILE([#include <linux/rtnetlink.h>], [],
161         [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no])])
162 fi
163
164 #
165 # Check for net/route.h
166 #
167 AC_CHECK_HEADER(net/route.h,
168 HAVE_PF_ROUTE=yes
169 AC_DEFINE([HAVE_PF_ROUTE],[],[Support for PF_ROUTE])
170 , [], [
171 #include <sys/types.h>
172 #include <sys/socket.h>
173 #include <net/if_dl.h>
174 ])
175
176 AM_CONDITIONAL(HAVE_PF_ROUTE, [ test x"$HAVE_PF_ROUTE" = xyes ])
177
178 #
179 # Check for sys/filio.h; needed for FIONREAD on Solaris
180 #
181 AC_CHECK_HEADER(sys/filio.h,
182 HAVE_SYS_FILIO_H=yes
183 AC_DEFINE([HAVE_SYS_FILIO_H],[],[Support for sys/filio.h])
184 , [], [
185 ])
186
187 AM_CONDITIONAL(HAVE_SYS_FILIO_H, [ test x"$HAVE_SYS_FILIO_H" = xyes ])
188
189 #
190 # Check for sys/sysctl.h; not present on Solaris
191 #
192 AC_CHECK_HEADER(sys/sysctl.h,
193 HAVE_SYS_SYSCTL=yes
194 AC_DEFINE([HAVE_SYS_SYSCTL_H],[],[Support for sys/sysctl.h])
195 , [], [
196 #include <sys/types.h>
197 #include <sys/socket.h>
198 #include <sys/param.h>
199 ])
200
201 AM_CONDITIONAL(HAVE_SYS_SYSCTL_H, [ test x"$HAVE_SYS_SYSCTL_H" = xyes ])
202
203 #
204 # Check for lifconf struct; only present on Solaris
205 #
206 AC_MSG_CHECKING(for struct lifconf)
207 AC_CACHE_VAL(catta_cv_has_struct_lifconf,
208 [AC_TRY_COMPILE(
209 [#include <sys/socket.h>
210 #include <net/if.h>
211 ],[sizeof (struct lifconf);],
212 catta_cv_has_struct_lifconf=yes,catta_cv_has_struct_lifconf=no)])
213 AC_MSG_RESULT($catta_cv_has_struct_lifconf)
214 if test $catta_cv_has_struct_lifconf = yes; then
215     AC_DEFINE(HAVE_STRUCT_LIFCONF,1,[Define if there is a struct lifconf.])
216 fi
217
218 #
219 # Check for struct ip_mreqn
220 #
221 AC_MSG_CHECKING(for struct ip_mreqn)
222 AC_TRY_COMPILE([#include <netinet/in.h>], [
223         struct ip_mreqn mreq;
224         mreq.imr_address.s_addr = 0;
225 ], [
226         # Yes, we have it...
227         AC_MSG_RESULT(yes)
228         AC_DEFINE([HAVE_STRUCT_IP_MREQN],[],[Support for struct ip_mreqn])
229 ], [
230         # We'll just have to try and use struct ip_mreq
231         AC_MSG_RESULT(no)
232         AC_MSG_CHECKING(for struct ip_mreq)
233         AC_TRY_COMPILE([#include <netinet/in.h>], [
234                 struct ip_mreq mreq;
235                 mreq.imr_interface.s_addr = 0;
236         ], [
237                 # Yes, we have it...
238                 AC_MSG_RESULT(yes)
239                 AC_DEFINE([HAVE_STRUCT_IP_MREQ],[],[Support for struct ip_mreq])
240         ], [
241                 # No multicast support
242                         AC_MSG_RESULT(no)
243         ])
244 ])
245
246 test_gcc_flag() {
247     AC_LANG_CONFTEST([AC_LANG_SOURCE([[int main() {}]])])
248     $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
249     ret=$?
250     rm -f conftest.o
251     return $ret
252 }
253
254 # If using GCC specify some additional parameters
255 if test "x$GCC" = "xyes" ; then
256
257     DESIRED_FLAGS="-Wall -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -fdiagnostics-show-option -Wno-cast-qual -fno-strict-aliasing"
258
259     for flag in $DESIRED_FLAGS ; do
260         AC_MSG_CHECKING([whether $CC accepts $flag])
261         if test_gcc_flag $flag ; then
262            CFLAGS="$CFLAGS $flag"
263            AC_MSG_RESULT([yes])
264         else
265            AC_MSG_RESULT([no])
266         fi
267     done
268 fi
269
270 # Checks for header files.
271 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h sys/ioctl.h sys/socket.h sys/time.h unistd.h])
272
273  # Solaris stuff
274  AC_SEARCH_LIBS([inet_ntop],[nsl])
275  AC_SEARCH_LIBS([recv],[socket])
276  AC_CHECK_DECL([CMSG_SPACE],,CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500 -D__EXTENSIONS__", [[#include <sys/socket.h>]])
277
278 # Checks for library functions.
279 AC_FUNC_SELECT_ARGTYPES
280 AC_CHECK_FUNCS([gethostname select socket uname strcasecmp gettimeofday strncasecmp strlcpy fcntl])
281
282 AC_FUNC_CHOWN
283 AC_FUNC_STAT
284 AC_TYPE_MODE_T
285 AC_TYPE_PID_T
286
287 AC_CHECK_DECLS(environ)
288
289 # check if gcc's -fvisibility is supported
290 CHECK_VISIBILITY_HIDDEN
291
292 # Check for pkg-config manually first, as if its not installed the
293 # PKG_PROG_PKG_CONFIG macro won't be defined.
294 AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
295
296 if test x"$have_pkg_config" = "xno"; then
297     AC_MSG_ERROR(pkg-config is required to install this program)
298 fi
299
300 PKG_PROG_PKG_CONFIG
301
302 #
303 # Doxygen
304 #
305 DX_HTML_FEATURE(ON)
306 DX_CHM_FEATURE(OFF)
307 DX_CHI_FEATURE(OFF)
308 DX_MAN_FEATURE(OFF)
309 DX_RTF_FEATURE(OFF)
310 DX_XML_FEATURE(ON)
311 DX_PDF_FEATURE(OFF)
312 DX_PS_FEATURE(OFF)
313 DX_INIT_DOXYGEN(catta, doxygen.cfg, doxygen)
314
315 #
316 # Conditionally compile test and example programs
317 #
318 AC_ARG_ENABLE(tests,
319         AS_HELP_STRING([--enable-tests],[Enable building of tests and examples]),
320         [case "${enableval}" in
321                 yes) ENABLE_TESTS=yes ;;
322                 no)  ENABLE_TESTS=no ;;
323                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;;
324         esac],
325         [ENABLE_TESTS=no])
326
327 AM_CONDITIONAL([ENABLE_TESTS], [test "x$ENABLE_TESTS" = "xyes"])
328
329 # ==========================================================================
330 AC_CONFIG_FILES([
331 Makefile
332 src/Makefile
333 include/Makefile
334 tests/Makefile
335 examples/Makefile
336 m4/Makefile
337 ])
338 AC_OUTPUT
339
340 # ==========================================================================
341 echo "
342  ---{ $PACKAGE_NAME $VERSION }---
343
344     prefix:                             ${prefix}
345     sysconfdir:                         ${sysconfdir}
346     localstatedir:                      ${localstatedir}
347     C Compiler:                         ${CC}
348     CFLAGS:                             ${CFLAGS}
349     Enable stack-smashing protection:   ${enable_ssp}
350     Building tests:                     ${ENABLE_TESTS}
351 "