1 # configure.ac - for libksba
2 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
3 # 2010, 2011, 2012 g10 Code GmbH
5 # This file is part of KSBA
7 # KSBA is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # KSBA is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, see <http://www.gnu.org/licenses/>.
20 # Process this file with autoconf to produce a configure script.
22 min_automake_version="1.14"
25 # To build a release you need to create a tag with the version number
26 # (git tag -s libksba-n.m.k) and run "./autogen.sh --force". Please
27 # bump the version number immediately after the release and do another
28 # commit and push so that the git magic is able to work. See below
29 # for the LT versions.
30 m4_define([mym4_package],[libksba])
31 m4_define([mym4_major], [1])
32 m4_define([mym4_minor], [3])
33 m4_define([mym4_micro], [4])
35 # Below is m4 magic to extract and compute the git revision number,
36 # the decimalized short revision number, a beta version string and a
37 # flag indicating a development version (mym4_isbeta). Note that the
38 # m4 processing is done by autoconf and not during the configure run.
39 m4_define([mym4_verslist], m4_split(m4_esyscmd([./autogen.sh --find-version] \
40 mym4_package mym4_major mym4_minor mym4_micro),[:]))
41 m4_define([mym4_isbeta], m4_argn(2, mym4_verslist))
42 m4_define([mym4_version], m4_argn(4, mym4_verslist))
43 m4_define([mym4_revision], m4_argn(7, mym4_verslist))
44 m4_define([mym4_revision_dec], m4_argn(8, mym4_verslist))
45 m4_esyscmd([echo ]mym4_version[>VERSION])
46 AC_INIT([mym4_package],[mym4_version], [http://bugs.gnupg.org])
48 # LT Version numbers: Remember to change them just *before* a release.
49 # (Interfaces removed: CURRENT++, AGE=0, REVISION=0)
50 # (Interfaces added: CURRENT++, AGE++, REVISION=0)
51 # (No interfaces changed: REVISION++)
52 # Please remember to document interface changes in the NEWS file.
57 # If the API is changed in an incompatible way: increment the next counter.
58 KSBA_CONFIG_API_VERSION=1
61 NEED_GPG_ERROR_VERSION=1.8
65 VERSION=$PACKAGE_VERSION
67 AC_CONFIG_AUX_DIR([build-aux])
68 AC_CONFIG_SRCDIR([src/ksba.h])
69 AM_INIT_AUTOMAKE([serial-tests dist-bzip2 no-dist-gzip])
70 AM_CONFIG_HEADER(config.h)
71 AC_CONFIG_MACRO_DIR([m4])
78 LT_INIT([win32-dll disable-static])
79 LT_LANG([Windows Resource])
84 AC_SUBST(LIBKSBA_LT_CURRENT)
85 AC_SUBST(LIBKSBA_LT_AGE)
86 AC_SUBST(LIBKSBA_LT_REVISION)
89 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
90 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
93 #ifndef _KSBA_CONFIG_H_INCLUDED
94 #define _KSBA_CONFIG_H_INCLUDED
96 /* Enable gpg-error's strerror macro for W32CE. */
97 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
102 #endif /*_KSBA_CONFIG_H_INCLUDED*/
107 # Checks for programs.
108 missing_dir=`cd $ac_aux_dir && pwd`
109 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
110 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
111 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
112 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
113 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
119 if test "x$ac_cv_prog_cc_c89" = "xno" ; then
120 AC_MSG_ERROR([[No C-89 compiler found]])
130 # We need to compile and run a program on the build machine.
131 # The AC_PROG_CC_FOR_BUILD macro in the AC archive is broken for
133 AC_MSG_CHECKING(for cc for build)
134 if test "$cross_compiling" = "yes"; then
135 CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
137 CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
139 AC_MSG_RESULT($CC_FOR_BUILD)
140 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
143 # This is handy for debugging so the compiler doesn't rearrange
144 # things and eliminate variables.
145 AC_ARG_ENABLE(optimization,
146 AC_HELP_STRING([--disable-optimization],
147 [disable compiler optimization]),
148 [if test $enableval = no ; then
149 CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
152 if test "$GCC" = yes; then
153 CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
155 if test "$USE_MAINTAINER_MODE" = "yes"; then
156 CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
158 # We use -W only if -Wno-missing-field-initializers is supported.
159 # -W is important because it detects errors like "if (foo);"
160 AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
161 _gcc_cflags_save=$CFLAGS
162 CFLAGS="-Wno-missing-field-initializers"
163 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
164 AC_MSG_RESULT($_gcc_wopt)
165 CFLAGS=$_gcc_cflags_save;
166 if test x"$_gcc_wopt" = xyes ; then
167 CFLAGS="$CFLAGS -W -Wno-sign-compare -Wno-missing-field-initializers"
170 AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement])
171 _gcc_cflags_save=$CFLAGS
172 CFLAGS="-Wdeclaration-after-statement"
173 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
174 AC_MSG_RESULT($_gcc_wopt)
175 CFLAGS=$_gcc_cflags_save;
176 if test x"$_gcc_wopt" = xyes ; then
177 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
181 AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
182 _gcc_cflags_save=$CFLAGS
183 CFLAGS="-Wpointer-arith"
184 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
185 AC_MSG_RESULT($_gcc_wopt)
186 CFLAGS=$_gcc_cflags_save;
187 if test x"$_gcc_wopt" = xyes ; then
188 CFLAGS="$CFLAGS -Wpointer-arith"
191 AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
192 _gcc_cflags_save=$CFLAGS
193 CFLAGS="-Wno-pointer-sign"
194 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_psign=yes,_gcc_psign=no)
195 AC_MSG_RESULT($_gcc_psign)
196 CFLAGS=$_gcc_cflags_save;
197 if test x"$_gcc_psign" = xyes ; then
198 CFLAGS="$CFLAGS -Wno-pointer-sign"
203 # Setup some stuff depending on host.
209 have_w32ce_system=yes
217 if test "$have_w32_system" = yes; then
218 AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
219 if test "$have_w32ce_system" = yes; then
220 AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
223 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
224 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
227 # For some systems we know that we have ld_version scripts.
228 # Use it then as default.
229 have_ld_version_script=no
232 have_ld_version_script=yes
235 have_ld_version_script=yes
238 AC_ARG_ENABLE([ld-version-script],
239 AC_HELP_STRING([--enable-ld-version-script],
240 [enable/disable use of linker version script.
241 (default is system dependent)]),
242 [have_ld_version_script=$enableval],
244 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
248 # Check for ELF visibility support.
250 AC_CACHE_CHECK(whether the visibility attribute is supported,
251 ksba_cv_visibility_attribute,
252 [ksba_cv_visibility_attribute=no
253 AC_LANG_CONFTEST([AC_LANG_SOURCE(
254 [[int foo __attribute__ ((visibility ("hidden"))) = 1;
255 int bar __attribute__ ((visibility ("protected"))) = 1;
258 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
259 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
260 if grep '\.hidden.*foo' conftest.s >/dev/null 2>&1 ; then
261 if grep '\.protected.*bar' conftest.s >/dev/null 2>&1; then
262 ksba_cv_visibility_attribute=yes
267 if test "$ksba_cv_visibility_attribute" = "yes"; then
268 AC_CACHE_CHECK(for broken visibility attribute,
269 ksba_cv_broken_visibility_attribute,
270 [ksba_cv_broken_visibility_attribute=yes
271 AC_LANG_CONFTEST([AC_LANG_SOURCE(
273 int bar (int x) __asm__ ("foo")
274 __attribute__ ((visibility ("hidden")));
275 int bar (int x) { return x; }
278 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
279 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
280 if grep '\.hidden@<:@ _@:>@foo' conftest.s >/dev/null 2>&1;
282 ksba_cv_broken_visibility_attribute=no
287 if test "$ksba_cv_visibility_attribute" = "yes"; then
288 AC_CACHE_CHECK(for broken alias attribute,
289 ksba_cv_broken_alias_attribute,
290 [ksba_cv_broken_alias_attribute=yes
291 AC_LANG_CONFTEST([AC_LANG_SOURCE(
292 [[extern int foo (int x) __asm ("xyzzy");
293 int bar (int x) { return x; }
294 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
296 extern __typeof (dfoo) dfoo __asm ("abccb");
300 if ${CC-cc} -Werror -S conftest.c -o conftest.s \
301 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
302 if grep 'xyzzy' conftest.s >/dev/null 2>&1 && \
303 grep 'abccb' conftest.s >/dev/null 2>&1; then
304 ksba_cv_broken_alias_attribute=no
309 if test "$ksba_cv_visibility_attribute" = "yes"; then
310 AC_CACHE_CHECK(if gcc supports -fvisibility=hidden,
311 ksba_cv_gcc_has_f_visibility,
312 [ksba_cv_gcc_has_f_visibility=no
313 _gcc_cflags_save=$CFLAGS
314 CFLAGS="-fvisibility=hidden"
315 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
316 ksba_cv_gcc_has_f_visibility=yes)
317 CFLAGS=$_gcc_cflags_save;
320 if test "$ksba_cv_visibility_attribute" = "yes" \
321 && test "$ksba_cv_broken_visibility_attribute" != "yes" \
322 && test "$ksba_cv_broken_alias_attribute" != "yes" \
323 && test "$ksba_cv_gcc_has_f_visibility" = "yes"
325 AC_DEFINE(KSBA_USE_VISIBILITY, 1,
326 [Define to use the GNU C visibility attribute.])
327 CFLAGS="$CFLAGS -fvisibility=hidden"
332 # Checks for libraries.
334 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION")
335 if test "x$GPG_ERROR_LIBS" = "x"; then
336 AC_MSG_ERROR([libgpg-error is needed.
337 See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .])
340 AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_KSBA,
341 [The default error source for libksba.])
344 # Checks for header files.
346 AC_CHECK_HEADERS([string.h])
348 # Checks for typedefs, structures, and compiler characteristics.
353 AC_CHECK_SIZEOF(unsigned int)
354 AC_CHECK_SIZEOF(unsigned long)
355 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
358 # Checks for library functions.
359 AC_CHECK_FUNCS([memmove strchr strtol strtoul stpcpy gmtime_r getenv])
365 gl_MODULES(alloca valgrind-tests)
368 # To be used in ksba-config
369 KSBA_CONFIG_LIBS="-lksba"
370 KSBA_CONFIG_CFLAGS=""
371 KSBA_CONFIG_HOST="$host"
372 AC_SUBST(KSBA_CONFIG_LIBS)
373 AC_SUBST(KSBA_CONFIG_CFLAGS)
374 AC_SUBST(KSBA_CONFIG_API_VERSION)
375 AC_SUBST(KSBA_CONFIG_HOST)
377 # The Makefiles need to know about cross compiling
378 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling != xno)
381 # Generate extended version information for W32.
382 if test "$have_w32_system" = yes; then
384 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
386 BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
388 AC_SUBST(BUILD_REVISION)
389 AC_SUBST(BUILD_FILEVERSION)
390 BUILD_REVISION="mym4_revision"
391 AC_SUBST(BUILD_REVISION)
392 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
393 [GIT commit id revision used to build this package])
395 AC_ARG_ENABLE([build-timestamp],
396 AC_HELP_STRING([--enable-build-timestamp],
397 [set an explicit build timestamp for reproducibility.
398 (default is the current time in ISO-8601 format)]),
399 [if test "$enableval" = "yes"; then
400 BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
402 BUILD_TIMESTAMP="$enableval"
404 [BUILD_TIMESTAMP="<none>"])
405 AC_SUBST(BUILD_TIMESTAMP)
406 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
407 [The time this package was configured for a build])
424 Libksba v${VERSION} has been configured as follows:
426 Revision: mym4_revision (mym4_revision_dec)