]> git.meshlink.io Git - catta/blob - configure.ac
Windows does not support in_pktinfo.ipi_spec_dst
[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 AC_CHECK_MEMBER([struct in_pktinfo.ipi_spec_dst],
62     AC_DEFINE([HAVE_IPI_SPEC_DST], [], [struct in_pktinfo has ipi_spec_dst member]),
63     [],
64     [[#include <ws2tcpip.h>]])
65
66 # -fstack-protector
67 AC_ARG_ENABLE([stack-protector],
68     [AS_HELP_STRING([--disable-stack-protector],
69         [Disable GCC's/libc's stack-smashing protection])],
70     [case "${enableval}" in
71          yes) enable_ssp=yes ;;
72           no) enable_ssp=no ;;
73            *) AC_MSG_ERROR([invalid value ${enableval} for --disable-stack-protector]) ;;
74      esac],
75     [enable_ssp=yes])
76
77 if test x"$enable_ssp" = x"yes" && test x"$GCC" != x"yes"; then
78     AC_MSG_NOTICE([Disabling stack-smashing protection because compiler is not GCC])
79     enable_ssp=no
80 fi
81
82 if test x"$enable_ssp" = x"yes"; then
83     # Check for broken ssp in libc: http://www.avahi.org/ticket/105
84     # libc's brokenness will get in the way regardless of whether -lssp is
85     # provided, but provide it anyway (otherwise non-libc ssp would wrongly
86     # break here)
87
88     # Get -lssp if it exists
89     GCC_STACK_PROTECT_LIB
90
91     AC_MSG_CHECKING([whether stack-smashing protection is available])
92     ssp_old_cflags="$CFLAGS"
93     ssp_old_ldflags="$LDFLAGS"
94     CFLAGS="$CFLAGS -Werror -fstack-protector-all -fPIC"
95     LDFLAGS="$LDFLAGS -Wl,-z,defs"
96     cat confdefs.h > conftest.c
97     cat >>conftest.c <<_ACEOF
98 void test_broken_ssp(c)
99     const char *c;
100 {
101     char arr[[123]], *p; /* beware of possible double-braces if copying this */
102     for (p = arr; *c; ++p) {
103         *p = *c;
104         ++c;
105     }
106 }
107 _ACEOF
108     rm -f conftest.o
109
110     if $CC -c $CFLAGS $CPPFLAGS -o conftest.o conftest.c >/dev/null 2>&1; then
111         AC_MSG_RESULT([yes])
112         AC_MSG_CHECKING([whether stack-smashing protection is buggy])
113         if $CC -o conftest.so $LDFLAGS -shared conftest.o $LIBS >/dev/null 2>&1; then
114             AC_MSG_RESULT([no])
115         else
116             AC_MSG_RESULT([yes])
117             enable_ssp=no
118         fi
119     else
120         AC_MSG_RESULT([no])
121     fi
122
123     rm -f conftest.c conftest.o conftest.so
124
125     CFLAGS="$ssp_old_cflags"
126     LDFLAGS="$ssp_old_ldflags"
127 fi
128
129 if test x"$enable_ssp" = x"yes"; then
130     # Do this the long way so we don't call GCC_STACK_PROTECT_LIB twice
131     GCC_STACK_PROTECT_CC
132
133     AC_LANG_PUSH([C++])
134     GCC_STACK_PROTECT_CXX
135     AC_LANG_POP([C++])
136     # XXX: Update the enable_ssp value now for output later?
137 fi
138
139 # libtool stuff
140 AC_PROG_LIBTOOL
141
142 ACX_PTHREAD(,AC_MSG_ERROR([Missing POSIX Threads support]))
143
144 #
145 # Check for netlink.h
146 #
147 AC_CHECK_HEADER(linux/netlink.h,
148 HAVE_NETLINK=yes
149 AC_DEFINE([HAVE_NETLINK],[],[Support for Linux netlink])
150 , [], [
151 #include <sys/socket.h>
152 #include <asm/types.h>
153 ])
154
155 AM_CONDITIONAL(HAVE_NETLINK, [ test x"$HAVE_NETLINK" = xyes ])
156
157 if test "x$HAVE_NETLINK" = "xyes" ; then
158     # Test whether rtnetlink.h can be included when compiled with -std=c99
159     # some distributions (e.g. archlinux) have broken headers that dont
160     # define __u64 with -std=c99
161     AC_MSG_CHECKING([checking whether rtnetlink.h can be included with -std=c99])
162     AC_TRY_COMPILE([#include <linux/rtnetlink.h>], [],
163         [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no])])
164 fi
165
166 #
167 # Check for net/route.h
168 #
169 AC_CHECK_HEADER(net/route.h,
170 HAVE_PF_ROUTE=yes
171 AC_DEFINE([HAVE_PF_ROUTE],[],[Support for PF_ROUTE])
172 , [], [
173 #include <sys/types.h>
174 #include <sys/socket.h>
175 #include <net/if_dl.h>
176 ])
177
178 AM_CONDITIONAL(HAVE_PF_ROUTE, [ test x"$HAVE_PF_ROUTE" = xyes ])
179
180 #
181 # Check for sys/filio.h; needed for FIONREAD on Solaris
182 #
183 AC_CHECK_HEADER(sys/filio.h,
184 HAVE_SYS_FILIO_H=yes
185 AC_DEFINE([HAVE_SYS_FILIO_H],[],[Support for sys/filio.h])
186 , [], [
187 ])
188
189 AM_CONDITIONAL(HAVE_SYS_FILIO_H, [ test x"$HAVE_SYS_FILIO_H" = xyes ])
190
191 #
192 # Check for sys/sysctl.h; not present on Solaris
193 #
194 AC_CHECK_HEADER(sys/sysctl.h,
195 HAVE_SYS_SYSCTL=yes
196 AC_DEFINE([HAVE_SYS_SYSCTL_H],[],[Support for sys/sysctl.h])
197 , [], [
198 #include <sys/types.h>
199 #include <sys/socket.h>
200 #include <sys/param.h>
201 ])
202
203 AM_CONDITIONAL(HAVE_SYS_SYSCTL_H, [ test x"$HAVE_SYS_SYSCTL_H" = xyes ])
204
205 #
206 # Check for lifconf struct; only present on Solaris
207 #
208 AC_MSG_CHECKING(for struct lifconf)
209 AC_CACHE_VAL(catta_cv_has_struct_lifconf,
210 [AC_TRY_COMPILE(
211 [#include <sys/socket.h>
212 #include <net/if.h>
213 ],[sizeof (struct lifconf);],
214 catta_cv_has_struct_lifconf=yes,catta_cv_has_struct_lifconf=no)])
215 AC_MSG_RESULT($catta_cv_has_struct_lifconf)
216 if test $catta_cv_has_struct_lifconf = yes; then
217     AC_DEFINE(HAVE_STRUCT_LIFCONF,1,[Define if there is a struct lifconf.])
218 fi
219
220 #
221 # Check for struct ip_mreqn
222 #
223 AC_MSG_CHECKING(for struct ip_mreqn)
224 AC_TRY_COMPILE([#include <netinet/in.h>], [
225         struct ip_mreqn mreq;
226         mreq.imr_address.s_addr = 0;
227 ], [
228         # Yes, we have it...
229         AC_MSG_RESULT(yes)
230         AC_DEFINE([HAVE_STRUCT_IP_MREQN],[],[Support for struct ip_mreqn])
231 ], [
232         # We'll just have to try and use struct ip_mreq
233         AC_MSG_RESULT(no)
234         AC_MSG_CHECKING(for struct ip_mreq)
235         AC_TRY_COMPILE([#include <netinet/in.h>], [
236                 struct ip_mreq mreq;
237                 mreq.imr_interface.s_addr = 0;
238         ], [
239                 # Yes, we have it...
240                 AC_MSG_RESULT(yes)
241                 AC_DEFINE([HAVE_STRUCT_IP_MREQ],[],[Support for struct ip_mreq])
242         ], [
243                 # No multicast support
244                         AC_MSG_RESULT(no)
245         ])
246 ])
247
248 test_gcc_flag() {
249     AC_LANG_CONFTEST([AC_LANG_SOURCE([[int main() {}]])])
250     $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
251     ret=$?
252     rm -f conftest.o
253     return $ret
254 }
255
256 # If using GCC specify some additional parameters
257 if test "x$GCC" = "xyes" ; then
258
259     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"
260
261     for flag in $DESIRED_FLAGS ; do
262         AC_MSG_CHECKING([whether $CC accepts $flag])
263         if test_gcc_flag $flag ; then
264            CFLAGS="$CFLAGS $flag"
265            AC_MSG_RESULT([yes])
266         else
267            AC_MSG_RESULT([no])
268         fi
269     done
270 fi
271
272 # Checks for header files.
273 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h sys/ioctl.h sys/socket.h sys/time.h unistd.h])
274
275  # Solaris stuff
276  AC_SEARCH_LIBS([inet_ntop],[nsl])
277  AC_SEARCH_LIBS([recv],[socket])
278  AC_CHECK_DECL([CMSG_SPACE],,CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500 -D__EXTENSIONS__", [[#include <sys/socket.h>]])
279
280 # Checks for library functions.
281 AC_FUNC_SELECT_ARGTYPES
282 AC_CHECK_FUNCS([gethostname select socket uname strcasecmp gettimeofday strncasecmp strlcpy])
283
284 AC_FUNC_CHOWN
285 AC_FUNC_STAT
286 AC_TYPE_MODE_T
287 AC_TYPE_PID_T
288
289 AC_CHECK_DECLS(environ)
290
291 # check if gcc's -fvisibility is supported
292 CHECK_VISIBILITY_HIDDEN
293
294 # Check for pkg-config manually first, as if its not installed the
295 # PKG_PROG_PKG_CONFIG macro won't be defined.
296 AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
297
298 if test x"$have_pkg_config" = "xno"; then
299     AC_MSG_ERROR(pkg-config is required to install this program)
300 fi
301
302 PKG_PROG_PKG_CONFIG
303
304 #
305 # Doxygen
306 #
307 DX_HTML_FEATURE(ON)
308 DX_CHM_FEATURE(OFF)
309 DX_CHI_FEATURE(OFF)
310 DX_MAN_FEATURE(OFF)
311 DX_RTF_FEATURE(OFF)
312 DX_XML_FEATURE(ON)
313 DX_PDF_FEATURE(OFF)
314 DX_PS_FEATURE(OFF)
315 DX_INIT_DOXYGEN(catta, doxygen.cfg, doxygen)
316
317 #
318 # Conditionally compile test and example programs
319 #
320 AC_ARG_ENABLE(tests,
321         AS_HELP_STRING([--enable-tests],[Enable building of tests and examples]),
322         [case "${enableval}" in
323                 yes) ENABLE_TESTS=yes ;;
324                 no)  ENABLE_TESTS=no ;;
325                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;;
326         esac],
327         [ENABLE_TESTS=no])
328
329 AM_CONDITIONAL([ENABLE_TESTS], [test "x$ENABLE_TESTS" = "xyes"])
330
331 # ==========================================================================
332 AC_CONFIG_FILES([
333 Makefile
334 src/Makefile
335 include/Makefile
336 tests/Makefile
337 examples/Makefile
338 m4/Makefile
339 ])
340 AC_OUTPUT
341
342 # ==========================================================================
343 echo "
344  ---{ $PACKAGE_NAME $VERSION }---
345
346     prefix:                             ${prefix}
347     sysconfdir:                         ${sysconfdir}
348     localstatedir:                      ${localstatedir}
349     C Compiler:                         ${CC}
350     CFLAGS:                             ${CFLAGS}
351     Enable stack-smashing protection:   ${enable_ssp}
352     Building tests:                     ${ENABLE_TESTS}
353 "