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