Add first KDE Framework and infrastructure for it
[gpg4win.git] / m4 / gpg4win.m4
1 dnl gpg4win.m4 - macros to configure gpg4win.
2 dnl Copyright (C) 2005, 2009 g10 Code GmbH
3 dnl
4 dnl This file is part of GPG4Win.
5 dnl
6 dnl GPG4Win is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 2 of the License, or
9 dnl (at your option) any later version.
10 dnl
11 dnl GPG4Win is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 dnl GNU General Public License for more details.
15 dnl
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program; if not, write to the Free Software
18 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 dnl MA 02110-1301, USA
20
21
22 # GPG4WIN_DEFINE SYMBOL
23 # A poor man's version of AC_DEFINE_UNQUOTED for NSIS.
24 AC_DEFUN([GPG4WIN_DEFINE],
25 [
26   eval $1=\"\!define $1 1\"
27   AC_SUBST($1)
28 ])
29
30
31 # GPG4WIN_BASH
32 # Gpg4Win needs bash.  This macro checks for it.
33 AC_DEFUN([GPG4WIN_BASH],
34 [
35   AC_MSG_CHECKING([for Bash])
36   _bash=$BASH_VERSION
37   if test -z "$_bash"; then
38     _bash=no
39   fi
40   AC_MSG_RESULT($_bash)
41   if test $_bash = no; then
42     AC_MSG_ERROR("this configure script requires Bash")
43   fi
44 ])
45
46
47 # GPG4WIN_PACKAGES
48 # Determines the path to the source and binary packages.
49 # Default is the "packages" directory in the source directory.
50 # The path is stored in the shell variable gpg4win_packages.
51 AC_DEFUN([GPG4WIN_PACKAGES],
52 [
53   AC_MSG_CHECKING(for packages directory)
54   _gpg4win_packages_default=packages
55   AC_ARG_WITH([packages],
56     AS_HELP_STRING([--with-packages=DIR],
57                    [source and binary packages [[packages]]]),
58     gpg4win_packages=$withval)
59   AS_IF([test -z $gpg4win_packages],
60         [gpg4win_packages=$_gpg4win_packages_default])
61   AS_IF([test `echo $gpg4win_packages | head -c 1` != /],
62         [gpg4win_packages=`pwd`/$gpg4win_packages])
63   AC_SUBST(gpg4win_packages)
64   AC_MSG_RESULT($gpg4win_packages)
65
66   # Set auto-detection.  FIXME: This should accept a comma-separated
67   # list of packages that will be autodetected.
68   _gpg4win_auto_detection=yes
69   AC_ARG_ENABLE([packages],
70     AS_HELP_STRING([--enable-packages], [enable auto-detection [[yes]]]),
71     _gpg4win_auto_detection=$enableval)
72 ])
73
74
75 # Should be called early.
76 AC_DEFUN([GPG4WIN_INIT],
77 [
78   # We call this here so its options appear before the per-package options.
79   AC_REQUIRE([GPG4WIN_PACKAGES])
80 ])
81
82
83 # GPG4WIN_FIND([FILE],[PATTERN],[ZIP|TAR],[DIR],[IF-FOUND],[IF-NOT-FOUND])
84 # Search for package file FILE in DIR.  If DIR is empty, yes or maybe,
85 # look in default directory.  If DIR is not maybe, abort if not found.
86 # The package file name is provided in gpg4win_val and the version in
87 # gpg4win_version.
88 AC_DEFUN([GPG4WIN_FIND],
89 [
90   AC_REQUIRE([GPG4WIN_BASH])
91   AC_REQUIRE([GPG4WIN_PACKAGES])
92
93   gpg4win_val=
94   gpg4win_version=
95
96   AC_MSG_CHECKING(for package $1)
97   _gpg4win_critical=no
98   _gpg4win_file=
99   _gpg4win_dir=$4
100
101   # If --enable-pkg-foo was specified, make success critical.
102   AS_IF([test x$_gpg4win_dir != xmaybe], [_gpg4win_critical=yes])
103
104   # Only check if critical or auto detection is requested.
105   AS_IF([test $_gpg4win_auto_detection = yes -o $_gpg4win_critical = yes],
106     [AS_IF([test -z "$_gpg4win_dir" -o "$_gpg4win_dir" = yes -o "$_gpg4win_dir" = maybe],
107           [_gpg4win_dir=$gpg4win_packages])
108
109     # Install pattern.
110     AS_IF([test -z "$2"], [_gpg4win_pat='$1-\([[0-9]].*\)'],
111           [_gpg4win_pat="$2"])
112
113     # Frob pattern.  Regex party!
114     [_gpg4win_glob=`echo "$_gpg4win_pat" | sed -e 's/\\\\(\(.*\)\\\\)/\1/'`]
115     [_gpg4win_glob=`echo "$_gpg4win_glob" | sed -e 's/\\.\\*/*/'`]
116
117     # Make non-matching globs expand to nothing.
118     shopt -s nullglob
119
120     _gpg4win_format=both
121     AS_IF([test ! -z "$3"], _gpg4win_format="$3")
122
123     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != zip],
124           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.tar.xz`
125            _gpg4win_suffix=.tar.xz])
126     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != zip],
127           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.tar.bz2`
128            _gpg4win_suffix=.tar.bz2])
129     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != zip],
130           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.tbz2`
131            _gpg4win_suffix=.tbz2])
132     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != zip],
133           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.tbz`
134            _gpg4win_suffix=.tbz])
135     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != zip],
136           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.tar.gz`
137            _gpg4win_suffix=.tar.gz])
138     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != zip],
139           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.tgz`
140            _gpg4win_suffix=.tgz])
141     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != tar],
142           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.zip`
143            _gpg4win_suffix=.zip])
144     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != tar -a $_gpg4win_format != zip],
145           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.exe`
146            _gpg4win_suffix=.exe])
147     shopt -u nullglob])
148
149   AS_IF([test -z "$_gpg4win_file"],
150         AC_MSG_RESULT(no),
151         AS_IF([test `echo $_gpg4win_file | head -c 1` != /],
152               [_gpg4win_file=`pwd`/$_gpg4win_file])
153         AC_MSG_RESULT($_gpg4win_file))
154   AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_critical = yes],
155         AC_MSG_ERROR(could not find sources for $1 in $_gpg4win_dir))
156
157   # Test for duplicate.
158   _gpg4win_found=
159   for _gpg4win_f in $_gpg4win_file; do
160       AS_IF([test "$_gpg4win_found" = yes],
161             [AC_MSG_WARN(found more than one sources for $1 in $_gpg4win_dir)
162              gpg4win_dup_sources="$gpg4win_dup_sources $1"])
163       _gpg4win_found=yes
164   done
165
166   AS_IF([test ! -z "$_gpg4win_file"],
167         [gpg4win_val="$_gpg4win_file"
168         [gpg4win_version=`echo "$gpg4win_val" | sed -e "s,^.*/${_gpg4win_pat}${_gpg4win_suffix}$,\1,"`]
169          [$5]],
170         [$6])
171 ])
172
173 AC_DEFUN([GPG4WIN_CHECK_EXDEPS],
174 [
175   AC_REQUIRE([GPG4WIN_CHECK_DEPS])
176
177   AC_MSG_CHECKING([additional host build list])
178
179   gpg4win_build_ex_list=`echo $_gpg4win_ex_deps | tsort`
180   # Remove newlines.
181   gpg4win_build_ex_list=`echo $gpg4win_build_ex_list`
182   AC_MSG_RESULT($gpg4win_build_ex_list)
183   AC_SUBST(gpg4win_build_ex_list)
184
185   # Check each dependency.
186   _gpg4win_not_found=
187   _gpg4win_d=
188   _gpg4win_p=
189   for _gpg4win_p in $_gpg4win_ex_deps; do
190     AS_IF([test -z $_gpg4win_d], [_gpg4win_d=$_gpg4win_p],
191           [
192             _gpg4win_found=
193             for _gpg4win_i in $_gpg4win_pkgs; do
194               AS_IF([test $_gpg4win_d = $_gpg4win_i],
195                     _gpg4win_found=yes
196                     break)
197             done
198             AS_IF([test -z $_gpg4win_found],
199                   AC_MSG_WARN(could not find ex variant of package $_gpg4win_d required by package $_gpg4win_p)
200                   _gpg4win_not_found=yes)
201             _gpg4win_d=
202           ])
203   done
204   AS_IF([test ! -z "$_gpg4win_not_found"],
205         AC_MSG_ERROR([could not find some required packages]))
206 ])
207
208 AC_DEFUN([GPG4WIN_CHECK_DEPS],
209 [
210   AC_MSG_CHECKING(build list)
211   gpg4win_build_list=`echo $_gpg4win_deps | tsort`
212   # Remove newlines.
213   gpg4win_build_list=`echo $gpg4win_build_list`
214   AC_MSG_RESULT($gpg4win_build_list)
215   AC_SUBST(gpg4win_build_list)
216
217   # Check each dependency.
218   _gpg4win_not_found=
219   _gpg4win_d=
220   _gpg4win_p=
221   for _gpg4win_p in $_gpg4win_deps; do
222     AS_IF([test -z $_gpg4win_d], [_gpg4win_d=$_gpg4win_p],
223           [
224             _gpg4win_found=
225             for _gpg4win_i in $_gpg4win_pkgs; do
226               AS_IF([test $_gpg4win_d = $_gpg4win_i],
227                     _gpg4win_found=yes
228                     break)
229             done
230             AS_IF([test -z $_gpg4win_found],
231                   AC_MSG_WARN(could not find package $_gpg4win_d required by package $_gpg4win_p)
232                   _gpg4win_not_found=yes)
233             _gpg4win_d=
234           ])
235   done
236   AS_IF([test ! -z "$_gpg4win_not_found"],
237         AC_MSG_ERROR([could not find some required packages]))
238 ])
239
240
241 AC_DEFUN([GPG4WIN_FINALIZE],
242 [
243   AC_REQUIRE([GPG4WIN_CHECK_EXDEPS])
244
245   _gpg4win_debug=no
246   AC_ARG_ENABLE([debug],
247     AS_HELP_STRING([--enable-debug], [enable debugging [[no]]]),
248     _gpg4win_debug=$enableval)
249
250   AS_IF([test "${_gpg4win_debug}" != no],
251     GPG4WIN_DEFINE(GPG4WIN_DEBUG))
252 ])
253
254
255 # GPG4WIN_IPKG([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
256 # Set up the internal package PKG.
257 # It is provided in gpg4win_val.
258 AC_DEFUN([GPG4WIN_IPKG],
259 [
260   AC_REQUIRE([GPG4WIN_INIT])
261   AC_MSG_CHECKING([for internal package $1])
262   _gpg4win_pkg=maybe
263   AC_ARG_ENABLE([pkg-$1],
264     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
265                    [include internal package $1]),
266     _gpg4win_pkg=$enableval,
267     _gpg4win_pkg=yes)
268
269   # gpg4win_pkg_PKGNAME_deps=DEPS
270   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
271   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
272
273   AC_MSG_RESULT($_gpg4win_pkg)
274
275   AS_IF([test "$_gpg4win_pkg" != no],
276     _gpg4win_pkgs="$_gpg4win_pkgs $1"
277     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
278     # Record dependencies.  Also enter every package as node.
279     _gpg4win_deps="$_gpg4win_deps $1 $1"
280     AS_IF([test ! -z "$2"],
281           for _gpg4win_i in $2; do
282             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
283           done)
284       [$3],
285       [$4])
286 ])
287
288
289
290 # GPG4WIN_SPKG([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
291 # Set up the source package PKG.
292 # It is provided in gpg4win_val.
293 AC_DEFUN([GPG4WIN_SPKG],
294 [
295   AC_REQUIRE([GPG4WIN_INIT])
296   _gpg4win_pkg=maybe
297   AC_ARG_ENABLE([pkg-$1],
298     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
299                    [include package $1]),
300     _gpg4win_pkg=$enableval)
301   _gpg4win_spkg=no
302   _gpg4win_version=
303   AS_IF([test "$_gpg4win_pkg" != no],
304         [GPG4WIN_FIND($1,,, $_gpg4win_pkg,
305          _gpg4win_spkg=$gpg4win_val
306          _gpg4win_version=$gpg4win_version)])
307
308   # At this point, _gpg4win_spkg is no, or the actual package source file.
309
310   # gpg4win_pkg_PKGNAME=FILENAME_OF_SOURCE
311   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_spkg
312   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
313
314   # gpg4win_pkg_PKGNAME_version=VERSION
315   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
316   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
317
318   # gpg4win_pkg_PKGNAME_deps=DEPS
319   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
320   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
321
322   AS_IF([test "$_gpg4win_spkg" != no],
323     _gpg4win_pkgs="$_gpg4win_pkgs $1"
324     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
325     # Record dependencies.  Also enter every package as node.
326     _gpg4win_deps="$_gpg4win_deps $1 $1"
327     AS_IF([test ! -z "$2"],
328           for _gpg4win_i in $2; do
329             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
330           done)
331       [$3],
332       [$4])
333 ])
334
335
336 # GPG4WIN_SPKGEX([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
337 # Set up the source package PKG to be additionally built
338 # for the host provided as additional-gpgex-host
339 AC_DEFUN([GPG4WIN_SPKGEX],
340 [
341   GPG4WIN_SPKG([$1],[$2],[$3],[$4])
342
343   AS_IF([test ! -z "$GPGEX_ADD_HOST"],
344
345     # gpg4win_pkg_PKGNAME_deps=DEPS
346     gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_ex_deps="$2"
347     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_ex_deps)
348
349     gpg4win_ex_pkgs="$gpg4win_ex_pkgs $1"
350
351     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__])_EX)
352     # Record dependencies.  Also enter every package as node.
353     _gpg4win_ex_deps="$_gpg4win_ex_deps $1 $1"
354     AS_IF([test ! -z "$2"],
355           for _gpg4win_i in $2; do
356             _gpg4win_ex_deps="$_gpg4win_ex_deps $_gpg4win_i $1"
357           done)
358   )
359 ])
360
361 # GPG4WIN_KDEPKG([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
362 # Set up the source package PKG to be additionally built
363 # for the host provided as additional-gpgex-host
364 AC_DEFUN([GPG4WIN_KDEPKG],
365 [
366   AC_REQUIRE([GPG4WIN_INIT])
367   _gpg4win_pkg=maybe
368   AC_ARG_ENABLE([pkg-$1],
369     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
370                    [include package $1]),
371     _gpg4win_pkg=$enableval)
372   _gpg4win_kdepkg=no
373   _gpg4win_version=
374   AS_IF([test "$_gpg4win_pkg" != no],
375         [GPG4WIN_FIND($1,,, $_gpg4win_pkg,
376         _gpg4win_kdepkg=$gpg4win_val
377         _gpg4win_version=$gpg4win_version)])
378
379   # gpg4win_pkg_PKGNAME=FILENAME_OF_SOURCE
380   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_kdepkg
381   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
382
383   # gpg4win_pkg_PKGNAME_version=VERSION
384   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
385   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
386
387   # gpg4win_pkg_PKGNAME_deps=DEPS
388   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
389   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
390
391   AS_IF([test "$_gpg4win_kdepkg" != no],
392     _gpg4win_pkgs="$_gpg4win_pkgs $1"
393     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
394     # Record dependencies.  Also enter every package as node.
395     _gpg4win_deps="$_gpg4win_deps $1 $1"
396     AS_IF([test ! -z "$2"],
397           for _gpg4win_i in $2; do
398             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
399           done)
400       [$3],
401       [$4])
402 ])
403
404 # GPG4WIN_BPKG_GNUWIN32([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
405 # Set up the gnuwin32 package PKG.
406 # It is provided in gpg4win_val.
407 AC_DEFUN([GPG4WIN_BPKG_GNUWIN32],
408 [
409   AC_REQUIRE([GPG4WIN_INIT])
410   _gpg4win_pkg=maybe
411   AC_ARG_ENABLE([pkg-$1],
412     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
413                    [include package $1]),
414     _gpg4win_pkg=$enableval)
415   _gpg4win_bpkg=no
416   _gpg4win_version=
417   AS_IF([test "$_gpg4win_pkg" != no],
418         [GPG4WIN_FIND($1-bin, [$1-\(.*\)-bin],,
419          $_gpg4win_pkg,
420          _gpg4win_bpkg=$gpg4win_val
421          _gpg4win_version=$gpg4win_version)])
422
423   # At this point, _gpg4win_bpkg is no, or the actual package source file.
424
425   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
426   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
427   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
428
429   # gpg4win_pkg_PKGNAME_version=VERSION
430   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
431   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
432
433   # gpg4win_pkg_PKGNAME_deps=DEPS
434   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
435   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
436
437   AS_IF([test "$_gpg4win_bpkg" != "no" ],
438     GPG4WIN_FIND($1-lib, [$1-\(.*\)-lib],,
439                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
440        AC_MSG_ERROR(can not find development package for package $1))
441     # gpg4win_pkg_PKGNAME_dev=FILENAME_OF_BINARY_DEVEL
442     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev=$_gpg4win_bpkg
443     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev)
444
445     GPG4WIN_FIND($1-src, [$1-\(.*\)-src],,
446                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
447        AC_MSG_ERROR(can not find sources for package $1))
448     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
449     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
450     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
451
452     # FIXME: Add a version consistency check here.  All three packages
453     # must match!
454
455     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
456
457     _gpg4win_pkgs="$_gpg4win_pkgs $1"
458     # Record dependencies.  Also enter every package as node.
459     _gpg4win_deps="$_gpg4win_deps $1 $1"
460     AS_IF([test ! -z "$2"],
461           for _gpg4win_i in $2; do
462             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
463           done)
464           [$3],
465           [$4])
466 ])
467
468 # GPG4WIN_BPKG_GNUWIN32_LIB([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
469 # Set up the gnuwin32 package PKG.  This is a static only library version.
470 # It is provided in gpg4win_val.
471 AC_DEFUN([GPG4WIN_BPKG_GNUWIN32_LIB],
472 [
473   AC_REQUIRE([GPG4WIN_INIT])
474   _gpg4win_pkg=maybe
475   AC_ARG_ENABLE([pkg-$1],
476     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
477                    [include package $1]),
478     _gpg4win_pkg=$enableval)
479   _gpg4win_bpkg=no
480   _gpg4win_version=
481   AS_IF([test "$_gpg4win_pkg" != no],
482         [GPG4WIN_FIND($1-lib, [$1-\(.*\)-lib],,
483          $_gpg4win_pkg,
484          _gpg4win_bpkg=$gpg4win_val
485          _gpg4win_version=$gpg4win_version)])
486
487   # At this point, _gpg4win_bpkg is no, or the actual package source file.
488
489   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
490   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
491   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
492
493   # gpg4win_pkg_PKGNAME_version=VERSION
494   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
495   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
496
497   AS_IF([test "$_gpg4win_bpkg" != no],
498     GPG4WIN_FIND($1-src, [$1-\(.*\)-src],,
499                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
500        AC_MSG_ERROR(can not find sources for package $1))
501     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
502     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
503     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
504
505     # FIXME: Add a version consistency check here.  All two packages
506     # must match!
507
508     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
509
510     _gpg4win_pkgs="$_gpg4win_pkgs $1"
511     # Record dependencies.  Also enter every package as node.
512     _gpg4win_deps="$_gpg4win_deps $1 $1"
513     AS_IF([test ! -z "$2"],
514           for _gpg4win_i in $2; do
515             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
516           done)
517           [$3],
518           [$4])
519 ])
520
521
522 # GPG4WIN_BPKG_GTK([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
523 # Set up the Gtk binary package PKG.
524 # It is provided in gpg4win_val.
525 AC_DEFUN([GPG4WIN_BPKG_GTK],
526 [
527   AC_REQUIRE([GPG4WIN_INIT])
528   _gpg4win_pkg=maybe
529   AC_ARG_ENABLE([pkg-$1],
530     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
531                    [include package $1]),
532     _gpg4win_pkg=$enableval)
533   _gpg4win_bpkg=no
534   _gpg4win_version=
535   AS_IF([test "$_gpg4win_pkg" != no],
536         [GPG4WIN_FIND($1,,zip, $_gpg4win_pkg,
537          _gpg4win_bpkg=$gpg4win_val
538          _gpg4win_version=$gpg4win_version)])
539
540   # At this point, _gpg4win_bpkg is no, or the actual package source file.
541
542   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
543   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
544   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
545
546   # gpg4win_pkg_PKGNAME_version=VERSION
547   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
548   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
549
550   # gpg4win_pkg_PKGNAME_deps=DEPS
551   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
552   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
553
554   AS_IF([test "$_gpg4win_bpkg" != no],
555     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
556        AC_MSG_ERROR(can not find sources for package $1))]
557     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
558     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
559     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
560
561     # FIXME: Add a version consistency check here.  All three packages
562     # must match!
563
564     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
565
566     _gpg4win_pkgs="$_gpg4win_pkgs $1"
567     # Record dependencies.  Also enter every package as node.
568     _gpg4win_deps="$_gpg4win_deps $1 $1"
569     AS_IF([test ! -z "$2"],
570           for _gpg4win_i in $2; do
571             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
572           done)
573           [$3],
574           [$4])
575 ])
576
577
578 # GPG4WIN_BPKG_GTK_DEV([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
579 # Set up the Gtk library package PKG.
580 # It is provided in gpg4win_val.
581 AC_DEFUN([GPG4WIN_BPKG_GTK_DEV],
582 [
583   AC_REQUIRE([GPG4WIN_INIT])
584   _gpg4win_pkg=maybe
585   AC_ARG_ENABLE([pkg-$1],
586     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
587                    [include package $1]),
588     _gpg4win_pkg=$enableval)
589   _gpg4win_bpkg=no
590   _gpg4win_version=
591   AS_IF([test "$_gpg4win_pkg" != no],
592         [GPG4WIN_FIND($1,,zip, $_gpg4win_pkg,
593          _gpg4win_bpkg=$gpg4win_val
594          _gpg4win_version=$gpg4win_version)])
595
596   # At this point, _gpg4win_bpkg is no, or the actual package source file.
597
598   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
599   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
600   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
601
602   # gpg4win_pkg_PKGNAME_version=VERSION
603   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
604   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
605
606   # gpg4win_pkg_PKGNAME_deps=DEPS
607   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
608   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
609
610   AS_IF([test "$_gpg4win_bpkg" != no],
611     [GPG4WIN_FIND($1-dev,,, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
612        AC_MSG_ERROR(can not find development package for package $1))]
613     # gpg4win_pkg_PKGNAME_dev=FILENAME_OF_BINARY_DEVEL
614     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev=$_gpg4win_bpkg
615     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev)
616
617     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
618        AC_MSG_ERROR(can not find sources for package $1))]
619     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
620     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
621     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
622
623     # FIXME: Add a version consistency check here.  All three packages
624     # must match!
625
626     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
627
628     _gpg4win_pkgs="$_gpg4win_pkgs $1"
629     # Record dependencies.  Also enter every package as node.
630     _gpg4win_deps="$_gpg4win_deps $1 $1"
631     AS_IF([test ! -z "$2"],
632           for _gpg4win_i in $2; do
633             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
634           done)
635           [$3],
636           [$4])
637 ])
638
639
640 # GPG4WIN_BPKG_GNU([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
641 # Set up the source package PKG.
642 # It is provided in gpg4win_val.
643 AC_DEFUN([GPG4WIN_BPKG_GNU],
644 [
645   AC_REQUIRE([GPG4WIN_INIT])
646   _gpg4win_pkg=maybe
647   AC_ARG_ENABLE([pkg-$1],
648     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
649                    [include package $1]),
650     _gpg4win_pkg=$enableval)
651   _gpg4win_bpkg=no
652   _gpg4win_version=
653
654   AS_IF([test "$_gpg4win_pkg" != no],
655         [
656           # For some shameful reason, the gettext package is actually called
657           # gettext-runtime!
658           AS_IF([test $1 = gettext],
659                 [GPG4WIN_FIND($1-runtime,,zip, $_gpg4win_pkg,
660                              _gpg4win_bpkg=$gpg4win_val
661                              _gpg4win_version=$gpg4win_version)],
662                 [GPG4WIN_FIND($1,,zip, $_gpg4win_pkg,
663                              _gpg4win_bpkg=$gpg4win_val
664                              _gpg4win_version=$gpg4win_version)])
665         ])
666
667   # At this point, _gpg4win_bpkg is no, or the actual package source file.
668
669   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
670   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
671   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
672
673   # gpg4win_pkg_PKGNAME_version=VERSION
674   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
675   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
676
677   # gpg4win_pkg_PKGNAME_deps=DEPS
678   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
679   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
680
681   AS_IF([test "$_gpg4win_bpkg" != no],
682     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
683        AC_MSG_ERROR(can not find sources for package $1))]
684     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
685     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
686     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
687
688     # FIXME: Add a version consistency check here.  All two packages
689     # must match!
690
691     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
692
693     _gpg4win_pkgs="$_gpg4win_pkgs $1"
694     # Record dependencies.  Also enter every package as node.
695     _gpg4win_deps="$_gpg4win_deps $1 $1"
696     AS_IF([test ! -z "$2"],
697           for _gpg4win_i in $2; do
698             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
699           done)
700           [$3],
701           [$4])
702 ])
703
704
705 # GPG4WIN_BPKG_BINSRC([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
706 # Set up package PKG which is expected to be delivered as two ZIP files
707 # with a "-(src|source)" and a "-(bin|noinstaller)" suffix.
708 AC_DEFUN([GPG4WIN_BPKG_BINSRC],
709 [
710   AC_REQUIRE([GPG4WIN_INIT])
711   _gpg4win_pkg=maybe
712   AC_ARG_ENABLE([pkg-$1],
713     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
714                    [include package $1]),
715     _gpg4win_pkg=$enableval)
716   _gpg4win_bpkg=no
717   _gpg4win_version=
718   AS_IF([test "$_gpg4win_pkg" != no],
719         [GPG4WIN_FIND($1-bin, [$1-\(.*\)-bin],,
720          $_gpg4win_pkg,
721          _gpg4win_bpkg=$gpg4win_val
722          _gpg4win_version=$gpg4win_version)])
723   AS_IF([test "$_gpg4win_pkg" != no -a "$_gpg4win_bpkg" = no],
724         [GPG4WIN_FIND($1-noinstaller, [$1-\(.*\)-noinstaller],,
725          $_gpg4win_pkg,
726          _gpg4win_bpkg=$gpg4win_val
727          _gpg4win_version=$gpg4win_version)])
728
729   # At this point, _gpg4win_bpkg is no, or the actual package binary file.
730
731   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
732   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]=$_gpg4win_bpkg
733   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__]))
734
735   # gpg4win_pkg_PKGNAME_version=VERSION
736   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_version=$_gpg4win_version
737   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_version)
738
739   # gpg4win_pkg_PKGNAME_deps=DEPS
740   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
741   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
742
743   AS_IF([test "$_gpg4win_bpkg" != no],
744     tmp_binsrc=yes
745     GPG4WIN_FIND($1-src, [$1-\(.*\)-src],,
746                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val, tmp_binsrc=no)
747     if test $tmp_binsrc = no ; then
748        GPG4WIN_FIND($1-source, [$1-\(.*\)-source],,
749                     $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
750                     AC_MSG_ERROR(can not find sources for package $1))
751     fi
752     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
753     gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_src=$_gpg4win_bpkg
754     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_src)
755
756     # FIXME: Add a version consistency check here.  Both packages
757     # must match!
758
759     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
760
761     _gpg4win_pkgs="$_gpg4win_pkgs []m4_translit([$1],[A-Z],[a-z])"
762     # Record dependencies.  Also enter every package as node.
763     _gpg4win_deps="$_gpg4win_deps []m4_translit([$1],[A-Z],[a-z]) []m4_translit([$1],[A-Z],[a-z])"
764     AS_IF([test ! -z "$2"],
765           for _gpg4win_i in $2; do
766             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i []m4_translit([$1],[A-Z],[a-z])"
767           done)
768           [$3],
769           [$4])
770 ])
771
772 # Add a runtime library argument 1 should be the dll
773 # name without the .dll suffix
774 AC_DEFUN([GPG4WIN_RUNTIME_LIBRARY],
775 [
776     dll_path="no"
777     AC_ARG_WITH([$1],
778     AS_HELP_STRING([--with-$1-dll[=FILE]],
779                    [include FILE as runtime dependency for the installer.]),
780                    [dll_path=$withval])
781
782     if test "$dll_path" = "no"; then
783         changequote(,)
784         gcc_major_minor=$($CC --version \
785                           | awk 'NR==1 {split($NF,a,"."); print a[1] "." a[2]}')
786         changequote([,])
787         guesses="/usr/lib/gcc/$host/$gcc_major_minor/$1.dll
788                  /usr/$host/lib/$1.dll
789                  /usr/lib/gcc/$host/${gcc_major_minor}-win32/$1.dll"
790
791         for file in $guesses; do
792             if test -r "$file"; then
793                 dll_path="$file"
794                 break
795             fi
796         done
797     fi
798
799     if test "$dll_path" = "no"; then
800         AC_MSG_ERROR(can not find the runtime library $1.dll in the default locations.
801                      Use the --with-$1 option to set the path directly.
802         )
803     fi
804     AC_MSG_NOTICE(Using $dll_path to provide $1)
805     $CP "$dll_path" src/$1.dll-x
806     $STRIP src/$1.dll-x
807 ])