]> git.meshlink.io Git - catta/blob - configure.ac
move the rtnetlink.h/C99 check and always fail configure if it fails
[catta] / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 # This file is part of avahi.
5 #
6 # avahi 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 # avahi 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 avahi; 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([avahi],[0.6.31],[avahi (at) lists (dot) freedesktop (dot) org])
23 AC_CONFIG_SRCDIR([avahi-core/server.c])
24 AC_CONFIG_MACRO_DIR([common])
25 AC_CONFIG_HEADERS([config.h])
26 AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax])
27
28 AC_SUBST(PACKAGE_URL, [http://avahi.org/])
29
30 AC_SUBST(LIBAVAHI_COMMON_VERSION_INFO, [8:3:5])
31 AC_SUBST(LIBAVAHI_CORE_VERSION_INFO, [7:2:0])
32
33 AC_CANONICAL_HOST
34
35 AM_SILENT_RULES([yes])
36
37 AC_CHECK_PROG([STOW], [stow], [yes], [no])
38
39 AS_IF([test "x$STOW" = "xyes" && test -d /usr/local/stow], [
40         AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
41         ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
42 ])
43
44 # Checks for programs.
45 AC_PROG_CC
46 AC_PROG_CC_C99
47 AM_PROG_CC_C_O
48 AC_USE_SYSTEM_EXTENSIONS
49 AC_PROG_MKDIR_P
50 AC_PROG_INSTALL
51 AC_PROG_LN_S
52 AC_PROG_MAKE_SET
53 AC_PROG_GCC_TRADITIONAL
54
55 # -fstack-protector
56 AC_ARG_ENABLE([stack-protector],
57     [AS_HELP_STRING([--disable-stack-protector],
58         [Disable GCC's/libc's stack-smashing protection])],
59     [case "${enableval}" in
60          yes) enable_ssp=yes ;;
61           no) enable_ssp=no ;;
62            *) AC_MSG_ERROR([invalid value ${enableval} for --disable-stack-protector]) ;;
63      esac],
64     [enable_ssp=yes])
65
66 if test x"$enable_ssp" = x"yes" && test x"$GCC" != x"yes"; then
67     AC_MSG_NOTICE([Disabling stack-smashing protection because compiler is not GCC])
68     enable_ssp=no
69 fi
70
71 if test x"$enable_ssp" = x"yes"; then
72     # Check for broken ssp in libc: http://www.avahi.org/ticket/105
73     # libc's brokenness will get in the way regardless of whether -lssp is
74     # provided, but provide it anyway (otherwise non-libc ssp would wrongly
75     # break here)
76
77     # Get -lssp if it exists
78     GCC_STACK_PROTECT_LIB
79
80     AC_MSG_CHECKING([whether stack-smashing protection is available])
81     ssp_old_cflags="$CFLAGS"
82     ssp_old_ldflags="$LDFLAGS"
83     CFLAGS="$CFLAGS -Werror -fstack-protector-all -fPIC"
84     LDFLAGS="$LDFLAGS -Wl,-z,defs"
85     cat confdefs.h > conftest.c
86     cat >>conftest.c <<_ACEOF
87 void test_broken_ssp(c)
88     const char *c;
89 {
90     char arr[[123]], *p; /* beware of possible double-braces if copying this */
91     for (p = arr; *c; ++p) {
92         *p = *c;
93         ++c;
94     }
95 }
96 _ACEOF
97     rm -f conftest.o
98
99     if $CC -c $CFLAGS $CPPFLAGS -o conftest.o conftest.c >/dev/null 2>&1; then
100         AC_MSG_RESULT([yes])
101         AC_MSG_CHECKING([whether stack-smashing protection is buggy])
102         if $CC -o conftest.so $LDFLAGS -shared conftest.o $LIBS >/dev/null 2>&1; then
103             AC_MSG_RESULT([no])
104         else
105             AC_MSG_RESULT([yes])
106             enable_ssp=no
107         fi
108     else
109         AC_MSG_RESULT([no])
110     fi
111
112     rm -f conftest.c conftest.o conftest.so
113
114     CFLAGS="$ssp_old_cflags"
115     LDFLAGS="$ssp_old_ldflags"
116 fi
117
118 if test x"$enable_ssp" = x"yes"; then
119     # Do this the long way so we don't call GCC_STACK_PROTECT_LIB twice
120     GCC_STACK_PROTECT_CC
121
122     AC_LANG_PUSH([C++])
123     GCC_STACK_PROTECT_CXX
124     AC_LANG_POP([C++])
125     # XXX: Update the enable_ssp value now for output later?
126 fi
127
128 # libtool stuff
129 AC_PROG_LIBTOOL
130
131 ACX_PTHREAD(,AC_MSG_ERROR([Missing POSIX Threads support]))
132
133 #
134 # Check for netlink.h
135 #
136 AC_CHECK_HEADER(linux/netlink.h,
137 HAVE_NETLINK=yes
138 AC_DEFINE([HAVE_NETLINK],[],[Support for Linux netlink])
139 , [], [
140 #include <sys/socket.h>
141 #include <asm/types.h>
142 ])
143
144 AM_CONDITIONAL(HAVE_NETLINK, [ test x"$HAVE_NETLINK" = xyes ])
145
146 if test "x$HAVE_NETLINK" = "xyes" ; then
147     # Test whether rtnetlink.h can be included when compiled with -std=c99
148     # some distributions (e.g. archlinux) have broken headers that dont
149     # define __u64 with -std=c99
150     AC_MSG_CHECKING([checking whether rtnetlink.h can be included with -std=c99])
151     AC_TRY_COMPILE([#include <linux/rtnetlink.h>], [],
152         [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no])])
153 fi
154
155 #
156 # Check for net/route.h
157 #
158 AC_CHECK_HEADER(net/route.h,
159 HAVE_PF_ROUTE=yes
160 AC_DEFINE([HAVE_PF_ROUTE],[],[Support for PF_ROUTE])
161 , [], [
162 #include <sys/types.h>
163 #include <sys/socket.h>
164 #include <net/if_dl.h>
165 ])
166
167 AM_CONDITIONAL(HAVE_PF_ROUTE, [ test x"$HAVE_PF_ROUTE" = xyes ])
168
169 #
170 # Check for sys/filio.h; needed for FIONREAD on Solaris
171 #
172 AC_CHECK_HEADER(sys/filio.h,
173 HAVE_SYS_FILIO_H=yes
174 AC_DEFINE([HAVE_SYS_FILIO_H],[],[Support for sys/filio.h])
175 , [], [
176 ])
177
178 AM_CONDITIONAL(HAVE_SYS_FILIO_H, [ test x"$HAVE_SYS_FILIO_H" = xyes ])
179
180 #
181 # Check for sys/sysctl.h; not present on Solaris
182 #
183 AC_CHECK_HEADER(sys/sysctl.h,
184 HAVE_SYS_SYSCTL=yes
185 AC_DEFINE([HAVE_SYS_SYSCTL_H],[],[Support for sys/sysctl.h])
186 , [], [
187 #include <sys/types.h>
188 #include <sys/socket.h>
189 #include <sys/param.h>
190 ])
191
192 AM_CONDITIONAL(HAVE_SYS_SYSCTL_H, [ test x"$HAVE_SYS_SYSCTL_H" = xyes ])
193
194 #
195 # Check for lifconf struct; only present on Solaris
196 #
197 AC_MSG_CHECKING(for struct lifconf)
198 AC_CACHE_VAL(avahi_cv_has_struct_lifconf,
199 [AC_TRY_COMPILE(
200 [#include <sys/socket.h>
201 #include <net/if.h>
202 ],[sizeof (struct lifconf);],
203 avahi_cv_has_struct_lifconf=yes,avahi_cv_has_struct_lifconf=no)])
204 AC_MSG_RESULT($avahi_cv_has_struct_lifconf)
205 if test $avahi_cv_has_struct_lifconf = yes; then
206     AC_DEFINE(HAVE_STRUCT_LIFCONF,1,[Define if there is a struct lifconf.])
207 fi
208
209 #
210 # Check for struct ip_mreqn
211 #
212 AC_MSG_CHECKING(for struct ip_mreqn)
213 AC_TRY_COMPILE([#include <netinet/in.h>], [
214         struct ip_mreqn mreq;
215         mreq.imr_address.s_addr = 0;
216 ], [
217         # Yes, we have it...
218         AC_MSG_RESULT(yes)
219         AC_DEFINE([HAVE_STRUCT_IP_MREQN],[],[Support for struct ip_mreqn])
220 ], [
221         # We'll just have to try and use struct ip_mreq
222         AC_MSG_RESULT(no)
223         AC_MSG_CHECKING(for struct ip_mreq)
224         AC_TRY_COMPILE([#include <netinet/in.h>], [
225                 struct ip_mreq mreq;
226                 mreq.imr_interface.s_addr = 0;
227         ], [
228                 # Yes, we have it...
229                 AC_MSG_RESULT(yes)
230                 AC_DEFINE([HAVE_STRUCT_IP_MREQ],[],[Support for struct ip_mreq])
231         ], [
232                 # No multicast support
233                         AC_MSG_RESULT(no)
234         ])
235 ])
236
237 test_gcc_flag() {
238     AC_LANG_CONFTEST([AC_LANG_SOURCE([[int main() {}]])])
239     $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
240     ret=$?
241     rm -f conftest.o
242     return $ret
243 }
244
245 # If using GCC specify some additional parameters
246 if test "x$GCC" = "xyes" ; then
247
248     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"
249
250     for flag in $DESIRED_FLAGS ; do
251         AC_MSG_CHECKING([whether $CC accepts $flag])
252         if test_gcc_flag $flag ; then
253            CFLAGS="$CFLAGS $flag"
254            AC_MSG_RESULT([yes])
255         else
256            AC_MSG_RESULT([no])
257         fi
258     done
259 fi
260
261 # Checks for header files.
262 AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h unistd.h netdb.h syslog.h])
263 AC_HEADER_STDBOOL
264
265 # Checks for typedefs, structures, and compiler characteristics.
266 AC_C_CONST
267 AC_TYPE_SIZE_T
268 AC_HEADER_TIME
269 AC_HEADER_SYS_WAIT
270
271  # Solaris stuff
272  AC_SEARCH_LIBS([inet_ntop],[nsl])
273  AC_SEARCH_LIBS([recv],[socket])
274  AC_CHECK_DECL([CMSG_SPACE],,CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500 -D__EXTENSIONS__", [[#include <sys/socket.h>]])
275
276 # Checks for library functions.
277 AC_FUNC_MEMCMP
278 AC_FUNC_SELECT_ARGTYPES
279 # avahi_malloc actually returns NULL for avahi_malloc(0), so it does not matter
280 # whether libc's malloc does too. (Same for realloc.)
281 #AC_FUNC_MALLOC
282 #AC_FUNC_REALLOC
283 AC_CHECK_FUNCS([gethostname memchr memmove memset mkdir select socket strchr strcspn strdup strerror strrchr strspn strstr uname setresuid setreuid setresgid setregid strcasecmp gettimeofday putenv strncasecmp strlcpy gethostbyname seteuid setegid setproctitle getprogname])
284
285 AC_FUNC_CHOWN
286 AC_FUNC_STAT
287 AC_TYPE_MODE_T
288 AC_TYPE_PID_T
289
290 AC_CHECK_DECLS(environ)
291
292 # check if gcc's -fvisibility is supported
293 CHECK_VISIBILITY_HIDDEN
294
295 # Check for pkg-config manually first, as if its not installed the
296 # PKG_PROG_PKG_CONFIG macro won't be defined.
297 AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
298
299 if test x"$have_pkg_config" = "xno"; then
300     AC_MSG_ERROR(pkg-config is required to install this program)
301 fi
302
303 PKG_PROG_PKG_CONFIG
304
305 #
306 # Doxygen
307 #
308 DX_HTML_FEATURE(ON)
309 DX_CHM_FEATURE(OFF)
310 DX_CHI_FEATURE(OFF)
311 DX_MAN_FEATURE(OFF)
312 DX_RTF_FEATURE(OFF)
313 DX_XML_FEATURE(ON)
314 DX_PDF_FEATURE(OFF)
315 DX_PS_FEATURE(OFF)
316 DX_INIT_DOXYGEN(avahi, doxygen.cfg, doxygen)
317
318 #
319 # Conditionally compile test and example programs
320 #
321 AC_ARG_ENABLE(tests,
322         AS_HELP_STRING([--enable-tests],[Enable building of tests and examples]),
323         [case "${enableval}" in
324                 yes) ENABLE_TESTS=yes ;;
325                 no)  ENABLE_TESTS=no ;;
326                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;;
327         esac],
328         [ENABLE_TESTS=no])
329
330 AM_CONDITIONAL([ENABLE_TESTS], [test "x$ENABLE_TESTS" = "xyes"])
331
332 # ==========================================================================
333 AC_CONFIG_FILES([
334 Makefile
335 avahi-common/Makefile
336 avahi-core/Makefile
337 examples/Makefile
338 common/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 "
353
354 echo "\
355     Building libavahi-core              yes
356     Building tests:                     ${ENABLE_TESTS}
357 "