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