1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4# $Id$
5
6# Copyright 2006 Lennart Poettering
7#
8# Licensed under the Apache License, Version 2.0 (the "License"); you
9# may not use this file except in compliance with the License.  You
10# may obtain a copy of the License at
11#
12#     http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS,
16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17# implied.  See the License for the specific language governing
18# permissions and limitations under the License.
19
20AC_PREREQ(2.63)
21AC_INIT([mod_dnssd],[0.6],[mzzbqqaffq (at) 0pointer (dot) net])
22AC_CONFIG_SRCDIR([src/mod_dnssd.c])
23AC_CONFIG_MACRO_DIR([m4])
24AC_CONFIG_HEADERS([config.h])
25AM_INIT_AUTOMAKE([foreign 1.10 -Wall])
26
27AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/mod_dnssd/])
28
29# Checks for programs.
30AC_PROG_CC
31AC_PROG_CPP
32AC_PROG_INSTALL
33AC_PROG_MAKE_SET
34
35test_gcc_flag() {
36    AC_LANG_CONFTEST([int main() {}])
37    $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
38    ret=$?
39    rm -f conftest.o
40    return $ret
41}
42
43# If using GCC specify some additional parameters
44if test "x$GCC" = "xyes" ; then
45
46    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 -Winline"
47
48    if test "x$HAVE_NETLINK" = "xyes" ; then
49        # Test whether rtnetlink.h can be included when compiled with -std=c99
50        # some distributions (e.g. archlinux) have broken headers that dont
51        # define __u64 with -std=c99
52        AC_MSG_CHECKING([checking whether rtnetlink.h can be included with -std=c99])
53        OLDCFLAGS="$CFLAGS"
54        CFLAGS="-std=c99"
55        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/rtnetlink.h>]], [[]])],[use_stdc99=yes],[use_stdc99=no])
56
57        if test x"$use_stdc99" = xyes; then
58            DESIRED_FLAGS="-std=c99 $DESIRED_FLAGS"
59            AC_MSG_RESULT([yes])
60        else
61            AC_MSG_RESULT([no])
62        fi
63
64        CFLAGS="$OLDCFLAGS"
65    else
66        DESIRED_FLAGS="-std=c99 $DESIRED_FLAGS"
67    fi
68
69    for flag in $DESIRED_FLAGS ; do
70        AC_MSG_CHECKING([whether $CC accepts $flag])
71        if test_gcc_flag $flag ; then
72           CFLAGS="$CFLAGS $flag"
73           AC_MSG_RESULT([yes])
74        else
75           AC_MSG_RESULT([no])
76        fi
77    done
78fi
79
80PKG_PROG_PKG_CONFIG
81
82PKG_CHECK_MODULES(APR, [ apr-1])
83CFLAGS="$APR_CFLAGS $CFLAGS"
84LIBS="$APR_LIBS $LIBS"
85
86AC_ARG_WITH(apxs,
87    AS_HELP_STRING(--with-apxs=PATH,/path/to/apxs),
88    [ AC_PATH_PROGS(APXS, [apxs2 apxs], "notfound", "$withval:$PATH") ],
89    [ AC_PATH_PROGS(APXS, [apxs2 apxs], "notfound", "/usr/local/apache/bin:/usr/local/bin:/usr/sbin:$PATH")])
90
91if test "x$APXS" = "xnotfound" ; then
92    AC_MSG_ERROR([*** Sorry, could not find apxs ***])
93fi
94
95AC_ARG_WITH(apachectl,
96    AS_HELP_STRING(--with-apachectl=PATH,/path/to/apachectl),
97    [ AC_PATH_PROGS(APACHECTL, [apache2ctl apachectl], "notfound", "$withval:$PATH") ],
98    [ AC_PATH_PROGS(APACHECTL, [apache2ctl apachectl], "notfound", "/usr/local/apache/bin:/usr/local/bin:/usr/sbin:$PATH")])
99
100#
101# Checking that we have Apache version 2
102#
103
104# saving current CFLAGS
105CFLAGS_SAVED=$CFLAGS
106CFLAGS="$CFLAGS -I`${APXS} -q INCLUDEDIR`"
107
108AC_MSG_CHECKING([for Apache 2])
109AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
110	#include <ap_release.h>
111]], [[
112        char *version = AP_SERVER_BASEREVISION;
113]])],[
114        APACHE_2="yes"
115],[
116        APACHE_2="no"
117])
118
119AC_MSG_RESULT($APACHE_2)
120
121if test "x$APACHE_2" = "xno" ; then
122    AC_MSG_ERROR([*** Sorry, you need apache 2 ***])
123fi
124
125# restoring CFLAGS
126CFLAGS=$CFLAGS_SAVED
127
128
129PKG_CHECK_MODULES(AVAHI, [ avahi-client >= 0.6 ])
130AC_SUBST(AVAHI_CFLAGS)
131AC_SUBST(AVAHI_LIBS)
132
133# LYNX documentation generation
134AC_ARG_ENABLE(lynx,
135        AS_HELP_STRING(--disable-lynx,Turn off lynx usage for documentation generation),
136[case "${enableval}" in
137  yes) lynx=yes ;;
138  no)  lynx=no ;;
139  *) AC_MSG_ERROR(bad value ${enableval} for --disable-lynx) ;;
140esac],[lynx=yes])
141
142if test x$lynx = xyes ; then
143   AC_CHECK_PROG(have_lynx, lynx, yes, no)
144
145   if test x$have_lynx = xno ; then
146     AC_MSG_ERROR([*** Sorry, you have to install lynx or use --disable-lynx ***])
147   fi
148fi
149
150AM_CONDITIONAL([USE_LYNX], [test "x$lynx" = xyes])
151
152AC_CONFIG_FILES([src/Makefile Makefile doc/Makefile doc/README.html])
153AC_OUTPUT
154