1# configure.ac for GPA
2# Copyright (C) 2000, 2001  Werner Koch
3# Copyright (C) 2002, 2003, 2004  Miguel Coca
4# Copyright (C) 2005-2016   g10 Code GmbH
5#
6# This file is part of GPA.
7#
8# GPA is free software; you can redistribute it and/or modify it under
9# the terms of the GNU General Public License as published by the Free
10# Software Foundation; either version 3 of the License, or (at your
11# option) any later version.
12#
13# GPA is distributed in the hope that it will be useful but WITHOUT
14# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16# License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, see <http://www.gnu.org/licenses/>.
20#
21# (Process this file with autoconf to produce a configure script.)
22AC_PREREQ(2.61)
23min_automake_version="1.10"
24
25# The version number goes here.
26#
27# To build a release you need to create a tag with the version number
28# (git tag -s gpa-1.n.m) and run "./autogen.sh --force".  Please
29# bump the version number immediately *after* the release and do
30# another commit and push so that the git magic is able to work.
31m4_define(mym4_version_major, [0])
32m4_define(mym4_version_minor, [10])
33m4_define(mym4_version_micro, [0])
34
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_isgit).  Note that the
38# m4 processing is done by autoconf and not during the configure run.
39m4_define(mym4_version,
40          [mym4_version_major.mym4_version_minor.mym4_version_micro])
41m4_define([mym4_revision],
42          m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
43m4_define([mym4_revision_dec],
44          m4_esyscmd_s([echo $((0x$(echo ]mym4_revision[|head -c 4)))]))
45m4_define([mym4_betastring],
46          m4_esyscmd_s([git describe --match 'gpa-[0-9].*[0-9]' --long|\
47                        awk -F- '$3!=0{print"-beta"$3}']))
48m4_define([mym4_isgit],m4_if(mym4_betastring,[],[no],[yes]))
49m4_define([mym4_full_version],[mym4_version[]mym4_betastring])
50
51AC_INIT([gpa],[mym4_full_version],[https://bugs.gnupg.org])
52
53
54NEED_GPG_ERROR_VERSION=1.27
55NEED_LIBASSUAN_API=2
56NEED_LIBASSUAN_VERSION=2.4.2
57NEED_GPGME_API=1
58NEED_GPGME_VERSION=1.9.0
59
60AC_CONFIG_AUX_DIR([build-aux])
61AM_CONFIG_HEADER(config.h)
62AC_CONFIG_SRCDIR(src/gpa.c)
63AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip])
64
65PACKAGE=$PACKAGE_NAME
66VERSION=$PACKAGE_VERSION
67AC_SUBST(PACKAGE)
68AC_SUBST(VERSION)
69AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
70AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
71
72AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$PACKAGE_BUGREPORT",
73                                      [address for reporting bugs])
74
75have_gpg_error=no
76have_gpgme=no
77have_libassuan=no
78
79
80#
81# Provide information about the build.
82#
83BUILD_REVISION="mym4_revision"
84AC_SUBST(BUILD_REVISION)
85AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
86                   [GIT commit id revision used to build this package])
87
88changequote(,)dnl
89BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
90changequote([,])dnl
91BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
92AC_SUBST(BUILD_FILEVERSION)
93
94BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
95AC_SUBST(BUILD_TIMESTAMP)
96AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
97                   [The time this package was configured for a build])
98
99
100
101
102AC_GNU_SOURCE
103
104AH_BOTTOM([
105/* We don't want the old assuan codes anymore. */
106#define _ASSUAN_ONLY_GPG_ERRORS 1
107
108#include "gpadefs.h"
109])
110
111
112AM_MAINTAINER_MODE
113AM_SILENT_RULES
114
115dnl Check for libraries
116AC_CHECK_LIB(m, sin)
117CHECK_ZLIB
118AC_CHECK_FUNCS([strsep stpcpy])
119
120development_version=no
121# Allow users to append something to the version string (other than -cvs)
122# without flagging it as development version.  The user version parts is
123# considered everything after a dash.
124if test "$development_version" != yes; then
125  changequote(,)dnl
126  tmp_pat='[a-zA-Z]'
127  changequote([,])dnl
128  if echo "$VERSION" | sed 's/-.*//' | grep "$tmp_pat" >/dev/null ||
129     echo "$VERSION" | grep -- "-cvs$" >/dev/null; then
130    development_version=yes
131  fi
132fi
133if test "$development_version" = yes; then
134    AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
135            [Defined if this is not a regular release])
136fi
137
138
139# Define HAVE_W32_SYSTEM as an alternative to the other macros which
140# might led the naive reader assume that W32 is actually a win.  Also
141# needed later to enable certain gcc options.
142have_w32_system=no
143case "${host}" in
144    *-mingw32*) have_w32_system=yes ;;
145esac
146if test "$have_w32_system" = yes; then
147   AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
148fi
149AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
150
151
152
153dnl
154dnl Checks for programs
155dnl
156AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
157AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
158AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
159AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
160AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
161AC_PROG_CC
162AC_ISC_POSIX
163AC_STDC_HEADERS
164AC_PROG_RANLIB
165AC_CHECK_TOOL(WINDRES, windres, :)
166
167
168#
169#  Options to disable features
170#
171card_manager=yes
172AC_MSG_CHECKING([whether to build the card manager])
173AC_ARG_ENABLE(card-manager,
174              AC_HELP_STRING([--disable-card-manager],
175                             [build without the card manager]),
176              card_manager=$enableval)
177AC_MSG_RESULT($card_manager)
178if test "$card_manager" = yes ; then
179  AC_DEFINE(ENABLE_CARD_MANAGER, 1, [Include the card manager in the build])
180fi
181AM_CONDITIONAL(ENABLE_CARD_MANAGER, test "$card_manager" = yes)
182
183keyserver_support=yes
184AC_MSG_CHECKING([whether to include keyserver support])
185AC_ARG_ENABLE(keyserver-support,
186              AC_HELP_STRING([--disable-keyserver-support],
187                             [build without keyserver support]),
188              keyserver_support=$enableval)
189AC_MSG_RESULT($keyserver_support)
190if test "$keyserver_support" = yes ; then
191  AC_DEFINE(ENABLE_KEYSERVER_SUPPORT, 1,
192            [Include keyserver support in the build])
193fi
194AM_CONDITIONAL(ENABLE_KEYSERVER_SUPPORT, test "$keyserver_support" = yes)
195
196
197#
198# Find the keyserver plugins. Assume that gpgkeys_ldap is always available
199#
200if test "$keyserver_support" = yes ; then
201  AC_PATH_PROGS(GPGKEYS_LDAP, gpg2keys_ldap gpgkeys_ldap,
202               [${libexecdir}/gnupg/gpg2keys_ldap],
203               [$PATH:/usr/libexec/gnupg:/usr/lib/gnupg2:/usr/lib/gnupg])
204  KEYSERVER_HELPERS_DIR=`dirname $GPGKEYS_LDAP`
205  if test -z "$KEYSERVER_HELPERS_DIR"; then
206       AC_MSG_ERROR([[
207***
208*** Keyserver helpers not found. They should be contained in the GnuPG package.
209***
210    ]])
211  fi
212  AC_DEFINE_UNQUOTED(KEYSERVER_HELPERS_DIR,
213                     "$KEYSERVER_HELPERS_DIR", [Path to keyserver helper tools])
214fi
215
216
217dnl
218dnl Checks for compiler features
219dnl
220
221
222dnl
223dnl Checks for libraries
224dnl
225NETLIBS=
226if test "$have_w32_system" = yes; then
227   NETLIBS="${NETLIBS} -lws2_32"
228fi
229AC_SUBST(NETLIBS)
230
231
232AM_PO_SUBDIRS
233AM_GNU_GETTEXT_VERSION([0.18.1])
234AM_GNU_GETTEXT([external],[need-ngettext])
235
236
237dnl Where is the GTK+ toolkit
238AM_PATH_GTK_2_0(2.10.0,, AC_MSG_ERROR(Cannot find GTK+ 2.0))
239
240
241#
242# The GnuPG shared error codes library.
243#
244AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
245                  have_gpg_error=yes,have_gpg_error=no)
246AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, 12,
247          [The default error source for GPA.])
248
249#
250# Libassuan is the IPC library used for the server mode
251#
252AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
253                  have_libassuan=yes,have_libassuan=no)
254
255# We need this for GPGME
256AC_SYS_LARGEFILE
257
258#
259# Depending on the OS we need to test for different versions of gpgme.
260#
261_AM_PATH_GPGME_CONFIG
262if test "$have_w32_system" = yes; then
263  AM_PATH_GPGME_GLIB("$NEED_GPGME_API:$NEED_GPGME_VERSION",
264                     have_gpgme=yes,have_gpgme=no)
265  GPGME_LIBS="$GPGME_GLIB_LIBS"
266  GPGME_CFLAGS="$GPGME_GLIB_CFLAGS"
267  AC_SUBST(GPGME_CFLAGS)
268  AC_SUBST(GPGME_LIBS)
269else
270  AM_PATH_GPGME("$NEED_GPGME_API:$NEED_GPGME_VERSION",
271                have_gpgme=yes,have_gpgme=no)
272fi
273
274_save_libs=$LIBS
275_save_cflags=$CFLAGS
276LIBS="$LIBS $GPGME_LIBS"
277CFLAGS="$CFLAGS $GPGME_CFLAGS"
278AC_CHECK_FUNCS([gpgme_data_identify])
279LIBS=$_save_libs
280CFLAGS="$_save_cflags"
281
282
283dnl The tests below are not anymore used because we now depend on a
284dnl gpgme which has all these features.  However, I keep the code here
285dnl for future work.
286dnl
287dnl _save_libs=$LIBS
288dnl _save_cflags=$CFLAGS
289dnl LIBS="$LIBS $GPGME_LIBS"
290dnl CFLAGS="$CFLAGS $GPGME_CFLAGS"
291dnl AC_CHECK_FUNCS([gpgme_op_assuan_transact])
292dnl AC_CHECK_FUNCS([gpgme_io_write])
293dnl # Fixme:  We should write a test based on gpgme_subkey_t
294dnl #         We might even want to put such a test into gpgme.m4.
295dnl AC_CHECK_MEMBERS([struct _gpgme_subkey.card_number],,,[#include <gpgme.h>])
296dnl LIBS=$_save_libs
297dnl CFLAGS="$_save_cflags"
298dnl # We build the card manager only if we have a decent libgpgme.  */
299dnl if test "x$ac_cv_func_gpgme_op_assuan_transact" = "xyes"; then
300dnl     AC_DEFINE(BUILD_CARD_MANAGER, 1,
301dnl               [Defined if the card manager shall be build.])
302dnl fi
303dnl AM_CONDITIONAL(BUILD_CARD_MANAGER,
304dnl                test "x$ac_cv_func_gpgme_op_assuan_transact" = "xyes")
305
306
307#
308# Checks for header files.
309#
310AC_MSG_NOTICE([checking for header files])
311AC_CHECK_HEADERS([locale.h])
312
313#
314# Checks for typedefs and structures
315#
316
317GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
318GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
319GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
320GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
321GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
322
323#
324# Check for library functions
325#
326
327# See whether libc supports the Linux inotify interface
328case "${host}" in
329    *-*-linux*)
330        AC_CHECK_FUNCS([inotify_init])
331        ;;
332esac
333
334
335#
336# Set extra compiler flags
337#
338AC_MSG_NOTICE([checking for cc features])
339if test "$GCC" = yes; then
340    if test "$USE_MAINTAINER_MODE" = "yes"; then
341        #
342        # Enable all kinds of warnings.
343        #
344        CFLAGS="$CFLAGS -O3 -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
345        CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
346
347        AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
348        _gcc_cflags_save=$CFLAGS
349        CFLAGS="-Wno-missing-field-initializers"
350        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
351        AC_MSG_RESULT($_gcc_wopt)
352        CFLAGS=$_gcc_cflags_save;
353        if test x"$_gcc_wopt" = xyes ; then
354          CFLAGS="$CFLAGS -W -Wno-sign-compare -Wno-missing-field-initializers"
355        fi
356
357        AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement])
358        _gcc_cflags_save=$CFLAGS
359        CFLAGS="-Wdeclaration-after-statement"
360        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
361        AC_MSG_RESULT($_gcc_wopt)
362        CFLAGS=$_gcc_cflags_save;
363        if test x"$_gcc_wopt" = xyes ; then
364          CFLAGS="$CFLAGS -Wdeclaration-after-statement"
365        fi
366
367	# We should keep -Wstrict-prototypes here.  However, it causes
368	# too many warnings in gtkitemfactory.h:51 (see comment over
369	# there).  This might be solved with GTK 3.
370        AC_MSG_CHECKING([if gcc supports -Wno-strict-prototypes])
371        _gcc_cflags_save=$CFLAGS
372        CFLAGS="-Wno-strict-prototypes"
373        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
374        AC_MSG_RESULT($_gcc_wopt)
375        CFLAGS=$_gcc_cflags_save;
376        if test x"$_gcc_wopt" = xyes ; then
377          CFLAGS="$CFLAGS -Wno-strict-prototypes"
378        fi
379
380    else
381        CFLAGS="$CFLAGS -Wall"
382    fi
383
384    AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
385    _gcc_cflags_save=$CFLAGS
386    CFLAGS="-Wno-pointer-sign"
387    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
388    AC_MSG_RESULT($_gcc_wopt)
389    CFLAGS=$_gcc_cflags_save;
390    if test x"$_gcc_wopt" = xyes ; then
391       CFLAGS="$CFLAGS -Wno-pointer-sign"
392    fi
393
394    AC_MSG_CHECKING([if gcc supports -Wno-unused-parameter])
395    _gcc_cflags_save=$CFLAGS
396    CFLAGS="-Wno-unused-parameter"
397    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
398    AC_MSG_RESULT($_gcc_wopt)
399    CFLAGS=$_gcc_cflags_save;
400    if test x"$_gcc_wopt" = xyes ; then
401       CFLAGS="$CFLAGS -Wno-unused-parameter"
402    fi
403
404    # We need to use ms-bitfields.
405    if test "$have_w32_system" = yes; then
406       CFLAGS="$CFLAGS -mms-bitfields"
407    fi
408fi
409
410
411#
412# Define name strings
413AC_DEFINE_UNQUOTED(GPA_NAME, "GPA", [The name of this program])
414AC_DEFINE_UNQUOTED(GPA_LONG_NAME, "GNU Privacy Assistant",
415                                   [The spelled out name of this program])
416
417
418#
419# Print errors here so that they are visible all
420# together and the user can acquire them all together.
421#
422die=no
423if test "$have_gpg_error" = "no"; then
424   die=yes
425   AC_MSG_NOTICE([[
426***
427*** You need libgpg-error to build this program.
428**  This library is for example available at
429***   ftp://ftp.gnupg.org/gcrypt/libgpg-error
430*** (at least version $NEED_GPG_ERROR_VERSION is required.)
431***]])
432fi
433if test "$have_gpgme" = "no"; then
434   die=yes
435   AC_MSG_NOTICE([[
436***
437*** You need gpgme to build this program.
438**  This library is for example available at
439***   ftp://ftp.gnupg.org/gcrypt/gpgme/
440*** (at least version $NEED_GPGME_VERSION is required.)
441***]])
442fi
443if test "$have_libassuan" = "no"; then
444   die=yes
445   AC_MSG_NOTICE([[
446***
447*** You need libassuan to build this program.
448*** This library is for example available at
449***   ftp://ftp.gnupg.org/gcrypt/libassuan/
450*** (at least version $NEED_LIBASSUAN_VERSION is required).
451***]])
452fi
453if test "$die" = "yes"; then
454    AC_MSG_ERROR([[
455***
456*** Required libraries not found. Please consult the above messages
457*** and install them before running configure again.
458***]])
459fi
460
461
462AC_CONFIG_FILES([ m4/Makefile
463Makefile
464po/Makefile.in
465src/Makefile
466src/versioninfo.rc
467pixmaps/Makefile
468doc/Makefile
469])
470
471
472AC_OUTPUT
473
474echo "
475        GPA v${VERSION} has been configured as follows:
476
477        Revision:  mym4_revision  (mym4_revision_dec)
478        Platform:  $host
479"