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