configure.ac revision a301690be6581e23a39813444b2904addcb26ab7
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4# This file is part of libdaemon.
5#
6# Copyright 2003-2008 Lennart Poettering
7#
8# libdaemon 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.1 of the
11# License, or (at your option) any later version.
12#
13# libdaemon is distributed in the hope that it will be useful, but
14# WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16# Lesser General Public License for more details.
17#
18# You should have received a copy of the GNU Lesser General Public
19# License along with libdaemon. If not, see
20# <http://www.gnu.org/licenses/>.
21
22AC_PREREQ(2.59)
23
24AC_INIT([libdaemon],[0.13],[mzqnrzba (at) 0pointer (dot) de])
25AC_CONFIG_SRCDIR([libdaemon/dfork.c])
26AC_CONFIG_HEADERS([config.h])
27
28AM_INIT_AUTOMAKE([foreign 1.9 -Wall])
29
30AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/libdaemon/])
31
32AC_SUBST(LIBDAEMON_VERSION_INFO, [4:0:4])
33
34if type -p stow > /dev/null && test -d /usr/local/stow ; then
35   AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
36   ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
37fi
38
39# Checks for programs.
40AC_PROG_CC
41AC_GNU_SOURCE
42AC_PROG_CXX
43AC_PROG_MAKE_SET
44AC_PROG_LIBTOOL
45
46test_gcc_flag() {
47    AC_LANG_CONFTEST([int main(int argc, char*argv[]) {}])
48    $CC -c conftest.c $CFLAGS "$1" -o conftest.o > /dev/null 2> /dev/null
49    ret=$?
50    rm -f conftest.o
51    return $ret
52}
53
54# If using GCC specify some additional parameters
55if test "x$GCC" = "xyes" ; then
56    # We use gnu99 instead of c99 because many have interpreted the standard
57    # in a way that int64_t isn't defined on non-64 bit platforms.
58    DESIRED_FLAGS="-std=gnu99 -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 -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter -ffast-math"
59
60    for flag in $DESIRED_FLAGS ; do
61        AC_MSG_CHECKING([whether $CC accepts $flag])
62        if test_gcc_flag $flag ; then
63           CFLAGS="$CFLAGS $flag"
64           CXXFLAGS="$CXXFLAGS $flag"
65           AC_MSG_RESULT([yes])
66        else
67           AC_MSG_RESULT([no])
68        fi
69    done
70fi
71
72# Checks for header files.
73AC_HEADER_STDC
74AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h syslog.h unistd.h sys/ioctl.h sys/time.h])
75AC_HEADER_SYS_WAIT
76
77# Checks for typedefs, structures, and compiler characteristics.
78AC_C_CONST
79AC_TYPE_PID_T
80AC_HEADER_TIME
81AC_C_VOLATILE
82
83# Checks for library functions.
84AC_FUNC_FORK
85AC_FUNC_SELECT_ARGTYPES
86AC_FUNC_VPRINTF
87AC_CHECK_FUNCS([select strerror dup2 memset strrchr asprintf])
88AC_TYPE_MODE_T
89AC_FUNC_SETPGRP
90AC_TYPE_SIGNAL
91AC_TYPE_SIZE_T
92
93AC_SYS_LARGEFILE
94
95# LYNX documentation generation
96AC_ARG_ENABLE(lynx,
97        AC_HELP_STRING(--disable-lynx,Turn off lynx usage for documentation generation),
98[case "${enableval}" in
99  yes) lynx=yes ;;
100  no)  lynx=no ;;
101  *) AC_MSG_ERROR(bad value ${enableval} for --disable-lynx) ;;
102esac],[lynx=yes])
103
104if test x$lynx = xyes ; then
105   AC_CHECK_PROG(have_lynx, lynx, yes, no)
106
107   if test x$have_lynx = xno ; then
108     AC_MSG_WARN([*** lynx not found, plain text README will not be built ***])
109   fi
110fi
111
112AM_CONDITIONAL([USE_LYNX], [test "x$lynx" = xyes])
113
114AC_ARG_ENABLE(examples,
115       AS_HELP_STRING([--disable-examples], [Don't build examples during make]),,
116       enable_examples="yes")
117AM_CONDITIONAL(EXAMPLES, [test "$enable_examples" = "yes"])
118
119AC_CONFIG_FILES([libdaemon/Makefile Makefile doc/Makefile doc/README.html doc/doxygen.conf examples/Makefile libdaemon.pc])
120AC_OUTPUT
121