build: Update m4/iconv.m4.
[pinentry.git] / configure.ac
1 # configure.ac
2 # Copyright (C) 1999 Robert Bihlmeyer <robbe@orcus.priv.at>
3 # Copyright (C) 2001, 2002, 2003, 2004, 2007, 2015, 2016 g10 Code GmbH
4 #
5 # This file is part of PINENTRY.
6 #
7 # PINENTRY 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 2 of the License, or
10 # (at your option) any later version.
11 #
12 # PINENTRY 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.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, see <https://www.gnu.org/licenses/>.
19 # SPDX-License-Identifier: GPL-2.0+
20
21 # (Process this file with autoconf to produce a configure script.)
22 AC_PREREQ(2.69)
23 min_automake_version="1.14"
24
25 # To build a release you need to create a tag with the version number
26 # (git tag -s pinentry-n.m.k) and run "./autogen.sh --force".  Please
27 # bump the version number immediately after the release, do another
28 # commit, and a push so that the git magic is able to work.
29 m4_define(mym4_version, [1.1.1])
30
31 # Below is m4 magic to extract and compute the git revision number,
32 # the decimalized short revision number, a beta version string and a
33 # flag indicating a development version (mym4_isgit).  Note that the
34 # m4 processing is done by autoconf and not during the configure run.
35 m4_define([mym4_revision], m4_esyscmd([git branch -v 2>/dev/null \
36           | awk '/^\* / {printf "%s",$3}']))
37 m4_define([mym4_revision_dec],
38           m4_esyscmd_s([echo $((0x$(echo ]mym4_revision[|head -c 4)))]))
39 m4_define([mym4_betastring],
40           m4_esyscmd_s([git describe --match 'pinentry-[0-9].[0-9].*[0-9]' \
41                            --long|  awk -F- '$3!=0{print"-beta"$3}']))
42 m4_define([mym4_isgit],m4_if(mym4_betastring,[],[no],[yes]))
43 m4_define([mym4_full_version],[mym4_version[]mym4_betastring])
44
45 AC_INIT([pinentry],[mym4_full_version], [https://bugs.gnupg.org])
46
47 AC_CONFIG_AUX_DIR([build-aux])
48 AM_CONFIG_HEADER(config.h)
49 AC_CONFIG_SRCDIR(pinentry/pinentry.h)
50 AM_INIT_AUTOMAKE([serial-tests dist-bzip2 no-dist-gzip])
51
52 AC_GNU_SOURCE
53
54 AM_MAINTAINER_MODE
55
56 AC_CANONICAL_HOST
57
58 AH_TOP([
59 #ifndef PINENTRY_CONFIG_H_INCLUDED
60 #define PINENTRY_CONFIG_H_INCLUDED
61
62 /* Enable gpg-error's strerror macro under W32CE.  */
63 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
64 ])
65
66 AH_BOTTOM([
67 #endif /*PINENTRY_CONFIG_H_INCLUDED*/
68 ])
69
70
71 dnl Checks for programs.
72 AC_PROG_MAKE_SET
73 AM_SANITY_CHECK
74 missing_dir=`cd $ac_aux_dir && pwd`
75 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
76 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
77 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
78 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
79 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
80 AC_PROG_CC
81 AC_PROG_CPP
82 AC_PROG_INSTALL
83 AC_PROG_RANLIB
84 # We need to check for cplusplus here because we may not do the test
85 # for Qt and autoconf does does not allow that.
86 AC_PROG_CXX
87 AC_PROG_LN_S
88 PKG_PROG_PKG_CONFIG
89 AC_CHECK_TOOL(WINDRES, windres, :)
90 AC_CHECK_PROGS(GITLOG_TO_CHANGELOG, gitlog-to-changelog,
91                [build-aux/gitlog-to-changelog])
92
93
94 have_dosish_system=no
95 have_w32_system=no
96 have_w32ce_system=no
97 case "${host}" in
98     *-mingw32*)
99         AC_DEFINE(USE_ONLY_8DOT3,1,
100                   [Set this to limit filenames to the 8.3 format])
101         have_dosish_system=yes
102         have_w32_system=yes
103         case "${host}" in
104           *-mingw32ce*)
105             have_w32ce_system=yes
106             ;;
107           *)
108             AC_DEFINE(HAVE_DRIVE_LETTERS,1,
109                       [Defined if the OS supports drive letters.])
110             ;;
111         esac
112         ;;
113     i?86-emx-os2 | i?86-*-os2*emx )
114         # OS/2 with the EMX environment
115         AC_DEFINE(HAVE_DRIVE_LETTERS)
116         have_dosish_system=yes
117         ;;
118
119     i?86-*-msdosdjgpp*)
120         # DOS with the DJGPP environment
121         AC_DEFINE(HAVE_DRIVE_LETTERS)
122         have_dosish_system=yes
123         ;;
124 esac
125
126 if test "$have_dosish_system" = yes; then
127    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
128              [Defined if we run on some of the PCDOS like systems
129               (DOS, Windoze. OS/2) with special properties like
130               no file modes])
131 fi
132 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
133
134 if test "$have_w32_system" = yes; then
135    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
136    if test "$have_w32ce_system" = yes; then
137       AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
138    fi
139 fi
140 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
141 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
142
143
144
145
146 dnl Checks for compiler features.
147 if test "$GCC" = yes; then
148     # Check whether gcc does not emit a diagnositc for unknown -Wno-*
149     # options.  This is the case for gcc >= 4.6
150     AC_MSG_CHECKING([if gcc ignores unknown -Wno-* options])
151     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
152 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6 )
153 #kickerror
154 #endif]],[])],[_gcc_silent_wno=yes],[_gcc_silent_wno=no])
155     AC_MSG_RESULT($_gcc_silent_wno)
156
157     if test "$USE_MAINTAINER_MODE" = "yes"; then
158         CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
159         CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
160
161         if test x"$_gcc_silent_wno" = xyes ; then
162           _gcc_warn=yes
163         else
164           AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
165           _gcc_cflags_save=$CFLAGS
166           CFLAGS="-Wno-missing-field-initializers"
167           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
168                             [_gcc_warn=yes],[_gcc_warn=no])
169           AC_MSG_RESULT($_gcc_warn)
170           CFLAGS=$_gcc_cflags_save;
171         fi
172         if test x"$_gcc_warn" = xyes ; then
173           CFLAGS="$CFLAGS -W -Wno-sign-compare -Wno-missing-field-initializers"
174         fi
175
176         AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement])
177         _gcc_cflags_save=$CFLAGS
178         CFLAGS="-Wdeclaration-after-statement"
179         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_warn=yes,_gcc_warn=no)
180         AC_MSG_RESULT($_gcc_warn)
181         CFLAGS=$_gcc_cflags_save;
182         if test x"$_gcc_warn" = xyes ; then
183           CFLAGS="$CFLAGS -Wdeclaration-after-statement"
184         fi
185
186     else
187         # Not in maintainer mode: Use standard warnings.
188         CFLAGS="$CFLAGS -Wall"
189     fi
190
191     CPPFLAGS="$CPPFLAGS -Wall"
192
193     if test x"$_gcc_silent_wno" = xyes ; then
194       _gcc_warn=yes
195     else
196       AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
197       _gcc_cflags_save=$CFLAGS
198       CFLAGS="-Wno-pointer-sign"
199       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],[_gcc_warn=yes],[_gcc_warn=no])
200       AC_MSG_RESULT($_gcc_warn)
201       CFLAGS=$_gcc_cflags_save;
202     fi
203     if test x"$_gcc_warn" = xyes ; then
204        CFLAGS="$CFLAGS -Wno-pointer-sign"
205     fi
206
207     AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
208     _gcc_cflags_save=$CFLAGS
209     CFLAGS="-Wpointer-arith"
210     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_warn=yes,_gcc_warn=no)
211     AC_MSG_RESULT($_gcc_warn)
212     CFLAGS=$_gcc_cflags_save;
213     if test x"$_gcc_warn" = xyes ; then
214        CFLAGS="$CFLAGS -Wpointer-arith"
215     fi
216 fi
217
218
219 # Checks for header files.
220 AC_HEADER_STDC
221 AC_CHECK_HEADERS(string.h unistd.h langinfo.h termio.h locale.h utime.h wchar.h)
222
223 dnl Checks for library functions.
224 AC_CHECK_FUNCS(seteuid stpcpy mmap stat)
225 GNUPG_CHECK_MLOCK
226
227 dnl Checks for standard types.
228 AC_TYPE_UINT32_T
229
230 # Common libraries and cflags.
231 COMMON_CFLAGS=
232 COMMON_LIBS=
233 AC_SUBST(COMMON_CFLAGS)
234 AC_SUBST(COMMON_LIBS)
235
236 dnl Checks for libgpg-error
237 #
238 # libgpg-error is a library with error codes shared between GnuPG
239 # related projects.
240 #
241 NEED_GPG_ERROR_VERSION=1.16
242 have_gpg_error=no
243
244 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
245                   have_gpg_error=yes,have_gpg_error=no)
246 COMMON_CFLAGS="$GPG_ERROR_CFLAGS $COMMON_CFLAGS"
247 COMMON_LIBS="$GPG_ERROR_LIBS $COMMON_LIBS"
248
249 AC_DEFINE_UNQUOTED(GPG_ERR_ENABLE_GETTEXT_MACROS, 1,
250                    [Under Windows we use the gettext code from libgpg-error])
251
252 AC_DEFINE_UNQUOTED(GPG_ERR_ENABLE_ERRNO_MACROS, 1,
253                    [Under WindowsCE we use the strerror replacement from libgpg-error.])
254
255
256 dnl Checks for libassuan.
257 #
258 # libassuan is used for IPC
259 #
260 NEED_LIBASSUAN_API=2
261 NEED_LIBASSUAN_VERSION=2.1.0
262 have_libassuan=no
263 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
264                   have_libassuan=yes,have_libassuan=no)
265 if test "$have_libassuan" = "yes"; then
266   AC_DEFINE_UNQUOTED(GNUPG_LIBASSUAN_VERSION, "$libassuan_version",
267                      [version of the libassuan library])
268 fi
269
270 COMMON_CFLAGS="$LIBASSUAN_CFLAGS $COMMON_CFLAGS"
271 COMMON_LIBS="$LIBASSUAN_LIBS $COMMON_LIBS"
272
273
274 dnl Checks for libsecmem.
275 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
276 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
277
278 dnl Check for libcap
279 AC_ARG_WITH([libcap], AC_HELP_STRING([--without-libcap],
280             [Disable support for capabilities library]))
281
282 if test "x$with_libcap" != "xno"; then
283   AC_PATH_PROG(SETCAP, setcap, :, "$PATH:/sbin:/usr/sbin")
284   AC_CHECK_LIB(cap, cap_set_proc, [
285     AC_DEFINE(USE_CAPABILITIES,1,[The capabilities support library is installed])
286     LIBCAP=-lcap
287   ])
288 fi
289 AC_SUBST(LIBCAP)
290
291 dnl
292 dnl Check for curses pinentry program.
293 dnl
294 AC_ARG_ENABLE(pinentry-curses,
295             AC_HELP_STRING([--enable-pinentry-curses], [build curses pinentry]),
296             pinentry_curses=$enableval, pinentry_curses=maybe)
297 AC_ARG_ENABLE(fallback-curses,
298             AC_HELP_STRING([--enable-fallback-curses], [include curses fallback]),
299             fallback_curses=$enableval, fallback_curses=maybe)
300
301 dnl
302 dnl Checks for curses libraries.  Deal correctly with $pinentry_curses = maybe
303 dnl and $fallback_curses = maybe.
304 dnl
305 if test "$pinentry_curses" != "no" -o "$fallback_curses" != "no"; then
306   IU_LIB_CURSES
307 fi
308 if test "$LIBCURSES"; then
309   if test "$pinentry_curses" != "no"; then
310     pinentry_curses=yes
311   fi
312   if test "$fallback_curses" != "no"; then
313     fallback_curses=yes
314     AC_DEFINE(FALLBACK_CURSES, 1,
315      [The GUI pinentries should fall back to curses if X is not available.])
316   fi
317 else
318   if test "$pinentry_curses" = "yes" -o "$fallback_curses" = "yes"; then
319     AC_MSG_ERROR([[
320 ***
321 *** The curses library is required. The latest version of
322 *** ncurses is always available from ftp://ftp.gnu.org/gnu/ncurses/.
323 ***]])
324   fi
325   pinentry_curses=no
326   fallback_curses=no
327 fi
328 AM_CONDITIONAL(BUILD_LIBPINENTRY_CURSES,
329               test "$pinentry_curses" = "yes" -o "$fallback_curses" = "yes")
330 AM_CONDITIONAL(BUILD_PINENTRY_CURSES, test "$pinentry_curses" = "yes")
331 AM_CONDITIONAL(FALLBACK_CURSES, test "$fallback_curses" = "yes")
332
333 if test "$pinentry_curses" = "yes"; then
334   AC_DEFINE(PINENTRY_CURSES, 1,
335            [The Curses version of Pinentry is to be build])
336 fi
337
338
339 dnl
340 dnl Check for tty pinentry program.
341 dnl
342 AC_ARG_ENABLE(pinentry-tty,
343             AC_HELP_STRING([--enable-pinentry-tty], [build tty pinentry]),
344             pinentry_tty=$enableval, pinentry_tty=maybe)
345 AM_CONDITIONAL(BUILD_PINENTRY_TTY, test "$pinentry_tty" = "yes")
346
347 if test "$pinentry_tty" = "yes"; then
348   AC_DEFINE(PINENTRY_TTY, 1,
349            [The TTY version of Pinentry is to be build])
350 fi
351
352
353 dnl
354 dnl Additional checks pinentry Curses.
355 dnl
356 if test "$pinentry_curses" = "yes" \
357         -o "$fallback_curses" = "yes" ; then
358   AM_ICONV
359   if test "$am_cv_func_iconv" != "yes"; then
360     AC_MSG_ERROR([[
361 ***
362 *** The iconv function is required.  You can specify its location
363 *** using the --with-libiconv-prefix=PREFIX option to configure.
364 ***]])
365   fi
366 fi
367
368 dnl
369 dnl Check for emacs pinentry program.
370 dnl
371 AC_ARG_ENABLE(pinentry-emacs,
372             AC_HELP_STRING([--enable-pinentry-emacs], [build emacs pinentry]),
373             pinentry_emacs=$enableval, pinentry_emacs=no)
374 AC_ARG_ENABLE(inside-emacs,
375             AC_HELP_STRING([--enable-inside-emacs], [include emacs hack]),
376             inside_emacs=$enableval, inside_emacs=maybe)
377
378 if test "$pinentry_emacs" != "no" -o "$inside_emacs" != "no"; then
379   AC_MSG_CHECKING([if Unix domain socket is supported])
380   AC_TRY_COMPILE([
381 #include <sys/socket.h>
382 #include <sys/un.h>
383 ],
384                  [int s = socket (AF_UNIX, SOCK_STREAM, 0);],
385                  [_unixsock_works=yes],
386                  [_unixsock_works=no])
387   AC_MSG_RESULT($_unixsock_works)
388   if test "$_unixsock_works" = "yes"; then
389     if test "$pinentry_emacs" != "no"; then
390       pinentry_emacs=yes
391     fi
392     if test "$inside_emacs" != "no"; then
393       inside_emacs=yes
394       AC_DEFINE(INSIDE_EMACS, 1,
395                 [The GUI pinentries should respect INSIDE_EMACS envvar.])
396     fi
397   else
398     if test "$pinentry_emacs" = "yes" -o "$inside_emacs" = "yes"; then
399       AC_MSG_ERROR([[
400 ***
401 *** Support for Unix domain sockets is required.
402 ***]])
403     fi
404     pinentry_emacs=no
405     inside_emacs=no
406   fi
407 fi
408
409 AM_CONDITIONAL(BUILD_LIBPINENTRY_EMACS,
410               test "$pinentry_emacs" = "yes" -o "$inside_emacs" = "yes")
411 AM_CONDITIONAL(BUILD_PINENTRY_EMACS, test "$pinentry_emacs" = "yes")
412 AM_CONDITIONAL(INSIDE_EMACS, test "$inside_emacs" = "yes")
413
414 if test "$pinentry_emacs" = "yes"; then
415   AC_DEFINE(PINENTRY_EMACS, 1,
416             [The Emacs version of Pinentry is to be build])
417 fi
418
419
420
421 dnl
422 dnl Check for EFL pinentry programs.
423 dnl
424 AC_ARG_ENABLE(pinentry-efl,
425             AC_HELP_STRING([--enable-pinentry-efl], [build EFL pinentry]),
426             pinentry_efl=$enableval, pinentry_efl=maybe)
427
428 dnl check for pkg-config
429 if test "$pinentry_efl" != "no"; then
430         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
431         if test x"${PKG_CONFIG}" = xno ; then
432                 pinentry_efl=no
433         fi
434 fi
435
436 if test "$pinentry_efl" != "no"; then
437         AC_MSG_CHECKING([for efl])
438         "${PKG_CONFIG}" --exists 'elementary >= 1.18'
439         if test $? -ne 0 ; then
440                 AC_MSG_RESULT([no])
441                 AC_MSG_WARN([efl >= 1.18 is required for efl pinentry])
442                 pinentry_efl=no
443         else
444                 AC_MSG_RESULT([yes])
445                 EFL_CFLAGS=`"${PKG_CONFIG}" --cflags ecore-x elementary`
446                 EFL_LIBS=`"${PKG_CONFIG}" --libs ecore-x elementary`
447                 AC_SUBST(EFL_CFLAGS)
448                 AC_SUBST(EFL_LIBS)
449                 if test "$pinentry_efl" != "no"
450                 then
451                         pinentry_efl=yes
452                 fi
453         fi
454 fi
455 AM_CONDITIONAL(BUILD_PINENTRY_EFL, test "$pinentry_efl" = "yes")
456
457 dnl
458 dnl Check for GTK+-2 / GNOME3 pinentry programs.
459 dnl
460 AC_ARG_ENABLE(pinentry-gtk2,
461             AC_HELP_STRING([--enable-pinentry-gtk2], [build GTK+-2 pinentry]),
462             pinentry_gtk_2=$enableval, pinentry_gtk_2=maybe)
463
464 AC_ARG_ENABLE(pinentry-gnome3,
465             AC_HELP_STRING([--enable-pinentry-gnome3], [build GNOME 3 pinentry]),
466             pinentry_gnome_3=$enableval, pinentry_gnome_3=maybe)
467
468 dnl check if the module gtk+-2.0 exists
469 if test "$pinentry_gtk_2" != "no"; then
470         PKG_CHECK_MODULES(
471                 GTK2,
472                 [gtk+-2.0 >= 2.4.0],
473                 [
474                         test "$pinentry_gtk_2" != "no" && pinentry_gtk_2=yes
475                         test "$pinentry_gnome_3" != "no" && pinentry_gnome_3=yes
476                 ],
477                 [
478                         AC_MSG_WARN([pkg-config could not find the module gtk+-2.0])
479                         pinentry_gtk_2=no
480                 ]
481         )
482 fi
483 AM_CONDITIONAL(BUILD_PINENTRY_GTK_2, test "$pinentry_gtk_2" = "yes")
484
485 if test "$pinentry_gnome_3" != "no"; then
486         PKG_CHECK_MODULES(
487                 GNOME3,
488                 [gcr-3,gcr-base-3],
489                 [
490                         pinentry_gnome_3=yes
491                         AC_DEFINE(GCR_API_SUBJECT_TO_CHANGE, 1, [Nod nod])
492                 ],
493                 [
494                         AC_MSG_WARN([pkg-config could not find the module gcr-3,gcr-base-3])
495                         pinentry_gnome_3=no
496                 ]
497         )
498 fi
499
500 AM_CONDITIONAL(BUILD_PINENTRY_GNOME_3, test "$pinentry_gnome_3" = "yes")
501
502 dnl
503 dnl Check for libsecret.
504 dnl
505 AC_ARG_ENABLE(libsecret,
506             AC_HELP_STRING([--enable-libsecret],
507             [optionally cache passphrases using libsecret]),
508             libsecret=$enableval, libsecret=maybe)
509
510 dnl check if the module libsecret exists
511 if test "$libsecret" != "no"; then
512         PKG_CHECK_MODULES(
513                 LIBSECRET,
514                 [libsecret-1],
515                 [libsecret=yes],
516                 [
517                         AC_MSG_WARN([pkg-config could not find the module libsecret-1])
518                         libsecret=no
519                 ]
520         )
521 fi
522 AM_CONDITIONAL(BUILD_WITH_LIBSECRET, test "$libsecret" = "yes")
523 if test "$libsecret" = "yes"; then
524   AC_DEFINE(HAVE_LIBSECRET, 1,
525     [The pinentries should optionally cache the passphrase using libsecret.])
526
527   COMMON_CFLAGS="$LIBSECRET_CFLAGS $COMMON_CFLAGS"
528   COMMON_LIBS="$LIBSECRET_LIBS $COMMON_LIBS"
529 fi
530
531 dnl
532 dnl Check for Qt pinentry program.
533 dnl
534 AC_ARG_ENABLE(pinentry-qt,
535             AC_HELP_STRING([--enable-pinentry-qt], [build qt pinentry]),
536             pinentry_qt=$enableval, pinentry_qt=maybe)
537
538
539 dnl
540 dnl Checks for qt libraries.  Deal correctly with $pinentry_qt = maybe.
541 dnl Tries to find Qt5, falls back on Qt4
542 dnl
543 if test "$pinentry_qt" != "no"; then
544   FIND_QT
545   if test "$have_qt4_libs" != "yes" -a "$have_qt5_libs" != "yes"; then
546     if test "$pinentry_qt" = "yes"; then
547         AC_MSG_ERROR([[
548     ***
549     *** Qt4 (QtCore, QtGui) or Qt5 (Qt5Core, Qt5Gui, Qt5Widgets) is required.
550     ***]])
551     else
552         pinentry_qt=no
553     fi
554   fi
555 fi
556
557 AC_SUBST(PINENTRY_QT_CFLAGS)
558 AC_SUBST(PINENTRY_QT_LIBS)
559 AC_SUBST(MOC)
560
561 dnl If we have come so far, qt pinentry can be build.
562 if test "$pinentry_qt" != "no"; then
563     pinentry_qt=yes
564 fi
565 AM_CONDITIONAL(BUILD_PINENTRY_QT, test "$pinentry_qt" = "yes")
566 if test "$pinentry_qt" = "yes"; then
567   AC_DEFINE(PINENTRY_QT, 1, [The qt version of Pinentry is to be build])
568   if test "$have_qt4_libs" = "yes"; then
569     pinentry_qt_lib_version="(Qt4)"
570   else
571     pinentry_qt_lib_version="(Qt5)"
572   fi
573 fi
574
575 dnl
576 dnl Check for TQt pinentry program.
577 dnl
578 AC_ARG_ENABLE(pinentry-tqt,
579               AC_HELP_STRING([--enable-pinentry-tqt], [build tqt pinentry]),
580               pinentry_tqt=$enableval, pinentry_tqt=no)
581
582 if test "$pinentry_tqt" != "no"; then
583
584   if test "$pinentry_qt" = "yes"; then
585     AC_MSG_ERROR([[
586     ***
587     *** Building both Qt and TQt pinentries is not supported.
588     *** Use --disable-pinentry-qt if you want the TQt pinentry.
589     ***]])
590   fi
591
592   PKG_CHECK_MODULES(PINENTRY_TQT, tqt,
593                     have_tqt_libs=yes,
594                     [PKG_CHECK_MODULES(PINENTRY_TQT, tqt-mt,
595                      have_tqt_libs=yes, have_tqt_libs=no)])
596
597   if test "$have_tqt_libs" = "yes"; then
598     AC_CHECK_TOOL([TQT_MOC], tqmoc, "no")
599   fi
600
601   if test "$have_tqt_libs" = "yes" -a "$TQT_MOC" != "no"; then
602     pinentry_tqt=yes
603   else
604     AC_MSG_WARN([TQt is not found])
605     pinentry_tqt=no
606   fi
607
608 fi
609 AM_CONDITIONAL(BUILD_PINENTRY_TQT, test "$pinentry_tqt" = "yes")
610
611 #
612 # Check whether we should build the W32 pinentry.  This is actually
613 # the simplest check as we do this only for that platform.
614 #
615 pinentry_w32=no
616 test $have_w32_system = yes && pinentry_w32=yes
617 AM_CONDITIONAL(BUILD_PINENTRY_W32, test "$pinentry_w32" = "yes")
618
619 dnl
620 dnl Check for FLTK pinentry program.
621 dnl
622 AC_ARG_ENABLE(pinentry-fltk,
623     AC_HELP_STRING([--enable-pinentry-fltk], [build FLTK 1.3 pinentry]),
624            pinentry_fltk=$enableval, pinentry_fltk=maybe)
625
626 dnl check for fltk-config
627 if test "$pinentry_fltk" != "no"; then
628    AC_PATH_PROG(FLTK_CONFIG, fltk-config, no)
629    if test x"${FLTK_CONFIG}" = xno ; then
630        AC_MSG_WARN([fltk-config is not found])
631        pinentry_fltk=no
632    fi
633 fi
634
635 dnl check for FLTK libraries and set flags
636 if test "$pinentry_fltk" != "no"; then
637    AC_MSG_CHECKING([for FLTK 1.3])
638    FLTK_VERSION=`${FLTK_CONFIG} --api-version`
639    if test ${FLTK_VERSION} != "1.3" ; then
640        AC_MSG_RESULT([no])
641        AC_MSG_WARN([FLTK 1.3 not found (available $FLTK_VERSION)])
642        pinentry_fltk=no
643    else
644        AC_MSG_RESULT([yes])
645        FLTKCFLAGS=`${FLTK_CONFIG} --cflags`
646        FLTKCXXFLAGS=`${FLTK_CONFIG} --cxxflags`
647        FLTKLIBS=`${FLTK_CONFIG} --ldflags`
648        AC_SUBST(FLTKCFLAGS)
649        AC_SUBST(FLTKCXXFLAGS)
650        AC_SUBST(FLTKLIBS)
651        pinentry_fltk=yes
652    fi
653 fi
654 AM_CONDITIONAL(BUILD_PINENTRY_FLTK, test "$pinentry_fltk" = "yes")
655
656 # Figure out the default pinentry.  We are very conservative here.
657 # Please change the order only after verifying that the preferred
658 # pinentry really is better (more feature-complete and more secure).
659
660 if test "$pinentry_gtk_2" = "yes"; then
661   PINENTRY_DEFAULT=pinentry-gtk-2
662 else
663   if test "$pinentry_qt" = "yes"; then
664     PINENTRY_DEFAULT=pinentry-qt
665   else
666     if test "$pinentry_gnome_3" = "yes"; then
667       PINENTRY_DEFAULT=pinentry-gnome3
668     else
669       if test "$pinentry_curses" = "yes"; then
670         PINENTRY_DEFAULT=pinentry-curses
671       else
672         if test "$pinentry_tty" = "yes"; then
673           PINENTRY_DEFAULT=pinentry-tty
674         else
675           if test "$pinentry_w32" = "yes"; then
676             PINENTRY_DEFAULT=pinentry-w32
677           else
678             if test "$pinentry_fltk" = "yes"; then
679               PINENTRY_DEFAULT=pinentry-fltk
680             else
681               if test "$pinentry_tqt" = "yes"; then
682                 PINENTRY_DEFAULT=pinentry-tqt
683               else
684                 if test "$pinentry_efl" = "yes"; then
685                   PINENTRY_DEFAULT=pinentry-efl
686                 else
687                   AC_MSG_ERROR([[No pinentry enabled.]])
688                 fi
689               fi
690             fi
691           fi
692         fi
693       fi
694     fi
695   fi
696 fi
697 AC_SUBST(PINENTRY_DEFAULT)
698
699 #
700 # Print errors here so that they are visible all
701 # together and the user can acquire them all together.
702 #
703 die=no
704 if test "$have_gpg_error" = "no"; then
705    die=yes
706    AC_MSG_NOTICE([[
707 ***
708 *** You need libgpg-error to build this program.
709 **  This library is for example available at
710 ***   ftp://ftp.gnupg.org/gcrypt/libgpg-error
711 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
712 ***]])
713 fi
714
715 if test "$have_libassuan" = "no"; then
716    die=yes
717    AC_MSG_NOTICE([[
718 ***
719 *** You need libassuan to build this program.
720 *** This library is for example available at
721 ***   ftp://ftp.gnupg.org/gcrypt/libassuan/
722 *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required).
723 ***]])
724 fi
725
726 if test "$die" = "yes"; then
727     AC_MSG_ERROR([[
728 ***
729 *** Required libraries not found. Please consult the above messages
730 *** and install them before running configure again.
731 ***]])
732 fi
733
734
735
736 #
737 # To avoid double inclusion of config.h which might happen at some
738 # places, we add the usual double inclusion protection at the top of
739 # config.h.
740 #
741 AH_TOP([
742 #ifndef GNUPG_CONFIG_H_INCLUDED
743 #define GNUPG_CONFIG_H_INCLUDED
744 ])
745
746 #
747 # Stuff which goes at the bottom of config.h.
748 #
749 AH_BOTTOM([
750 #ifdef GPG_ERR_SOURCE_DEFAULT
751 # error GPG_ERR_SOURCE_DEFAULT already defined
752 #endif
753 #define GPG_ERR_SOURCE_DEFAULT  GPG_ERR_SOURCE_PINENTRY
754 #endif /*GNUPG_CONFIG_H_INCLUDED*/
755 ])
756
757 build_doc=yes
758 AC_ARG_ENABLE([doc], AC_HELP_STRING([--disable-doc],
759                                     [do not build the documentation]),
760                      build_doc=$enableval, build_doc=yes)
761 AM_CONDITIONAL([BUILD_DOC], [test "x$build_doc" != xno])
762
763
764 AC_CONFIG_FILES([
765 m4/Makefile
766 secmem/Makefile
767 pinentry/Makefile
768 curses/Makefile
769 tty/Makefile
770 efl/Makefile
771 emacs/Makefile
772 gtk+-2/Makefile
773 gnome3/Makefile
774 qt/Makefile
775 tqt/Makefile
776 w32/Makefile
777 fltk/Makefile
778 doc/Makefile
779 Makefile
780 ])
781
782 AC_OUTPUT
783
784 AC_MSG_NOTICE([
785
786         Pinentry v${VERSION} has been configured as follows:
787
788         Revision:  mym4_revision  (mym4_revision_dec)
789         Platform:  $host
790
791         Curses Pinentry ..: $pinentry_curses
792         TTY Pinentry .....: $pinentry_tty
793         Emacs Pinentry ...: $pinentry_emacs
794         EFL Pinentry .....: $pinentry_efl
795         GTK+-2 Pinentry ..: $pinentry_gtk_2
796         GNOME 3 Pinentry .: $pinentry_gnome_3
797         Qt Pinentry ......: $pinentry_qt $pinentry_qt_lib_version
798         TQt Pinentry .....: $pinentry_tqt
799         W32 Pinentry .....: $pinentry_w32
800         FLTK Pinentry ....: $pinentry_fltk
801
802         Fallback to Curses: $fallback_curses
803         Emacs integration : $inside_emacs
804
805         libsecret ........: $libsecret
806
807         Default Pinentry .: $PINENTRY_DEFAULT
808 ])