]> git.meshlink.io Git - catta/blob - configure.ac
Include qt mainloop adapter in build system. Moc finding code is cracktastic thanks to
[catta] / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 # $Id$
5
6 # This file is part of avahi.
7 #
8 # avahi is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU Lesser General Public License as
10 # published by the Free Software Foundation; either version 2 of the
11 # License, or (at your option) any later version.
12 #
13 # avahi is distributed in the hope that it will be useful, but WITHOUT
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 # License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with avahi; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 # USA.
22
23 AC_PREREQ(2.57)
24 AC_INIT([avahi],[0.2],[avahi (at) lists (dot) freedesktop (dot) org])
25 AC_CONFIG_SRCDIR([avahi-core/server.c])
26 AC_CONFIG_HEADERS([config.h])
27 AM_INIT_AUTOMAKE([foreign 1.9 -Wall])
28
29 AC_SUBST(PACKAGE_URL, [http://www.freedesktop.org/Software/Avahi])
30
31 if type -p stow > /dev/null && test -d /usr/local/stow ; then
32     AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
33     ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
34 fi
35
36 # Checks for programs.
37 AC_PROG_CC
38 AC_PROG_CXX
39 AC_GNU_SOURCE
40 AC_PROG_CPP
41 AC_PROG_INSTALL
42 AC_PROG_LN_S
43 AC_PROG_MAKE_SET
44 AC_PROG_GCC_TRADITIONAL
45
46 # libtool stuff
47 AC_PROG_LIBTOOL
48
49 #
50 # Detecting the linux distribution for specific things like init scripts.
51 #
52 AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO],[Specify the Linux distribution to target: One of debian, gentoo, archlinux or none]))
53 if test "z$with_distro" = "z"; then
54     #AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
55     AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
56     AC_CHECK_FILE(/etc/arch-release,with_distro="archlinux")
57     AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
58 fi
59 with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]' `
60
61 if test "z$with_distro" = "z"; then
62     AC_MSG_ERROR([Linux distribution autodetection failed, you must specify the distribution to target using --with-distro=DISTRO, set DISTRO to none if your distribution is not supported.])
63     exit 1
64 else
65 case $with_distro in
66     debian|gentoo|archlinux|none)
67      ;;
68     *)
69      AC_MSG_ERROR([Your distribution (${with_distro}) is not yet supported, init scripts and dbus configuration will not be installed! (patches welcome), you can specify --with-distro=none to skip this check])
70      ;;
71 esac
72 fi
73
74 #AM_CONDITIONAL(TARGET_SUSE, test x"$with_distro" = xsuse)
75 AM_CONDITIONAL(TARGET_GENTOO, test x"$with_distro" = xgentoo)
76 AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian)
77 AM_CONDITIONAL(TARGET_ARCHLINUX, test x"$with_distro" = xarchlinux)
78
79 test_gcc_flag() {
80     AC_LANG_CONFTEST([int main() {}])
81     $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
82     ret=$?
83     rm -f conftest.o
84     return $ret
85 }
86
87 # If using GCC specify some additional parameters
88 if test "x$GCC" = "xyes" ; then
89
90     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 -Wlarger-than-4000 -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter"
91
92     # Test whether rtnetlink.h can be included when compiled with -std=c99
93     # some distributions (e.g. archlinux) have broken headers that dont
94     # define __u64 with -std=c99
95     AC_MSG_CHECKING([checking whether rtnetlink.h can be included with -std=c99])
96     OLDCFLAGS="$CFLAGS"
97     CFLAGS="-std=c99"
98     AC_TRY_COMPILE([#include <linux/rtnetlink.h>], [],
99         use_stdc99=yes, use_stdc99=no)
100
101     if test x"$use_stdc99" = xyes; then
102         DESIRED_FLAGS="-std=c99 $DESIRED_FLAGS"
103         AC_MSG_RESULT([yes])
104     else
105         AC_MSG_RESULT([no])
106     fi
107
108     CFLAGS="$OLDCFLAGS"
109
110     for flag in $DESIRED_FLAGS ; do
111         AC_MSG_CHECKING([whether $CC accepts $flag])
112         if test_gcc_flag $flag ; then 
113            CFLAGS="$CFLAGS $flag"
114            AC_MSG_RESULT([yes])
115         else
116            AC_MSG_RESULT([no])
117         fi
118     done 
119 fi
120
121 # Checks for header files.
122 AC_HEADER_STDC
123 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])
124
125 # Checks for typedefs, structures, and compiler characteristics.
126 AC_C_CONST
127 AC_TYPE_SIZE_T
128 AC_HEADER_TIME
129 AC_HEADER_SYS_WAIT
130
131 # Checks for library functions.
132 AC_FUNC_MEMCMP
133 AC_FUNC_SELECT_ARGTYPES
134 AC_FUNC_MALLOC
135 AC_FUNC_REALLOC
136 AC_CHECK_FUNCS([gethostname memchr memmove memset mkdir select socket strchr strcspn strdup strerror strrchr strspn strstr uname setresuid setreuid strcasecmp gettimeofday putenv strncasecmp])
137
138 AC_FUNC_CHOWN
139 AC_FUNC_STAT
140 AC_TYPE_MODE_T
141 AC_TYPE_PID_T
142
143 # Check for pkg-config manually first, as if its not installed the
144 # PKG_PROG_PKG_CONFIG macro won't be defined.
145 AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
146
147 if test x"$have_pkg_config" == xno; then
148     AC_MSG_ERROR(pkg-config is required to install this program)
149 fi
150
151 PKG_PROG_PKG_CONFIG
152
153 #
154 # Check for GLIB 2.0
155 #
156 AC_ARG_ENABLE(glib,
157         AS_HELP_STRING([--disable-glib],[Disable use of GLib]),
158         [case "${enableval}" in
159                 yes) HAVE_GLIB=yes ;;
160                 no)  HAVE_GLIB=no ;;
161                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-glib) ;;
162         esac],
163         [HAVE_GLIB=yes])
164
165 if test "x$HAVE_GLIB" = "xyes" ; then
166         PKG_CHECK_MODULES(GLIB20, [ glib-2.0 >= 2.4.0 ])
167         AC_SUBST(GLIB20_CFLAGS)
168         AC_SUBST(GLIB20_LIBS)
169 fi
170 AM_CONDITIONAL(HAVE_GLIB, test "x$HAVE_GLIB" = "xyes")
171
172 #
173 # Check for Qt 3
174 #
175 AC_ARG_ENABLE(qt3,
176         AS_HELP_STRING([--disable-qt3],[Disable building of Qt3 mainloop integration]),
177         [case "${enableval}" in
178                 yes) HAVE_QT3=yes ;;
179                 no)  HAVE_QT3=no ;;
180                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-qt3) ;;
181         esac],
182         [HAVE_QT3=yes])
183
184 if test "x$HAVE_QT3" = "xyes" ; then
185         PKG_CHECK_MODULES( QT3, [ qt-mt >= 3.0.0 ], [ 
186         AC_SUBST(QT3_CFLAGS)
187         AC_SUBST(QT3_LIBS)
188         QT3_PREFIX="`$PKG_CONFIG --variable=prefix qt-mt`/bin"
189         MOC_QT3="no"
190         AC_CHECK_FILE( "$QT3_PREFIX/moc-qt3", [ MOC_QT3=$QT3_PREFIX/moc-qt3 ], [
191             AC_CHECK_FILE("$QT3_PREFIX/moc", [ MOC_QT3=$QT3_PREFIX/moc ], [ HAVE_QT3=no ] ) 
192         ] )   
193         AC_SUBST(MOC_QT3)
194       ], [ HAVE_QT3=no ] )
195 fi
196 AM_CONDITIONAL(HAVE_QT3, test "x$HAVE_QT3" = "xyes")
197
198 #
199 # Check for Qt 4
200 #
201 AC_ARG_ENABLE(qt4,
202         AS_HELP_STRING([--disable-qt4],[Disable building of Qt4Core mainloop integration]),
203         [case "${enableval}" in
204                 yes) HAVE_QT4=yes ;;
205                 no)  HAVE_QT4=no ;;
206                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-qt4) ;;
207         esac],
208         [HAVE_QT4=yes])
209
210 if test "x$HAVE_QT4" = "xyes" ; then
211         PKG_CHECK_MODULES( QT4, [ QtCore >= 4.0.0 ], [ 
212         AC_SUBST(QT4_CFLAGS)
213         AC_SUBST(QT4_LIBS)
214         QT4_PREFIX="`$PKG_CONFIG --variable=prefix QtCore`/bin"
215         MOC_QT4="no"
216         AC_CHECK_FILE( "$QT4_PREFIX/moc-qt4", [ MOC_QT4=$QT4_PREFIX/moc-qt4 ], [
217             AC_CHECK_FILE("$QT4_PREFIX/moc", [ MOC_QT4=$QT4_PREFIX/moc ], [ HAVE_QT4=no ] ) 
218         ] )   
219         AC_SUBST(MOC_QT4)
220       ], [ HAVE_QT4=no ] )
221 fi
222 AM_CONDITIONAL(HAVE_QT4, test "x$HAVE_QT4" = "xyes")
223
224
225 #
226 # Check for GTK+
227 #
228 AC_ARG_ENABLE(gtk,
229         AS_HELP_STRING([--disable-gtk],[Disable use of GTK+]),
230         [case "${enableval}" in
231                 yes) HAVE_GTK=yes ;;
232                 no)  HAVE_GTK=no ;;
233                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-gtk) ;;
234         esac],
235         [HAVE_GTK=yes])
236
237 if test "x$HAVE_GTK" = "xyes" ; then
238         # Check for GTK 2.0
239         PKG_CHECK_MODULES(GTK20, [ gtk+-2.0 >= 2.4.0 ])
240         AC_SUBST(GTK20_CFLAGS)
241         AC_SUBST(GTK20_LIBS)
242         
243         # Check for GLADE 2.0
244         PKG_CHECK_MODULES(GLADE20, [ libglade-2.0 >= 2.4.0 ])
245         AC_SUBST(GLADE20_CFLAGS)
246         AC_SUBST(GLADE20_LIBS)
247
248         interfacesdir="${datadir}/${PACKAGE}/interfaces/"
249         AC_SUBST(interfacesdir)
250 fi
251 AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes")
252
253 #
254 # D-BUS
255 #
256 AC_ARG_ENABLE(dbus,
257         AS_HELP_STRING([--disable-dbus],[Disable use of D-BUS]),
258         [case "${enableval}" in
259                 yes) HAVE_DBUS=yes ;;
260                 no)  HAVE_DBUS=no ;;
261                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-dbus) ;;
262         esac],
263         [HAVE_DBUS=yes]) 
264
265 AC_ARG_WITH(dbus-sys, AS_HELP_STRING([--with-dbus-sys=<dir>], [where D-BUS system.d directory is]))
266 AC_ARG_WITH(dbus-system-socket, AS_HELP_STRING([--with-dbus-system-address=<address>], [where the dbus system socket is, you probably want to put unix:path= at the start]))
267
268 if test "x$HAVE_DBUS" = "xyes" ; then
269     AC_DEFINE(HAVE_DBUS, 1, [Whether we have D-BUS or not])
270
271     PKG_CHECK_MODULES(DBUS, [ dbus-1 >= 0.30 ])
272     DBUS_CFLAGS="$DBUS_CFLAGS -DDBUS_API_SUBJECT_TO_CHANGE"
273     AC_SUBST(DBUS_CFLAGS)
274     AC_SUBST(DBUS_LIBS)
275
276     if ! test -z "$with_dbus_sys" ; then
277         DBUS_SYS_DIR="$with_dbus_sys"
278     else
279         DBUS_SYS_DIR="${sysconfdir}/dbus-1/system.d"
280     fi
281     AC_SUBST(DBUS_SYS_DIR)
282
283     if ! test -z "$with_dbus_system_address" ; then
284         DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="$with_dbus_system_address"
285     else
286         # Note this default path is hardcoded in D-BUS and should
287         # not use $localstatedir
288         DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=/var/run/dbus/system_bus_socket"
289     fi
290     AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)
291     
292 fi
293 AM_CONDITIONAL(HAVE_DBUS, test "x$HAVE_DBUS" = "xyes")
294
295 #
296 # Expat
297 #
298 AC_ARG_ENABLE(expat,
299         AS_HELP_STRING([--disable-expat],[Disable use of Expat]),
300         [case "${enableval}" in
301                 yes) HAVE_EXPAT=yes ;;
302                 no)  HAVE_EXPAT=no ;;
303                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-expat) ;;
304         esac],
305         [HAVE_EXPAT=yes]) 
306
307 if test "x$HAVE_EXPAT" = "xyes" ; then
308     AC_CHECK_LIB(expat, XML_ParserCreate, [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ], have_expat=false)
309
310     if ! $have_expat ; then
311         AC_MSG_ERROR([*** libexpat not found ***])
312     fi
313 fi
314 AM_CONDITIONAL(HAVE_EXPAT, test "x$HAVE_EXPAT" = "xyes")
315
316 #
317 # libdaemon
318 #
319 AC_ARG_ENABLE(libdaemon,
320         AS_HELP_STRING([--disable-libdaemon],[Disable use of libdaemon]),
321         [case "${enableval}" in
322                 yes) HAVE_LIBDAEMON=yes ;;
323                 no)  HAVE_LIBDAEMON=no ;;
324                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-libdaemon) ;;
325         esac],
326         [HAVE_LIBDAEMON=yes]) 
327
328 if test "x$HAVE_LIBDAEMON" = "xyes" ; then
329     PKG_CHECK_MODULES(LIBDAEMON, [ libdaemon >= 0.5 ])
330     AC_SUBST(LIBDAEMON_CFLAGS)
331     AC_SUBST(LIBDAEMON_LIBS)
332 fi
333 AM_CONDITIONAL(HAVE_LIBDAEMON, test "x$HAVE_LIBDAEMON" = "xyes")
334
335 #
336 # Python stuff
337 #
338 AC_ARG_ENABLE(python,
339     AS_HELP_STRING([--disable-python], [Disable scripts that depends on python]),
340     [case "${enableval}" in
341           yes) HAVE_PYTHON=yes ;;
342           no)  HAVE_PYTHON=no ;;
343           *) AC_MSG_ERROR([bad value ${enableval} for --enable-python]) ;;
344     esac],[HAVE_PYTHON=yes])
345
346 if test "x$HAVE_PYTHON" = "xyes" ; then
347     AM_PATH_PYTHON([2.4])
348     AM_CHECK_PYMOD(gtk,,,[AC_MSG_ERROR(Could not find Python module pygtk)])
349     AM_CHECK_PYMOD(dbus,,,[AC_MSG_ERROR(Could not find Python module dbus)])
350     AM_CHECK_PYMOD(socket,,,[AC_MSG_ERROR(Could not find Python module socket)])
351     AM_CHECK_PYMOD(dbm,,,[AC_MSG_ERROR(Could not find Python module dbm)])
352     AM_CHECK_PYMOD(anydbm,,,[AC_MSG_ERROR(Could not find Python module anydbm)])
353 fi
354 AM_CONDITIONAL(HAVE_PYTHON, [test "x$HAVE_PYTHON" = "xyes" ])
355
356 #
357 # Defining Avahi User and Group.
358 #
359 AC_ARG_WITH(avahi_user, AS_HELP_STRING([--with-avahi-user=<user>],[User for running the Avahi daemon (avahi)]))
360 if test -z "$with_avahi_user" ; then
361     AVAHI_USER=avahi
362 else
363     AVAHI_USER=$with_avahi_user
364 fi
365 AC_SUBST(AVAHI_USER)
366 AC_DEFINE_UNQUOTED(AVAHI_USER,"$AVAHI_USER", [User for running the Avahi daemon])
367
368 AC_ARG_WITH(avahi_group,AS_HELP_STRING([--with-avahi-group=<group>],[Group for Avahi (avahi)]))
369 if test -z "$with_avahi_group" ; then
370     AVAHI_GROUP=avahi
371 else
372     AVAHI_GROUP=$with_avahi_group
373 fi
374 AC_SUBST(AVAHI_GROUP)
375 AC_DEFINE_UNQUOTED(AVAHI_GROUP,"$AVAHI_GROUP", [Group for Avahi])
376
377 #
378 # Avahi runtime dir
379 #
380 avahi_runtime_dir="${localstatedir}/run"
381 avahi_socket="${avahi_runtime_dir}/avahi-daemon/socket"
382 AC_SUBST(avahi_runtime_dir)
383 AC_SUBST(avahi_socket)
384
385
386 #
387 # Doxygen
388 #
389 DX_HTML_FEATURE(ON)
390 DX_CHM_FEATURE(OFF)
391 DX_CHI_FEATURE(OFF)
392 DX_MAN_FEATURE(OFF)
393 DX_RTF_FEATURE(OFF)
394 DX_XML_FEATURE(OFF)
395 DX_PDF_FEATURE(OFF)
396 DX_PS_FEATURE(OFF)
397 DX_INIT_DOXYGEN(avahi, doxygen.cfg, doxygen)
398
399 #
400 # XMLTOMAN manpage generation
401 #
402 AC_ARG_ENABLE(xmltoman,
403         AS_HELP_STRING([--disable-xmltoman],[Disable rebuilding of man pages with xmltoman]),
404 [case "${enableval}" in
405   yes) xmltoman=yes ;;
406   no)  xmltoman=no ;;
407   *) AC_MSG_ERROR([bad value ${enableval} for --disable-xmltoman]) ;;
408 esac],[xmltoman=yes])
409
410 if test x$xmltoman = xyes ; then
411     AC_CHECK_PROG(have_xmltoman, xmltoman, yes, no)
412  
413     if test x$have_xmltoman = xno ; then
414         if ! test -e man/avahi-daemon.8 ; then
415             AC_MSG_ERROR([*** xmltoman was not found, it is required to build the manpages and they have not been pre-built])
416             exit 1
417         fi
418         AC_MSG_WARN([*** Not rebuilding man pages as xmltoman is not found ***])
419         xmltoman=no
420     fi
421 fi
422
423 AM_CONDITIONAL([USE_XMLTOMAN], [test "x$xmltoman" = xyes])
424
425 # ==========================================================================
426 AC_CONFIG_FILES([
427 Makefile 
428 avahi-common/Makefile 
429 avahi-core/Makefile 
430 avahi-glib/Makefile 
431 avahi-qt/Makefile
432 avahi-daemon/Makefile 
433 avahi-daemon/avahi-dbus.conf
434 avahi-discover-standalone/Makefile 
435 avahi-client/Makefile 
436 initscript/Makefile 
437 initscript/debian/Makefile
438 initscript/gentoo/Makefile
439 initscript/archlinux/Makefile
440 avahi-dnsconfd/Makefile
441 avahi-utils/Makefile
442 avahi-utils/avahi/Makefile
443 examples/Makefile
444 common/Makefile
445 man/Makefile
446 tests/Makefile
447 service-type-database/Makefile
448 ])
449 AC_OUTPUT
450
451 # ==========================================================================
452 echo "
453  ---{ $PACKAGE_NAME $VERSION }---
454
455     prefix:                 ${prefix}
456     sysconfdir:             ${sysconfdir}
457     dbus-1 system.d dir:    ${DBUS_SYS_DIR}
458     dbus-1 version:         `pkg-config dbus-1 --modversion`
459     dbus-1 system socket    ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS}
460     compiler:               ${CC}
461     cflags:                 ${CFLAGS}
462     Enable GLIB:            ${HAVE_GLIB}
463     Enable GTK:             ${HAVE_GTK}
464     Enable D-BUS:           ${HAVE_DBUS}
465     Enable Expat:           ${HAVE_EXPAT}
466     Enable libdaemon:       ${HAVE_LIBDAEMON}
467     Have Python:            ${HAVE_PYTHON}
468     Linux Distro:           ${with_distro}
469     User for Avahi:         ${AVAHI_USER}
470     Group for Avahi:        ${AVAHI_GROUP}
471 "
472
473 BUILD_DAEMON="no (!)"
474
475 if test "x$HAVE_EXPAT" = "xyes" -a "x$HAVE_LIBDAEMON" = "xyes" ; then
476     BUILD_DAEMON=yes
477 fi
478
479 BUILD_UTILS="no (!)"
480
481 if test "x$BUILD_DAEMON" = "xyes" -a "x$HAVE_DBUS" = "xyes" -a "x$HAVE_PYTHON" = "xyes" ; then
482     BUILD_UTILS=yes
483 fi
484
485 BUILD_CLIENT="no (!)"
486
487 if test "x$BUILD_DAEMON" = "xyes" -a "x$HAVE_DBUS" = "xyes" ; then
488     BUILD_CLIENT=yes
489 fi
490
491     
492 echo "
493     Building libavahi-core              yes
494     Building avahi-daemon:              ${BUILD_DAEMON}
495     Building avahi-dnsconfd:            ${BUILD_DAEMON}
496     Building avahi-utils:               ${BUILD_UTILS}
497     Building libavahi-glib:             ${HAVE_GLIB}
498     Building libavahi-client:           ${BUILD_CLIENT}
499     Building avahi-discover-standalone: ${HAVE_GTK}
500 "