31d2f0378bd5d4439d5fe8c37e472874f18cbb9e
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 dnl This is the lm2latex configure script.
4 dnl
5 dnl Copyright (C) 2010 Sebastian Harl <sh@tokkee.org>
6 dnl All rights reserved.
7 dnl
8 dnl Redistribution and use in source and binary forms, with or without
9 dnl modification, are permitted provided that the following conditions
10 dnl are met:
11 dnl 1. Redistributions of source code must retain the above copyright
12 dnl notice, this list of conditions and the following disclaimer.
13 dnl 2. Redistributions in binary form must reproduce the above copyright
14 dnl notice, this list of conditions and the following disclaimer in the
15 dnl documentation and/or other materials provided with the distribution.
16 dnl
17 dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 dnl PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
21 dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 dnl OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 dnl WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 dnl ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 AC_INIT([lm2latex],[m4_esyscmd(./version-gen.sh)],
30 [Sebastian Harl <sh@tokkee.org>], [],
31 [http://git.tokkee.org/?p=lm2latex.git])
32 AC_CONFIG_SRCDIR([src/lm2latex.c])
33 AC_CONFIG_HEADERS([src/config.h])
34 AC_PREFIX_DEFAULT([/opt/lm2latex])
36 AM_INIT_AUTOMAKE([foreign -Wall])
38 AC_LANG(C)
40 AC_SYS_LARGEFILE
42 AC_PROG_CC
43 AC_PROG_CPP
44 AC_PROG_INSTALL
45 AC_PROG_LN_S
46 AC_PROG_MAKE_SET
48 AM_PROG_CC_C_O
49 AM_PROG_LEX
51 m4_ifdef([LT_INIT],
52 [
53 LT_INIT
54 ],
55 # else
56 # (older libtools)
57 [
58 AC_PROG_LIBTOOL
59 ]
60 )
62 test_cc_flags() {
63 AC_LANG_CONFTEST([int main() {}])
64 $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
65 ret=$?
66 rm -f conftest.o
67 return $ret
68 }
70 m4_divert_once([HELP_ENABLE], [
71 Build options:])
73 dnl Optionally stick to standard C99 and POSIX:2001 as close as possible.
74 AC_ARG_ENABLE([standards],
75 AS_HELP_STRING([--enable-standards],
76 [C99 / POSIX standards compliance mode @<:@default=no@:>@]),
77 [enable_standards="$enableval"],
78 [enable_standards="no"])
80 if test "x$enable_standards" = "xyes"; then
81 AC_DEFINE([_ISOC99_SOURCE], 1,
82 [Define to enforce ISO/IEC 9899:1999 (C99) compliance.])
83 AC_DEFINE([_POSIX_C_SOURCE], 200112L,
84 [Define to enforce IEEE 1003.1-2001 (POSIX:2001) compliance.])
85 AC_DEFINE([_XOPEN_SOURCE], 600,
86 [Define to enforce X/Open 6 (XSI) compliance.])
87 AC_DEFINE([_REENTRANT], 1,
88 [Define to enable reentrant interfaces.])
89 AC_DEFINE([_THREAD_SAFE], 1,
90 [Define to enable reentrant interfaces.])
92 for flag in -std=c99 -pedantic; do
93 AC_MSG_CHECKING([whether $CC accepts $flag])
95 if test_cc_flags $flag; then
96 CFLAGS="$CFLAGS $flag"
97 AC_MSG_RESULT([yes])
98 else
99 AC_MSG_RESULT([no])
100 fi
101 done
102 fi
104 dnl Hardening (see e.g. http://wiki.debian.org/Hardening for a motivation).
105 AC_DEFINE([_FORTIFY_SOURCE], 2,
106 [Define to enable protection against static sized buffer overflows.])
107 AC_ARG_ENABLE([hardening],
108 AS_HELP_STRING([--disable-hardening],
109 [hardening options @<:@default=yes@:>@]),
110 [enable_hardening="$enableval"],
111 [enable_hardening="yes"])
113 if test "x$enable_hardening" = "xyes"; then
114 hardening=0
115 hardening_tests=0
116 for flag in -Wformat -Wformat-security; do
117 hardening_tests=$(($hardening_tests + 1))
118 AC_MSG_CHECKING([whether $CC accepts $flag])
120 if test_cc_flags $flag; then
121 CFLAGS="$CFLAGS $flag"
122 hardening=$(($hardening + 1))
123 AC_MSG_RESULT([yes])
124 else
125 AC_MSG_RESULT([no])
126 fi
127 done
128 if test $hardening -ne $hardening_tests; then
129 AC_MSG_WARN(
130 [Some hardening options are not supported by your compiler!])
131 fi
132 fi
134 dnl Strict checking for potential problems.
135 AC_ARG_ENABLE([strict-checks],
136 AS_HELP_STRING([--disable-strict-checks],
137 [strict compiler checks @<:@default=yes@:>@]),
138 [enable_strict_checks="$enableval"],
139 [enable_strict_checks="yes"])
141 STRICT_CFLAGS=""
142 for flag in -Wall -Werror; do
143 AC_MSG_CHECKING([whether $CC accepts $flag])
145 if test_cc_flags $flag; then
146 STRICT_CFLAGS="$STRICT_CFLAGS $flag"
147 AC_MSG_RESULT([yes])
148 else
149 AC_MSG_RESULT([no])
150 fi
151 done
153 if test "x$enable_strict_checks" = "xyes"; then
154 for flag in -Wextra \
155 -Wbad-function-cast \
156 -Wcast-align \
157 -Wcast-qual \
158 -Wconversion \
159 -Wdeclaration-after-statement \
160 -Wmissing-prototypes \
161 -Wpointer-arith \
162 -Wshadow \
163 -Wstrict-prototypes \
164 -Wunreachable-code; do
165 AC_MSG_CHECKING([whether $CC accepts $flag])
167 if test_cc_flags $flag; then
168 STRICT_CFLAGS="$STRICT_CFLAGS $flag"
169 AC_MSG_RESULT([yes])
170 else
171 AC_MSG_RESULT([no])
172 fi
173 done
174 fi
175 AC_SUBST([STRICT_CFLAGS])
177 AC_CHECK_HEADERS(libgen.h)
179 AC_CONFIG_FILES([Makefile src/Makefile])
180 AC_OUTPUT
182 cat <<EOF;
184 $PACKAGE_NAME has been configured successfully.
186 Run 'make' to compile the software and use 'make install' to
187 install the package into $prefix.
189 Configuration summary:
191 package version: $PACKAGE_VERSION
192 build date: `date --utc '+%F %T'` (UTC)
194 Please report bugs to $PACKAGE_BUGREPORT.
196 EOF