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