1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 dnl This is the foobar configure script.
4 dnl
5 dnl Copyright (C) 2012 Sebastian 'tokkee' Harl <sh@tokkee.org>
6 dnl
7 dnl This program is free software; you can redistribute it and/or modify it
8 dnl under the terms of the GNU General Public License as published by the
9 dnl Free Software Foundation; only version 2 of the License is applicable.
10 dnl
11 dnl This program is distributed in the hope that it will be useful, but
12 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 dnl General Public License for more details.
15 dnl
16 dnl You should have received a copy of the GNU General Public License along
17 dnl with this program; if not, write to the Free Software Foundation, Inc.,
18 dnl 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 dnl OR:
20 dnl All rights reserved.
21 dnl
22 dnl Redistribution and use in source and binary forms, with or without
23 dnl modification, are permitted provided that the following conditions
24 dnl are met:
25 dnl 1. Redistributions of source code must retain the above copyright
26 dnl notice, this list of conditions and the following disclaimer.
27 dnl 2. Redistributions in binary form must reproduce the above copyright
28 dnl notice, this list of conditions and the following disclaimer in the
29 dnl documentation and/or other materials provided with the distribution.
30 dnl
31 dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
33 dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34 dnl PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
35 dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
36 dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
37 dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
38 dnl OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 dnl WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
40 dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
41 dnl ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 AC_INIT([foobar full name],[m4_esyscmd(./version-gen.sh)],
44 [sh@tokkee.org],
45 [foobar],
46 [http://git.tokkee.org/?p=template.git])
47 PACKAGE_MAINTAINER="Sebastian 'tokkee' Harl <sh@tokkee.org>"
48 AC_DEFINE_UNQUOTED([PACKAGE_MAINTAINER], ["$PACKAGE_MAINTAINER"],
49 [Define to the name of the maintainer of this package.])
50 AC_CONFIG_SRCDIR([src/foobar.c])
51 AC_CONFIG_HEADERS([src/config.h])
52 AC_PREFIX_DEFAULT([/opt/foobar])
54 AM_INIT_AUTOMAKE([foreign -Wall])
56 AC_LANG(C)
58 AC_SYS_LARGEFILE
60 AC_PROG_CC
61 AC_PROG_CPP
62 AC_PROG_INSTALL
63 AC_PROG_LN_S
64 AC_PROG_MAKE_SET
66 AM_PROG_CC_C_O
68 m4_ifdef([LT_INIT],
69 [
70 LT_INIT
71 ],
72 # else
73 # (older libtools)
74 [
75 AC_PROG_LIBTOOL
76 ]
77 )
79 test_cc_flags() {
80 AC_LANG_CONFTEST([AC_LANG_PROGRAM([[ ]], [[ ]])])
81 $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
82 ret=$?
83 rm -f conftest.o
84 return $ret
85 }
87 m4_divert_once([HELP_ENABLE], [
88 Build options:])
90 dnl Optionally stick to standard C99 and POSIX:2001 as close as possible.
91 AC_ARG_ENABLE([standards],
92 AS_HELP_STRING([--enable-standards],
93 [C99 / POSIX standards compliance mode @<:@default=no@:>@]),
94 [enable_standards="$enableval"],
95 [enable_standards="no"])
97 if test "x$enable_standards" = "xyes"; then
98 AC_DEFINE([_ISOC99_SOURCE], 1,
99 [Define to enforce ISO/IEC 9899:1999 (C99) compliance.])
100 AC_DEFINE([_POSIX_C_SOURCE], 200112L,
101 [Define to enforce IEEE 1003.1-2001 (POSIX:2001) compliance.])
102 AC_DEFINE([_XOPEN_SOURCE], 600,
103 [Define to enforce X/Open 6 (XSI) compliance.])
104 AC_DEFINE([_REENTRANT], 1,
105 [Define to enable reentrant interfaces.])
106 AC_DEFINE([_THREAD_SAFE], 1,
107 [Define to enable reentrant interfaces.])
109 for flag in -std=c99 -pedantic; do
110 AC_MSG_CHECKING([whether $CC accepts $flag])
112 if test_cc_flags $flag; then
113 CFLAGS="$CFLAGS $flag"
114 AC_MSG_RESULT([yes])
115 else
116 AC_MSG_RESULT([no])
117 fi
118 done
119 fi
121 dnl Hardening (see e.g. http://wiki.debian.org/Hardening for a motivation).
122 AC_DEFINE([_FORTIFY_SOURCE], 2,
123 [Define to enable protection against static sized buffer overflows.])
124 AC_ARG_ENABLE([hardening],
125 AS_HELP_STRING([--disable-hardening],
126 [hardening options @<:@default=yes@:>@]),
127 [enable_hardening="$enableval"],
128 [enable_hardening="yes"])
130 if test "x$enable_hardening" = "xyes"; then
131 hardening=0
132 hardening_tests=0
133 for flag in -Wformat -Wformat-security; do
134 hardening_tests=$(($hardening_tests + 1))
135 AC_MSG_CHECKING([whether $CC accepts $flag])
137 if test_cc_flags $flag; then
138 CFLAGS="$CFLAGS $flag"
139 hardening=$(($hardening + 1))
140 AC_MSG_RESULT([yes])
141 else
142 AC_MSG_RESULT([no])
143 fi
144 done
145 if test $hardening -ne $hardening_tests; then
146 AC_MSG_WARN(
147 [Some hardening options are not supported by your compiler!])
148 fi
149 fi
151 dnl Strict checking for potential problems.
152 AC_ARG_ENABLE([strict-checks],
153 AS_HELP_STRING([--disable-strict-checks],
154 [strict compiler checks @<:@default=yes@:>@]),
155 [enable_strict_checks="$enableval"],
156 [enable_strict_checks="yes"])
158 STRICT_CFLAGS=""
159 for flag in -Wall -Werror; do
160 AC_MSG_CHECKING([whether $CC accepts $flag])
162 if test_cc_flags $flag; then
163 STRICT_CFLAGS="$STRICT_CFLAGS $flag"
164 AC_MSG_RESULT([yes])
165 else
166 AC_MSG_RESULT([no])
167 fi
168 done
170 if test "x$enable_strict_checks" = "xyes"; then
171 for flag in -Wextra \
172 -Wbad-function-cast \
173 -Wcast-align \
174 -Wcast-qual \
175 -Wconversion \
176 -Wdeclaration-after-statement \
177 -Wmissing-prototypes \
178 -Wpointer-arith \
179 -Wshadow \
180 -Wstrict-prototypes \
181 -Wunreachable-code; do
182 AC_MSG_CHECKING([whether $CC accepts $flag])
184 if test_cc_flags $flag; then
185 STRICT_CFLAGS="$STRICT_CFLAGS $flag"
186 AC_MSG_RESULT([yes])
187 else
188 AC_MSG_RESULT([no])
189 fi
190 done
191 fi
192 AC_SUBST([STRICT_CFLAGS])
194 AC_CHECK_HEADERS(libgen.h)
196 dnl Check for dependencies.
197 build_documentation="yes"
199 have_xsltproc="yes"
200 AC_PATH_PROG([XSLTPROC], [xsltproc])
201 if test "x$XSLTPROC" = "x"; then
202 have_xsltproc="no"
203 build_documentation="no (missing xsltproc)"
204 fi
206 have_a2x="yes"
207 AC_PATH_PROG([A2X], [a2x])
208 if test "x$A2X" = "x"; then
209 have_a2x="no"
210 build_documentation="no (missing a2x)"
211 fi
212 AC_SUBST([A2X])
214 AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes")
216 AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile])
217 AC_OUTPUT
219 BUILD_DATE="`date --utc '+%F %T'` (UTC)"
221 AC_MSG_RESULT()
222 AC_MSG_RESULT([$PACKAGE_NAME has been configured successfully.])
223 AC_MSG_RESULT()
224 AC_MSG_RESULT([Run 'make' to compile the software and use 'make install' to])
225 AC_MSG_RESULT([install the package into $prefix.])
226 AC_MSG_RESULT()
227 AC_MSG_RESULT([Configuration summary:])
228 AC_MSG_RESULT()
229 AC_MSG_RESULT([ package version: $PACKAGE_VERSION])
230 AC_MSG_RESULT([ build date: $BUILD_DATE])
231 AC_MSG_RESULT()
232 AC_MSG_RESULT([ Tools:])
233 AC_MSG_RESULT([ AsciiDoc (a2x): . . . . . . $have_a2x])
234 AC_MSG_RESULT([ xsltproc: . . . . . . . . . $have_xsltproc])
235 AC_MSG_RESULT()
236 AC_MSG_RESULT([ Features:])
237 AC_MSG_RESULT([ documentation: . . . . . . $build_documentation])
238 AC_MSG_RESULT()
239 AC_MSG_RESULT([This package is maintained by $PACKAGE_MAINTAINER.])
240 AC_MSG_RESULT([Please report bugs to $PACKAGE_BUGREPORT.])
241 AC_MSG_RESULT()