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