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