Code

3ef87037520f52fbe3f297fc50233231558b7783
[tpdfview.git] / configure.ac
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                         -Wunreachable-code; do
168                 AC_MSG_CHECKING([whether $CC accepts $flag])
170                 if test_cc_flags $flag; then
171                         STRICT_CFLAGS="$STRICT_CFLAGS $flag"
172                         AC_MSG_RESULT([yes])
173                 else
174                         AC_MSG_RESULT([no])
175                 fi
176         done
177 fi
178 AC_SUBST([STRICT_CFLAGS])
180 AC_CHECK_HEADERS(libgen.h)
182 dnl Check for dependencies.
183 build_documentation="yes"
185 have_xsltproc="yes"
186 AC_PATH_PROG([XSLTPROC], [xsltproc])
187 if test "x$XSLTPROC" = "x"; then
188         have_xsltproc="no"
189         build_documentation="no (missing xsltproc)"
190 fi
192 have_a2x="yes"
193 AC_PATH_PROG([A2X], [a2x])
194 if test "x$A2X" = "x"; then
195         have_a2x="no"
196         build_documentation="no (missing a2x)"
197 fi
198 AC_SUBST([A2X])
200 AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes")
202 PKG_CHECK_MODULES([CAIRO], [cairo])
203 PKG_CHECK_MODULES([GTK2], [gtk+-2.0])
204 PKG_CHECK_MODULES([POPPLER_GLIB], [poppler-glib])
206 AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile])
207 AC_OUTPUT
209 cat <<EOF;
211 $PACKAGE_NAME has been configured successfully.
213 Run 'make' to compile the software and use 'make install' to
214 install the package into $prefix.
216 Configuration summary:
218   package version: $PACKAGE_VERSION
219   build date: `date --utc '+%F %T'` (UTC)
221   Tools:
222     AsciiDoc (a2x): . . . . . . $have_a2x
223     xsltproc: . . . . . . . . . $have_xsltproc
225   Libraries:
226     libcairo: . . . . . . . . . `$PKG_CONFIG --modversion cairo`
227     libgtk-2.0: . . . . . . . . `$PKG_CONFIG --modversion gtk+-2.0`
228     libpoppler-glib:  . . . . . `$PKG_CONFIG --modversion poppler-glib`
230   Features:
231     documentation:  . . . . . . $build_documentation
233 This package is maintained by $PACKAGE_MAINTAINER.
234 Please report bugs to $PACKAGE_BUGREPORT.
236 EOF