2 # Process this file with autoconf to produce a configure script.
4 # This file is part of catta.
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.
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.
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
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])
28 AC_SUBST(PACKAGE_URL, [http://github.com/everbase/catta/])
30 AC_SUBST(LIBCATTA_VERSION_INFO, [0:0:0])
34 AM_SILENT_RULES([yes])
36 AC_CHECK_PROG([STOW], [stow], [yes], [no])
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}"
43 # Checks for programs.
47 AC_USE_SYSTEM_EXTENSIONS
52 AC_PROG_GCC_TRADITIONAL
54 if test x"$ac_cv_prog_cc_c99" = x"no"; then
55 AC_MSG_ERROR([C99 support is required])
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"
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]),
67 [[#include <netinet/in.h>]])
70 AC_CHECK_DECL(__APPLE__)
71 AM_CONDITIONAL([APPLE], [ test "x$ac_cv_have_decl___APPLE__" = "xyes" ])
72 if test "x$ac_cv_have_decl___APPLE__" = "xyes" ; then
73 CPPFLAGS="$CPPFLAGS -I`pwd`/src/compat/ios/include"
77 AC_ARG_ENABLE([stack-protector],
78 [AS_HELP_STRING([--disable-stack-protector],
79 [Disable GCC's/libc's stack-smashing protection])],
80 [case "${enableval}" in
81 yes) enable_ssp=yes ;;
83 *) AC_MSG_ERROR([invalid value ${enableval} for --disable-stack-protector]) ;;
87 if test x"$enable_ssp" = x"yes" && test x"$GCC" != x"yes"; then
88 AC_MSG_NOTICE([Disabling stack-smashing protection because compiler is not GCC])
92 if test x"$enable_ssp" = x"yes"; then
93 # Check for broken ssp in libc: http://www.avahi.org/ticket/105
94 # libc's brokenness will get in the way regardless of whether -lssp is
95 # provided, but provide it anyway (otherwise non-libc ssp would wrongly
98 # Get -lssp if it exists
101 AC_MSG_CHECKING([whether stack-smashing protection is available])
102 ssp_old_cflags="$CFLAGS"
103 ssp_old_ldflags="$LDFLAGS"
104 CFLAGS="$CFLAGS -Werror -fstack-protector-all -fPIC"
105 LDFLAGS="$LDFLAGS -Wl,-z,defs"
106 cat confdefs.h > conftest.c
107 cat >>conftest.c <<_ACEOF
108 void test_broken_ssp(c)
111 char arr[[123]], *p; /* beware of possible double-braces if copying this */
112 for (p = arr; *c; ++p) {
120 if $CC -c $CFLAGS $CPPFLAGS -o conftest.o conftest.c >/dev/null 2>&1; then
122 AC_MSG_CHECKING([whether stack-smashing protection is buggy])
123 if $CC -o conftest.so $LDFLAGS -shared conftest.o $LIBS >/dev/null 2>&1; then
133 rm -f conftest.c conftest.o conftest.so
135 CFLAGS="$ssp_old_cflags"
136 LDFLAGS="$ssp_old_ldflags"
139 if test x"$enable_ssp" = x"yes"; then
140 # Do this the long way so we don't call GCC_STACK_PROTECT_LIB twice
147 ACX_PTHREAD(,AC_MSG_ERROR([Missing POSIX Threads support]))
150 # Check for netlink.h
152 AC_CHECK_HEADER(linux/netlink.h,
154 AC_DEFINE([HAVE_NETLINK],[],[Support for Linux netlink])
156 #include <sys/socket.h>
157 #include <asm/types.h>
160 AM_CONDITIONAL(HAVE_NETLINK, [ test x"$HAVE_NETLINK" = xyes ])
162 if test "x$HAVE_NETLINK" = "xyes" ; then
163 # Test whether rtnetlink.h can be included when compiled with -std=c99
164 # some distributions (e.g. archlinux) have broken headers that dont
165 # define __u64 with -std=c99
166 AC_MSG_CHECKING([checking whether rtnetlink.h can be included with -std=c99])
167 AC_TRY_COMPILE([#include <linux/rtnetlink.h>], [],
168 [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no])])
172 # Check for net/route.h
174 AC_CHECK_HEADER(net/route.h,
176 AC_DEFINE([HAVE_PF_ROUTE],[],[Support for PF_ROUTE])
178 #include <sys/types.h>
179 #include <sys/socket.h>
180 #include <net/if_dl.h>
183 AM_CONDITIONAL(HAVE_PF_ROUTE, [ test x"$HAVE_PF_ROUTE" = xyes ])
186 # Check for sys/filio.h; needed for FIONREAD on Solaris
188 AC_CHECK_HEADER(sys/filio.h,
190 AC_DEFINE([HAVE_SYS_FILIO_H],[],[Support for sys/filio.h])
194 AM_CONDITIONAL(HAVE_SYS_FILIO_H, [ test x"$HAVE_SYS_FILIO_H" = xyes ])
197 # Check for sys/sysctl.h; not present on Solaris
199 AC_CHECK_HEADER(sys/sysctl.h,
201 AC_DEFINE([HAVE_SYS_SYSCTL_H],[],[Support for sys/sysctl.h])
203 #include <sys/types.h>
204 #include <sys/socket.h>
205 #include <sys/param.h>
208 AM_CONDITIONAL(HAVE_SYS_SYSCTL_H, [ test x"$HAVE_SYS_SYSCTL_H" = xyes ])
211 # Check for lifconf struct; only present on Solaris
213 AC_MSG_CHECKING(for struct lifconf)
214 AC_CACHE_VAL(catta_cv_has_struct_lifconf,
216 [#include <sys/socket.h>
218 ],[sizeof (struct lifconf);],
219 catta_cv_has_struct_lifconf=yes,catta_cv_has_struct_lifconf=no)])
220 AC_MSG_RESULT($catta_cv_has_struct_lifconf)
221 if test $catta_cv_has_struct_lifconf = yes; then
222 AC_DEFINE(HAVE_STRUCT_LIFCONF,1,[Define if there is a struct lifconf.])
226 # Check for struct ip_mreqn
228 AC_MSG_CHECKING(for struct ip_mreqn)
229 AC_TRY_COMPILE([#include <netinet/in.h>], [
230 struct ip_mreqn mreq;
231 mreq.imr_address.s_addr = 0;
235 AC_DEFINE([HAVE_STRUCT_IP_MREQN],[],[Support for struct ip_mreqn])
237 # We'll just have to try and use struct ip_mreq
239 AC_MSG_CHECKING(for struct ip_mreq)
240 AC_TRY_COMPILE([#include <netinet/in.h>], [
242 mreq.imr_interface.s_addr = 0;
246 AC_DEFINE([HAVE_STRUCT_IP_MREQ],[],[Support for struct ip_mreq])
248 # No multicast support
254 AC_LANG_CONFTEST([AC_LANG_SOURCE([[int main() {}]])])
255 $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
261 # If using GCC specify some additional parameters
262 if test "x$GCC" = "xyes" ; then
264 DESIRED_FLAGS="-Wall -W -Wextra -pedantic -pipe -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wshadow -Wbad-function-cast -Wwrite-strings -fdiagnostics-show-option -fno-strict-aliasing"
266 # when compiling for MingW, -Wmissing-noreturn is triggered a bunch of
267 # times from autogenerated libtool wrappers, so leave it out on Windows.
268 if test "x$ac_cv_have_decl__WIN32" != "xyes" ; then
269 DESIRED_FLAGS="$DESIRED_FLAGS -Wmissing-noreturn"
272 for flag in $DESIRED_FLAGS ; do
273 AC_MSG_CHECKING([whether $CC accepts $flag])
274 if test_gcc_flag $flag ; then
275 CFLAGS="$CFLAGS $flag"
283 # Checks for header files.
284 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h sys/ioctl.h sys/socket.h sys/time.h unistd.h])
287 AC_SEARCH_LIBS([inet_ntop],[nsl])
288 AC_SEARCH_LIBS([recv],[socket])
289 AC_CHECK_DECL([CMSG_SPACE],,CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500 -D__EXTENSIONS__", [[#include <sys/socket.h>]])
291 # Checks for library functions.
292 AC_FUNC_SELECT_ARGTYPES
293 AC_CHECK_FUNCS([gethostname select socket uname strcasecmp gettimeofday strncasecmp strlcpy fcntl])
300 AC_CHECK_DECLS(environ)
302 # check if gcc's -fvisibility is supported
303 CHECK_VISIBILITY_HIDDEN
305 # Check for pkg-config manually first, as if its not installed the
306 # PKG_PROG_PKG_CONFIG macro won't be defined.
307 AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
309 if test x"$have_pkg_config" = "xno"; then
310 AC_MSG_ERROR(pkg-config is required to install this program)
326 DX_INIT_DOXYGEN(catta, doxygen.cfg, doxygen)
329 # Conditionally compile test and example programs
332 AS_HELP_STRING([--enable-tests],[Enable building of tests and examples]),
333 [case "${enableval}" in
334 yes) ENABLE_TESTS=yes ;;
335 no) ENABLE_TESTS=no ;;
336 *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;;
340 AM_CONDITIONAL([ENABLE_TESTS], [test "x$ENABLE_TESTS" = "xyes"])
342 # ==========================================================================
352 # ==========================================================================
354 ---{ $PACKAGE_NAME $VERSION }---
357 sysconfdir: ${sysconfdir}
358 localstatedir: ${localstatedir}
361 Enable stack-smashing protection: ${enable_ssp}
362 Building tests: ${ENABLE_TESTS}