Summarize all packages with more than one version.
[gpg4win.git] / m4 / gpg4win.m4
1 dnl gpg4win.m4 - macros to configure gpg4win.
2 dnl Copyright (C) 2005 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 x$_gpg4win_dir = xyes -o x$_gpg4win_dir = xmaybe],
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.bz2`
125            _gpg4win_suffix=.tar.bz2])
126     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != zip],
127           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.tbz2`
128            _gpg4win_suffix=.tbz2])
129     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != zip],
130           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.tbz`
131            _gpg4win_suffix=.tbz])
132     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != zip],
133           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.tar.gz`
134            _gpg4win_suffix=.tar.gz])
135     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != zip],
136           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.tgz`
137            _gpg4win_suffix=.tgz])
138     AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_format != tar],
139           [_gpg4win_file=`echo ${_gpg4win_dir}/${_gpg4win_glob}.zip`
140            _gpg4win_suffix=.zip])
141     shopt -u nullglob])
142
143   AS_IF([test -z "$_gpg4win_file"],
144         AC_MSG_RESULT(no),
145         AS_IF([test `echo $_gpg4win_file | head -c 1` != /],
146               [_gpg4win_file=`pwd`/$_gpg4win_file])
147         AC_MSG_RESULT($_gpg4win_file))
148   AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_critical = yes],
149         AC_MSG_ERROR(could not find sources for $1 in $_gpg4win_dir))
150
151   # Test for duplicate.
152   _gpg4win_found=
153   for _gpg4win_f in $_gpg4win_file; do
154       AS_IF([test "$_gpg4win_found" = yes],
155             [AC_MSG_WARN(found more than one sources for $1 in $_gpg4win_dir)
156              gpg4win_dup_sources="$gpg4win_dup_sources $1"])
157       _gpg4win_found=yes
158   done
159
160   AS_IF([test ! -z "$_gpg4win_file"],
161         [gpg4win_val="$_gpg4win_file"
162         [gpg4win_version=`echo "$gpg4win_val" | sed -e "s,^.*/${_gpg4win_pat}${_gpg4win_suffix}$,\1,"`]
163          [$5]],
164         [$6])
165 ])
166
167
168 AC_DEFUN([GPG4WIN_CHECK_DEPS],
169 [
170   AC_MSG_CHECKING(build list)
171   gpg4win_build_list=`echo $_gpg4win_deps | tsort`
172   # Remove newlines.
173   gpg4win_build_list=`echo $gpg4win_build_list`
174   AC_MSG_RESULT($gpg4win_build_list)
175   AC_SUBST(gpg4win_build_list)
176
177   # Check each dependency.
178   _gpg4win_not_found=
179   _gpg4win_d=
180   _gpg4win_p=
181   for _gpg4win_p in $_gpg4win_deps; do
182     AS_IF([test -z $_gpg4win_d], [_gpg4win_d=$_gpg4win_p],
183           [
184             _gpg4win_found=
185             for _gpg4win_i in $_gpg4win_pkgs; do
186               AS_IF([test $_gpg4win_d = $_gpg4win_i],
187                     _gpg4win_found=yes
188                     break)
189             done
190             AS_IF([test -z $_gpg4win_found],
191                   AC_MSG_WARN(could not find package $_gpg4win_d required by package $_gpg4win_p)
192                   _gpg4win_not_found=yes)
193             _gpg4win_d=
194           ])
195   done
196   AS_IF([test ! -z "$_gpg4win_not_found"],
197         AC_MSG_ERROR([could not find some required packages]))
198 ])
199
200
201 AC_DEFUN([GPG4WIN_FINALIZE],
202 [
203   AC_REQUIRE([GPG4WIN_CHECK_DEPS])
204
205   _gpg4win_debug=no
206   AC_ARG_ENABLE([debug],
207     AS_HELP_STRING([--enable-debug], [enable debugging [[no]]]),
208     _gpg4win_debug=$enableval)
209
210   AS_IF([test "x${_gpg4win_debug}" != "xno"],
211     GPG4WIN_DEFINE(GPG4WIN_DEBUG))
212 ])
213
214
215 # GPG4WIN_IPKG([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
216 # Set up the internal package PKG.
217 # It is provided in gpg4win_val.
218 AC_DEFUN([GPG4WIN_IPKG],
219 [
220   AC_REQUIRE([GPG4WIN_INIT])
221   AC_MSG_CHECKING([for internal package $1])
222   _gpg4win_pkg=maybe
223   AC_ARG_ENABLE([pkg-$1],
224     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
225                    [include internal package $1]),
226     _gpg4win_pkg=$enableval,
227     _gpg4win_pkg=yes)
228
229   AC_MSG_RESULT($_gpg4win_pkg)
230
231   AS_IF([test "$_gpg4win_pkg" != no],
232     _gpg4win_pkgs="$_gpg4win_pkgs $1"
233     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
234     # Record dependencies.  Also enter every package as node.
235     _gpg4win_deps="$_gpg4win_deps $1 $1"
236     AS_IF([test ! -z "$2"],
237           for _gpg4win_i in $2; do
238             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
239           done)
240       [$3],
241       [$4])
242 ])
243
244
245
246 # GPG4WIN_SPKG([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
247 # Set up the source package PKG.
248 # It is provided in gpg4win_val.
249 AC_DEFUN([GPG4WIN_SPKG],
250 [
251   AC_REQUIRE([GPG4WIN_INIT])
252   _gpg4win_pkg=maybe
253   AC_ARG_ENABLE([pkg-$1],
254     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
255                    [include package $1]),
256     _gpg4win_pkg=$enableval)
257   _gpg4win_spkg=no
258   _gpg4win_version=
259   AS_IF([test x$_gpg4win_pkg != xno],
260         [GPG4WIN_FIND($1,,, $_gpg4win_pkg,
261          _gpg4win_spkg=$gpg4win_val
262          _gpg4win_version=$gpg4win_version)])
263
264   # At this point, _gpg4win_spkg is no, or the actual package source file.
265
266   # gpg4win_pkg_PKGNAME=FILENAME_OF_SOURCE
267   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_spkg
268   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
269
270   # gpg4win_pkg_PKGNAME_version=VERSION
271   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
272   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
273
274   AS_IF([test "$_gpg4win_spkg" != no],
275     _gpg4win_pkgs="$_gpg4win_pkgs $1"
276     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
277     # Record dependencies.  Also enter every package as node.
278     _gpg4win_deps="$_gpg4win_deps $1 $1"
279     AS_IF([test ! -z "$2"],
280           for _gpg4win_i in $2; do
281             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
282           done)
283       [$3],
284       [$4])
285 ])
286
287
288
289 # GPG4WIN_BPKG_GNUWIN32([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
290 # Set up the gnuwin32 package PKG.
291 # It is provided in gpg4win_val.
292 AC_DEFUN([GPG4WIN_BPKG_GNUWIN32],
293 [
294   AC_REQUIRE([GPG4WIN_INIT])
295   _gpg4win_pkg=maybe
296   AC_ARG_ENABLE([pkg-$1],
297     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
298                    [include package $1]),
299     _gpg4win_pkg=$enableval)
300   _gpg4win_bpkg=no
301   _gpg4win_version=
302   AS_IF([test x$_gpg4win_pkg != xno],
303         [GPG4WIN_FIND($1-bin, [$1-\(.*\)-bin],,
304          $_gpg4win_pkg,
305          _gpg4win_bpkg=$gpg4win_val
306          _gpg4win_version=$gpg4win_version)])
307
308   # At this point, _gpg4win_bpkg is no, or the actual package source file.
309
310   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
311   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
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   AS_IF([test $_gpg4win_bpkg != no],
319     GPG4WIN_FIND($1-lib, [$1-\(.*\)-lib],,
320                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
321        AC_MSG_ERROR(can not find development package for package $1))
322     # gpg4win_pkg_PKGNAME_dev=FILENAME_OF_BINARY_DEVEL
323     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev=$_gpg4win_bpkg
324     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev)
325
326     GPG4WIN_FIND($1-src, [$1-\(.*\)-src],,
327                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
328        AC_MSG_ERROR(can not find sources for package $1))
329     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
330     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
331     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
332
333     # FIXME: Add a version consistency check here.  All three packages
334     # must match!
335
336     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
337
338     _gpg4win_pkgs="$_gpg4win_pkgs $1"
339     # Record dependencies.  Also enter every package as node.
340     _gpg4win_deps="$_gpg4win_deps $1 $1"
341     AS_IF([test ! -z "$2"],
342           for _gpg4win_i in $2; do
343             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
344           done)
345           [$3],
346           [$4])
347 ])
348
349 # GPG4WIN_BPKG_GNUWIN32_LIB([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
350 # Set up the gnuwin32 package PKG.  This is a static only library version.
351 # It is provided in gpg4win_val.
352 AC_DEFUN([GPG4WIN_BPKG_GNUWIN32_LIB],
353 [
354   AC_REQUIRE([GPG4WIN_INIT])
355   _gpg4win_pkg=maybe
356   AC_ARG_ENABLE([pkg-$1],
357     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
358                    [include package $1]),
359     _gpg4win_pkg=$enableval)
360   _gpg4win_bpkg=no
361   _gpg4win_version=
362   AS_IF([test x$_gpg4win_pkg != xno],
363         [GPG4WIN_FIND($1-lib, [$1-\(.*\)-lib],,
364          $_gpg4win_pkg,
365          _gpg4win_bpkg=$gpg4win_val
366          _gpg4win_version=$gpg4win_version)])
367
368   # At this point, _gpg4win_bpkg is no, or the actual package source file.
369
370   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
371   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
372   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
373
374   # gpg4win_pkg_PKGNAME_version=VERSION
375   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
376   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
377
378   AS_IF([test $_gpg4win_bpkg != no],
379     GPG4WIN_FIND($1-src, [$1-\(.*\)-src],,
380                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
381        AC_MSG_ERROR(can not find sources for package $1))
382     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
383     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
384     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
385
386     # FIXME: Add a version consistency check here.  All two packages
387     # must match!
388
389     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
390
391     _gpg4win_pkgs="$_gpg4win_pkgs $1"
392     # Record dependencies.  Also enter every package as node.
393     _gpg4win_deps="$_gpg4win_deps $1 $1"
394     AS_IF([test ! -z "$2"],
395           for _gpg4win_i in $2; do
396             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
397           done)
398           [$3],
399           [$4])
400 ])
401
402
403 # GPG4WIN_BPKG_GTK([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
404 # Set up the Gtk binary package PKG.
405 # It is provided in gpg4win_val.
406 AC_DEFUN([GPG4WIN_BPKG_GTK],
407 [
408   AC_REQUIRE([GPG4WIN_INIT])
409   _gpg4win_pkg=maybe
410   AC_ARG_ENABLE([pkg-$1],
411     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
412                    [include package $1]),
413     _gpg4win_pkg=$enableval)
414   _gpg4win_bpkg=no
415   _gpg4win_version=
416   AS_IF([test x$_gpg4win_pkg != xno],
417         [GPG4WIN_FIND($1,,zip, $_gpg4win_pkg,
418          _gpg4win_bpkg=$gpg4win_val
419          _gpg4win_version=$gpg4win_version)])
420
421   # At this point, _gpg4win_bpkg is no, or the actual package source file.
422
423   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
424   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
425   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
426
427   # gpg4win_pkg_PKGNAME_version=VERSION
428   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
429   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
430
431   AS_IF([test $_gpg4win_bpkg != no],
432     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
433        AC_MSG_ERROR(can not find sources for package $1))]
434     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
435     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
436     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
437
438     # FIXME: Add a version consistency check here.  All three packages
439     # must match!
440
441     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
442
443     _gpg4win_pkgs="$_gpg4win_pkgs $1"
444     # Record dependencies.  Also enter every package as node.
445     _gpg4win_deps="$_gpg4win_deps $1 $1"
446     AS_IF([test ! -z "$2"],
447           for _gpg4win_i in $2; do
448             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
449           done)
450           [$3],
451           [$4])
452 ])
453
454
455 # GPG4WIN_BPKG_GTK_DEV([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
456 # Set up the Gtk library package PKG.
457 # It is provided in gpg4win_val.
458 AC_DEFUN([GPG4WIN_BPKG_GTK_DEV],
459 [
460   AC_REQUIRE([GPG4WIN_INIT])
461   _gpg4win_pkg=maybe
462   AC_ARG_ENABLE([pkg-$1],
463     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
464                    [include package $1]),
465     _gpg4win_pkg=$enableval)
466   _gpg4win_bpkg=no
467   _gpg4win_version=
468   AS_IF([test x$_gpg4win_pkg != xno],
469         [GPG4WIN_FIND($1,,zip, $_gpg4win_pkg,
470          _gpg4win_bpkg=$gpg4win_val
471          _gpg4win_version=$gpg4win_version)])
472
473   # At this point, _gpg4win_bpkg is no, or the actual package source file.
474
475   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
476   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
477   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
478
479   # gpg4win_pkg_PKGNAME_version=VERSION
480   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
481   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
482
483   AS_IF([test $_gpg4win_bpkg != no],
484     [GPG4WIN_FIND($1-dev,,, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
485        AC_MSG_ERROR(can not find development package for package $1))]
486     # gpg4win_pkg_PKGNAME_dev=FILENAME_OF_BINARY_DEVEL
487     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev=$_gpg4win_bpkg
488     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev)
489
490     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
491        AC_MSG_ERROR(can not find sources for package $1))]
492     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
493     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
494     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
495
496     # FIXME: Add a version consistency check here.  All three packages
497     # must match!
498
499     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
500
501     _gpg4win_pkgs="$_gpg4win_pkgs $1"
502     # Record dependencies.  Also enter every package as node.
503     _gpg4win_deps="$_gpg4win_deps $1 $1"
504     AS_IF([test ! -z "$2"],
505           for _gpg4win_i in $2; do
506             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
507           done)
508           [$3],
509           [$4])
510 ])
511
512
513 # GPG4WIN_BPKG_GNU([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
514 # Set up the source package PKG.
515 # It is provided in gpg4win_val.
516 AC_DEFUN([GPG4WIN_BPKG_GNU],
517 [
518   AC_REQUIRE([GPG4WIN_INIT])
519   _gpg4win_pkg=maybe
520   AC_ARG_ENABLE([pkg-$1],
521     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
522                    [include package $1]),
523     _gpg4win_pkg=$enableval)
524   _gpg4win_bpkg=no
525   _gpg4win_version=
526
527   AS_IF([test x$_gpg4win_pkg != xno],
528         [
529           # For some shameful reason, the gettext package is actually called
530           # gettext-runtime!
531           AS_IF([test $1 = gettext],
532                 [GPG4WIN_FIND($1-runtime,,zip, $_gpg4win_pkg,
533                              _gpg4win_bpkg=$gpg4win_val
534                              _gpg4win_version=$gpg4win_version)],
535                 [GPG4WIN_FIND($1,,zip, $_gpg4win_pkg,
536                              _gpg4win_bpkg=$gpg4win_val
537                              _gpg4win_version=$gpg4win_version)])
538         ])
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   AS_IF([test $_gpg4win_bpkg != no],
551     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
552        AC_MSG_ERROR(can not find sources for package $1))]
553     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
554     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
555     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
556
557     # FIXME: Add a version consistency check here.  All two packages
558     # must match!
559
560     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
561
562     _gpg4win_pkgs="$_gpg4win_pkgs $1"
563     # Record dependencies.  Also enter every package as node.
564     _gpg4win_deps="$_gpg4win_deps $1 $1"
565     AS_IF([test ! -z "$2"],
566           for _gpg4win_i in $2; do
567             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
568           done)
569           [$3],
570           [$4])
571 ])
572
573
574 # GPG4WIN_BPKG_BINSRC([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
575 # Set up package PKG which is expected to be delivered as two ZIP files
576 # with a "-(src|source)" and a "-(bin|noinstaller)" suffix.
577 AC_DEFUN([GPG4WIN_BPKG_BINSRC],
578 [
579   AC_REQUIRE([GPG4WIN_INIT])
580   _gpg4win_pkg=maybe
581   AC_ARG_ENABLE([pkg-$1],
582     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
583                    [include package $1]),
584     _gpg4win_pkg=$enableval)
585   _gpg4win_bpkg=no
586   _gpg4win_version=
587   AS_IF([test x$_gpg4win_pkg != xno],
588         [GPG4WIN_FIND($1-bin, [$1-\(.*\)-bin],,
589          $_gpg4win_pkg,
590          _gpg4win_bpkg=$gpg4win_val
591          _gpg4win_version=$gpg4win_version)])
592   AS_IF([test x$_gpg4win_pkg != xno -a x$_gpg4win_bpkg = xno],
593         [GPG4WIN_FIND($1-noinstaller, [$1-\(.*\)-noinstaller],,
594          $_gpg4win_pkg,
595          _gpg4win_bpkg=$gpg4win_val
596          _gpg4win_version=$gpg4win_version)])
597
598   # At this point, _gpg4win_bpkg is no, or the actual package binary file.
599
600   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
601   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]=$_gpg4win_bpkg
602   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__]))
603
604   # gpg4win_pkg_PKGNAME_version=VERSION
605   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_version=$_gpg4win_version
606   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_version)
607
608   AS_IF([test $_gpg4win_bpkg != no],
609     tmp_binsrc=yes
610     GPG4WIN_FIND($1-src, [$1-\(.*\)-src],,
611                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val, tmp_binsrc=no)
612     if test $tmp_binsrc = no ; then
613        GPG4WIN_FIND($1-source, [$1-\(.*\)-source],,
614                     $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val, 
615                     AC_MSG_ERROR(can not find sources for package $1))
616     fi
617     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
618     gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_src=$_gpg4win_bpkg
619     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_src)
620
621     # FIXME: Add a version consistency check here.  Both packages
622     # must match!
623
624     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
625
626     _gpg4win_pkgs="$_gpg4win_pkgs []m4_translit([$1],[A-Z],[a-z])"
627     # Record dependencies.  Also enter every package as node.
628     _gpg4win_deps="$_gpg4win_deps []m4_translit([$1],[A-Z],[a-z]) []m4_translit([$1],[A-Z],[a-z])"
629     AS_IF([test ! -z "$2"],
630           for _gpg4win_i in $2; do
631             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i []m4_translit([$1],[A-Z],[a-z])"
632           done)
633           [$3],
634           [$4])
635 ])
636