db3ca4a65bb9715ff9a49c6dc0252bf433233728
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 dnl This is the tpdfview configure script.
4 dnl
5 dnl Copyright (C) 2011 Sebastian 'tokkee' 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([tiny PDF viewer],[m4_esyscmd(./version-gen.sh)],
30 [sh@tokkee.org], [tpdfview],
31 [http://git.tokkee.org/?p=tpdfview.git])
32 PACKAGE_MAINTAINER="Sebastian 'tokkee' Harl <sh@tokkee.org>"
33 AC_DEFINE_UNQUOTED([PACKAGE_MAINTAINER], ["$PACKAGE_MAINTAINER"],
34 [Define to the name of the maintainer of this package.])
35 AC_CONFIG_SRCDIR([src/tpdfview.c])
36 AC_CONFIG_HEADERS([src/config.h])
37 AC_PREFIX_DEFAULT([/opt/tpdfview])
39 AM_INIT_AUTOMAKE([foreign -Wall])
41 AC_LANG(C)
43 AC_SYS_LARGEFILE
45 AC_PROG_CC
46 AC_PROG_CPP
47 AC_PROG_INSTALL
48 AC_PROG_LN_S
49 AC_PROG_MAKE_SET
51 AM_PROG_CC_C_O
53 m4_ifdef([LT_INIT],
54 [
55 LT_INIT
56 ],
57 # else
58 # (older libtools)
59 [
60 AC_PROG_LIBTOOL
61 ]
62 )
64 PKG_PROG_PKG_CONFIG
66 test_cc_flags() {
67 AC_LANG_CONFTEST([AC_LANG_PROGRAM([[ ]], [[ ]])])
68 $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
69 ret=$?
70 rm -f conftest.o
71 return $ret
72 }
74 m4_divert_once([HELP_ENABLE], [
75 Build options:])
77 dnl Optionally stick to standard C99 and POSIX:2001 as close as possible.
78 AC_ARG_ENABLE([standards],
79 AS_HELP_STRING([--enable-standards],
80 [C99 / POSIX standards compliance mode @<:@default=no@:>@]),
81 [enable_standards="$enableval"],
82 [enable_standards="no"])
84 if test "x$enable_standards" = "xyes"; then
85 AC_DEFINE([_ISOC99_SOURCE], 1,
86 [Define to enforce ISO/IEC 9899:1999 (C99) compliance.])
87 AC_DEFINE([_POSIX_C_SOURCE], 200112L,
88 [Define to enforce IEEE 1003.1-2001 (POSIX:2001) compliance.])
89 AC_DEFINE([_XOPEN_SOURCE], 600,
90 [Define to enforce X/Open 6 (XSI) compliance.])
91 AC_DEFINE([_REENTRANT], 1,
92 [Define to enable reentrant interfaces.])
93 AC_DEFINE([_THREAD_SAFE], 1,
94 [Define to enable reentrant interfaces.])
96 for flag in -std=c99 -pedantic; do
97 AC_MSG_CHECKING([whether $CC accepts $flag])
99 if test_cc_flags $flag; then
100 CFLAGS="$CFLAGS $flag"
101 AC_MSG_RESULT([yes])
102 else
103 AC_MSG_RESULT([no])
104 fi
105 done
106 fi
108 dnl Hardening (see e.g. http://wiki.debian.org/Hardening for a motivation).
109 AC_DEFINE([_FORTIFY_SOURCE], 2,
110 [Define to enable protection against static sized buffer overflows.])
111 AC_ARG_ENABLE([hardening],
112 AS_HELP_STRING([--disable-hardening],
113 [hardening options @<:@default=yes@:>@]),
114 [enable_hardening="$enableval"],
115 [enable_hardening="yes"])
117 if test "x$enable_hardening" = "xyes"; then
118 hardening=0
119 hardening_tests=0
120 for flag in -Wformat -Wformat-security; do
121 hardening_tests=$(($hardening_tests + 1))
122 AC_MSG_CHECKING([whether $CC accepts $flag])
124 if test_cc_flags $flag; then
125 CFLAGS="$CFLAGS $flag"
126 hardening=$(($hardening + 1))
127 AC_MSG_RESULT([yes])
128 else
129 AC_MSG_RESULT([no])
130 fi
131 done
132 if test $hardening -ne $hardening_tests; then
133 AC_MSG_WARN(
134 [Some hardening options are not supported by your compiler!])
135 fi
136 fi
138 dnl Strict checking for potential problems.
139 AC_ARG_ENABLE([strict-checks],
140 AS_HELP_STRING([--disable-strict-checks],
141 [strict compiler checks @<:@default=yes@:>@]),
142 [enable_strict_checks="$enableval"],
143 [enable_strict_checks="yes"])
145 STRICT_CFLAGS=""
146 for flag in -Wall -Werror; do
147 AC_MSG_CHECKING([whether $CC accepts $flag])
149 if test_cc_flags $flag; then
150 STRICT_CFLAGS="$STRICT_CFLAGS $flag"
151 AC_MSG_RESULT([yes])
152 else
153 AC_MSG_RESULT([no])
154 fi
155 done
157 if test "x$enable_strict_checks" = "xyes"; then
158 for flag in -Wextra \
159 -Wbad-function-cast \
160 -Wcast-align \
161 -Wcast-qual \
162 -Wconversion \
163 -Wdeclaration-after-statement \
164 -Wmissing-prototypes \
165 -Wpointer-arith \
166 -Wshadow \
167 -Wstrict-prototypes \
168 -Wunreachable-code; do
169 AC_MSG_CHECKING([whether $CC accepts $flag])
171 if test_cc_flags $flag; then
172 STRICT_CFLAGS="$STRICT_CFLAGS $flag"
173 AC_MSG_RESULT([yes])
174 else
175 AC_MSG_RESULT([no])
176 fi
177 done
178 fi
179 AC_SUBST([STRICT_CFLAGS])
181 AC_CHECK_HEADERS(libgen.h)
183 dnl Check for dependencies.
184 build_documentation="yes"
186 have_xsltproc="yes"
187 AC_PATH_PROG([XSLTPROC], [xsltproc])
188 if test "x$XSLTPROC" = "x"; then
189 have_xsltproc="no"
190 build_documentation="no (missing xsltproc)"
191 fi
193 have_a2x="yes"
194 AC_PATH_PROG([A2X], [a2x])
195 if test "x$A2X" = "x"; then
196 have_a2x="no"
197 build_documentation="no (missing a2x)"
198 fi
199 AC_SUBST([A2X])
201 AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes")
203 PKG_CHECK_MODULES([CAIRO], [cairo])
204 PKG_CHECK_MODULES([GTK2], [gtk+-2.0])
205 PKG_CHECK_MODULES([POPPLER_GLIB], [poppler-glib])
207 if test "x$enable_strict_checks" = "xyes"; then
208 # Some Gtk headers generate warnings when doing strict checking, which
209 # would result in unnecessary compile errors
210 AC_MSG_NOTICE([Try to suppress warnings from Gtk headers...])
211 for flag in `$PKG_CONFIG --cflags-only-I gtk+-2.0`; do
212 I_dir=${flag#-I}
214 flag="-isystem $I_dir"
215 AC_MSG_CHECKING([whether $CC accepts $flag])
216 if test_cc_flags "$flag"; then
217 STRICT_CFLAGS="$STRICT_CFLAGS $flag"
218 AC_MSG_RESULT([yes])
219 else
220 AC_MSG_RESULT([no])
221 fi
222 done
223 fi
225 AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile])
226 AC_OUTPUT
228 cat <<EOF;
230 $PACKAGE_NAME has been configured successfully.
232 Run 'make' to compile the software and use 'make install' to
233 install the package into $prefix.
235 Configuration summary:
237 package version: $PACKAGE_VERSION
238 build date: `date --utc '+%F %T'` (UTC)
240 Tools:
241 AsciiDoc (a2x): . . . . . . $have_a2x
242 xsltproc: . . . . . . . . . $have_xsltproc
244 Libraries:
245 libcairo: . . . . . . . . . `$PKG_CONFIG --modversion cairo`
246 libgtk-2.0: . . . . . . . . `$PKG_CONFIG --modversion gtk+-2.0`
247 libpoppler-glib: . . . . . `$PKG_CONFIG --modversion poppler-glib`
249 Features:
250 documentation: . . . . . . $build_documentation
252 This package is maintained by $PACKAGE_MAINTAINER.
253 Please report bugs to $PACKAGE_BUGREPORT.
255 EOF