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