Curses build fix for DOS'ish systems.
[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 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, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20
21 # (Process this file with autoconf to produce a configure script.)
22 AC_PREREQ(2.57)
23 min_automake_version="1.10"
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, [0.8.3])
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], [http://bugs.gnupg.org])
46
47 AM_CONFIG_HEADER(config.h)
48 AC_CONFIG_SRCDIR(pinentry/pinentry.h)
49 AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
50
51 AC_GNU_SOURCE
52
53 AM_MAINTAINER_MODE
54
55 AC_CANONICAL_HOST
56
57 AH_TOP([
58 #ifndef PINENTRY_CONFIG_H_INCLUDED
59 #define PINENTRY_CONFIG_H_INCLUDED
60
61 /* Enable gpg-error's strerror macro under W32CE.  */
62 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
63 ])
64
65 AH_BOTTOM([
66 #endif /*PINENTRY_CONFIG_H_INCLUDED*/
67 ])
68
69
70 dnl Checks for programs.
71 AC_PROG_MAKE_SET
72 AM_SANITY_CHECK
73 missing_dir=`cd $ac_aux_dir && pwd`
74 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
75 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
76 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
77 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
78 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
79 AC_PROG_CC
80 AC_PROG_CPP
81 AC_PROG_INSTALL
82 AC_PROG_RANLIB
83 # We need to check for cplusplus here because we may not do the test
84 # for Qt and autoconf does does not allow that.
85 AC_PROG_CXX
86 AC_PROG_LN_S
87 AC_CHECK_TOOL(WINDRES, windres, :)
88 AC_CHECK_PROGS(GITLOG_TO_CHANGELOG, gitlog-to-changelog,
89                [build-aux/gitlog-to-changelog])
90
91
92 have_dosish_system=no
93 have_w32_system=no
94 have_w32ce_system=no
95 case "${host}" in
96     *-mingw32*)
97         AC_DEFINE(USE_ONLY_8DOT3,1,
98                   [Set this to limit filenames to the 8.3 format])
99         have_dosish_system=yes
100         have_w32_system=yes
101         case "${host}" in
102           *-mingw32ce*)
103             have_w32ce_system=yes
104             ;;
105           *)
106             AC_DEFINE(HAVE_DRIVE_LETTERS,1,
107                       [Defined if the OS supports drive letters.])
108             ;;
109         esac
110         ;;
111     i?86-emx-os2 | i?86-*-os2*emx )
112         # OS/2 with the EMX environment
113         AC_DEFINE(HAVE_DRIVE_LETTERS)
114         have_dosish_system=yes
115         ;;
116
117     i?86-*-msdosdjgpp*)
118         # DOS with the DJGPP environment
119         AC_DEFINE(HAVE_DRIVE_LETTERS)
120         have_dosish_system=yes
121         ;;
122 esac
123
124 if test "$have_dosish_system" = yes; then
125    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
126              [Defined if we run on some of the PCDOS like systems
127               (DOS, Windoze. OS/2) with special properties like
128               no file modes])
129 fi
130 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
131
132 if test "$have_w32_system" = yes; then
133    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
134    if test "$have_w32ce_system" = yes; then
135       AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
136    fi
137 fi
138 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
139 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
140
141
142
143
144 dnl Checks for compiler features.
145 if test "$GCC" = yes; then
146     CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
147     CPPFLAGS="$CPPFLAGS -Wall"
148
149     AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
150     _gcc_cflags_save=$CFLAGS
151     CFLAGS="-Wno-pointer-sign"
152     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_psign=yes,_gcc_psign=no)
153     AC_MSG_RESULT($_gcc_psign)
154     CFLAGS=$_gcc_cflags_save;
155     if test x"$_gcc_psign" = xyes ; then
156        CFLAGS="$CFLAGS -Wno-pointer-sign"
157     fi
158 fi
159
160
161 # Checks for header files.
162 AC_HEADER_STDC
163 AC_CHECK_HEADERS(string.h unistd.h langinfo.h termio.h locale.h utime.h wchar.h)
164
165 dnl Checks for library functions.
166 AC_CHECK_FUNCS(seteuid stpcpy mmap)
167 GNUPG_CHECK_MLOCK
168
169 dnl Checks for libassuan.
170 dnl -> None required becuase we use a stripped down version of libassuan.
171
172
173 dnl Checks for libsecmem.
174 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
175 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
176
177 dnl Check for libcap
178 AC_ARG_WITH([libcap], AC_HELP_STRING([--without-libcap],
179             [Disable support for capabilities library]))
180
181 if test "x$with_libcap" != "xno"; then
182   AC_PATH_PROG(SETCAP, setcap, :, "$PATH:/sbin:/usr/sbin")
183   AC_CHECK_LIB(cap, cap_set_proc, [
184     AC_DEFINE(USE_CAPABILITIES,1,[The capabilities support library is installed])
185     LIBCAP=-lcap
186   ])
187 fi
188 AC_SUBST(LIBCAP)
189
190 dnl
191 dnl Check for curses pinentry program.
192 dnl
193 AC_ARG_ENABLE(pinentry-curses,
194             AC_HELP_STRING([--enable-pinentry-curses], [build curses pinentry]),
195             pinentry_curses=$enableval, pinentry_curses=maybe)
196 AC_ARG_ENABLE(fallback-curses,
197             AC_HELP_STRING([--enable-fallback-curses], [include curses fallback]),
198             fallback_curses=$enableval, fallback_curses=maybe)
199
200 dnl
201 dnl Checks for curses libraries.  Deal correctly with $pinentry_curses = maybe
202 dnl and $fallback_curses = maybe.
203 dnl
204 if test "$pinentry_curses" != "no" -o "$fallback_curses" != "no"; then
205   IU_LIB_CURSES
206 fi
207 if test "$LIBCURSES"; then
208   if test "$pinentry_curses" != "no"; then
209     pinentry_curses=yes
210   fi
211   if test "$fallback_curses" != "no"; then
212     fallback_curses=yes
213     AC_DEFINE(FALLBACK_CURSES, 1,
214      [The GUI pinentries should fall back to curses if X is not available.])
215   fi
216 else
217   if test "$pinentry_curses" = "yes" -o "$fallback_curses" = "yes"; then
218     AC_MSG_ERROR([[
219 ***
220 *** The curses library is required. The latest version of
221 *** ncurses is always available from ftp://ftp.gnu.org/gnu/ncurses/.
222 ***]])
223   fi
224   pinentry_curses=no
225   fallback_curses=no
226 fi
227 AM_CONDITIONAL(BUILD_LIBPINENTRY_CURSES,
228               test "$pinentry_curses" = "yes" -o "$fallback_curses" = "yes")
229 AM_CONDITIONAL(BUILD_PINENTRY_CURSES, test "$pinentry_curses" = "yes")
230 AM_CONDITIONAL(FALLBACK_CURSES, test "$fallback_curses" = "yes")
231
232 if test "$pinentry_curses" = "yes"; then
233   AC_DEFINE(PINENTRY_CURSES, 1,
234            [The Curses version of Pinentry is to be build])
235 fi
236
237
238 dnl
239 dnl Check for GTK+ pinentry program.
240 dnl
241 AC_ARG_ENABLE(pinentry-gtk,
242             AC_HELP_STRING([--enable-pinentry-gtk], [build GTK+ pinentry]),
243             pinentry_gtk=$enableval, pinentry_gtk=maybe)
244
245 dnl
246 dnl Checks for GTK+ libraries.  Deal correctly with $pinentry_gtk = maybe.
247 dnl
248 if test "$pinentry_gtk" != "no"; then
249 AM_PATH_GLIB(1.2.0,,
250 if test "$pinentry_gtk" = "yes"; then
251     AC_MSG_ERROR([[
252 ***
253 *** GLIB 1.2.0 or newer is required. The latest version of GLIB
254 *** is always available from ftp://ftp.gtk.org/.
255 ***]])
256 else
257     pinentry_gtk=no
258 fi)
259 fi
260
261 if test "$pinentry_gtk" != "no"; then
262 AM_PATH_GTK(1.2.0,
263     AC_DEFINE(HAVE_GTK, 1, [Defined if GTK is available]),
264 if test "$pinentry_gtk" = "yes"; then
265     AC_MSG_ERROR([[
266 ***
267 *** GTK+ 1.2.0 or newer is required. The latest version of GTK+
268 *** is always available form ftp://ftp.gtk.org/.
269 ***]])
270 else
271     pinentry_gtk=no
272 fi)
273 fi
274
275 dnl If we have come so far, GTK+ pinentry can be build.
276 if test "$pinentry_gtk" != "no"; then
277     pinentry_gtk=yes
278 fi
279 AM_CONDITIONAL(BUILD_PINENTRY_GTK, test "$pinentry_gtk" = "yes")
280 if test "$pinentry_gtk" = "yes"; then
281   AC_DEFINE(PINENTRY_GTK, 1, [The GTK+ version of Pinentry is to be build])
282 fi
283
284 if test "$pinentry_curses" = "yes" \
285         -o "$fallback_curses" = "yes" \
286         -o "$pinentry_gtk" = "yes"; then
287   dnl Additional checks pinentry Curses/GTK+.
288   AM_ICONV
289   if test "$am_cv_func_iconv" != "yes"; then
290     AC_MSG_ERROR([[
291 ***
292 *** The iconv function is required.  You can specify its location
293 *** using the --with-libiconv-prefix=PREFIX option to configure.
294 ***]])
295   fi
296 fi
297
298 dnl if test "$pinentry_gtk" = "yes"; then
299 dnl Additional checks for GTK+ pinentry.
300 dnl End of additional checks for GTK+ pinentry.
301 dnl fi
302
303
304 dnl
305 dnl Check for GTK+-2 pinentry program.
306 dnl
307 AC_ARG_ENABLE(pinentry-gtk2,
308             AC_HELP_STRING([--enable-pinentry-gtk2], [build GTK+-2 pinentry]),
309             pinentry_gtk_2=$enableval, pinentry_gtk_2=maybe)
310
311 dnl check for pkg-config
312 if test "$pinentry_gtk_2" != "no"; then
313         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
314         if test x"${PKG_CONFIG}" = xno ; then
315                 pinentry_gtk_2=no
316         fi
317 fi
318
319 dnl check if the module gtk+-2.0 exists
320 if test "$pinentry_gtk_2" != "no"; then
321         AC_MSG_CHECKING([for gtk+-2])
322         "${PKG_CONFIG}" --exists gtk+-2.0
323         if test $? -ne 0 ; then
324                 AC_MSG_RESULT([no])
325                 AC_MSG_WARN([pkg-config could not find the module gtk+-2.0])
326                 pinentry_gtk_2=no
327         else
328                 AC_MSG_RESULT([yes])
329                 AC_MSG_CHECKING([gtk+-2 version >= 2.4.0])
330                 modvers=`"${PKG_CONFIG}" --modversion gtk+-2.0`
331                 AC_MSG_RESULT([$modvers])
332                 "${PKG_CONFIG}" --atleast-version=2.4.0 gtk+-2.0
333                 if test $? -ne 0 ; then
334                         AC_MSG_WARN([building GTK+-2 pinentry disabled])
335                         pinentry_gtk_2=no
336                 else
337                         GTK2CFLAGS=`"${PKG_CONFIG}" --cflags gtk+-2.0`
338                         GTK2LIBS=`"${PKG_CONFIG}" --libs gtk+-2.0`
339                         AC_SUBST(GTK2CFLAGS)
340                         AC_SUBST(GTK2LIBS)
341                         pinentry_gtk_2=yes
342                 fi
343         fi
344 fi
345 AM_CONDITIONAL(BUILD_PINENTRY_GTK_2, test "$pinentry_gtk_2" = "yes")
346
347
348 dnl
349 dnl Check for Qt pinentry program.
350 dnl
351 AC_ARG_ENABLE(pinentry-qt,
352             AC_HELP_STRING([--enable-pinentry-qt], [build Qt pinentry]),
353             pinentry_qt=$enableval, pinentry_qt=maybe)
354 dnl
355 dnl Checks for Qt libraries.  Deal correctly with $pinentry_qt = maybe.
356 dnl
357 if test "$pinentry_qt" != "no"; then
358 QT_CHECK_COMPILERS
359 QT_PATH
360 if test $have_qt = "no"; then
361         if test $pinentry_qt = "yes"; then
362           AC_MSG_ERROR([[
363 ***
364 *** Qt ($qt_minversion) $ac_qt_notfound not found. Please check your
365 *** installation!  For more details about this problem, look at the
366 *** end of config.log.$missing_qt_mt
367 ***]])
368         else
369           pinentry_qt="no"
370         fi
371 fi
372 if test $have_moc = "no"; then
373         if test $pinentry_qt = "yes"; then
374         AC_MSG_ERROR([[
375 ***
376 *** No Qt meta object compiler (moc) found!
377 *** Please check whether you installed Qt correctly.
378 *** You need to have a running moc binary.
379 *** configure tried to run $ac_cv_path_moc and the test didn't
380 *** succeed. If configure shouldn't have tried this one, set
381 *** the environment variable MOC to the right one before running
382 *** configure.
383 ***]])
384         else
385           pinentry_qt="no"
386         fi
387 fi
388 fi
389
390 dnl If we have come so far, Qt pinentry can probably be build.
391 if test "$pinentry_qt" != "no"; then
392     pinentry_qt=yes
393 fi
394 AM_CONDITIONAL(BUILD_PINENTRY_QT, test "$pinentry_qt" = "yes")
395
396 if test "$pinentry_qt" = "yes"; then
397   AC_DEFINE(PINENTRY_QT, 1, [The Qt version of Pinentry is to be build])
398 fi
399
400 dnl if test "$pinentry_qt" = "yes"; then
401 dnl dnl Additional checks for Qt pinentry.
402 dnl dnl End of checks for Qt pinentry.
403 dnl fi
404
405
406 dnl
407 dnl Check for Qt4 pinentry program.
408 dnl
409 AC_ARG_ENABLE(pinentry-qt4,
410             AC_HELP_STRING([--enable-pinentry-qt4], [build Qt4 pinentry]),
411             pinentry_qt4=$enableval, pinentry_qt4=maybe)
412
413
414 dnl
415 dnl Checks for Qt4 libraries.  Deal correctly with $pinentry_qt4 = maybe.
416 dnl
417 if test "$pinentry_qt4" != "no"; then
418 PKG_CHECK_MODULES(QT4_CORE, QtCore,,
419 if test "$pinentry_qt4" = "yes"; then
420     AC_MSG_ERROR([[
421 ***
422 *** Qt4 Core is required.
423 ***]])
424 else
425     pinentry_qt4=no
426 fi)
427 fi
428
429 if test "$pinentry_qt4" != "no"; then
430 PKG_CHECK_MODULES(QT4_GUI, QtGui,,
431 if test "$pinentry_qt4" = "yes"; then
432     AC_MSG_ERROR([[
433 ***
434 *** Qt4 Gui is required.
435 ***]])
436 else
437     pinentry_qt4=no
438 fi)
439 fi
440
441 dnl If we have come so far, Qt4 pinentry can be build.
442 if test "$pinentry_qt4" != "no"; then
443     pinentry_qt4=yes
444 fi
445 AM_CONDITIONAL(BUILD_PINENTRY_QT4, test "$pinentry_qt4" = "yes")
446 if test "$pinentry_qt4" = "yes"; then
447   AC_DEFINE(PINENTRY_QT4, 1, [The Qt4 version of Pinentry is to be build])
448 fi
449
450 dnl if test "$pinentry_qt4" = "yes"; then
451 dnl Additional checks for Qt4 pinentry.
452 dnl End of additional checks for Qt4 pinentry.
453 dnl fi
454
455
456 #
457 # Check whether we should build the W32 pinentry.  This is actually
458 # the simplest check as we do this only for that platform.
459 #
460 pinentry_w32=no
461 test $have_w32_system = yes && pinentry_w32=yes
462 AM_CONDITIONAL(BUILD_PINENTRY_W32, test "$pinentry_w32" = "yes")
463
464
465 # Figure out the default pinentry.  We are very conservative here.
466 # Please change the order only after verifying that the preferred
467 # pinentry really is better (more feature-complete and more secure).
468
469 if test "$pinentry_gtk_2" = "yes"; then
470    PINENTRY_DEFAULT=pinentry-gtk-2
471 else
472   if test "$pinentry_gtk" = "yes"; then
473     PINENTRY_DEFAULT=pinentry-gtk
474   else
475     if test "$pinentry_qt" = "yes"; then
476       PINENTRY_DEFAULT=pinentry-qt
477     else
478       if test "$pinentry_qt4" = "yes"; then
479         PINENTRY_DEFAULT=pinentry-qt4
480       else
481         if test "$pinentry_curses" = "yes"; then
482           PINENTRY_DEFAULT=pinentry-curses
483         else
484           if test "$pinentry_w32" = "yes"; then
485             PINENTRY_DEFAULT=pinentry-w32
486           else
487             AC_MSG_ERROR([[No pinentry enabled.]])
488           fi
489         fi
490       fi
491     fi
492   fi
493 fi
494 AC_SUBST(PINENTRY_DEFAULT)
495
496
497 AC_CONFIG_FILES([
498 assuan/Makefile
499 secmem/Makefile
500 pinentry/Makefile
501 curses/Makefile
502 gtk/Makefile
503 gtk+-2/Makefile
504 qt/Makefile
505 qt4/Makefile
506 w32/Makefile
507 doc/Makefile
508 Makefile
509 ])
510
511 AC_OUTPUT
512
513 AC_MSG_NOTICE([
514         Pinentry v${VERSION} has been configured as follows:
515
516         Revision:  mym4_revision  (mym4_revision_dec)
517         Platform:  $host
518
519         Curses Pinentry: $pinentry_curses
520         GTK+ Pinentry: $pinentry_gtk
521         GTK+-2 Pinentry: $pinentry_gtk_2
522         Qt Pinentry: $pinentry_qt
523         Qt4 Pinentry: $pinentry_qt4
524         W32 Pinentry: $pinentry_w32
525
526         Fallback to Curses: $fallback_curses
527
528         Default Pinentry: $PINENTRY_DEFAULT
529 ])