Add repacked kleopatra.
[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     shopt -u nullglob])
145
146   AS_IF([test -z "$_gpg4win_file"],
147         AC_MSG_RESULT(no),
148         AS_IF([test `echo $_gpg4win_file | head -c 1` != /],
149               [_gpg4win_file=`pwd`/$_gpg4win_file])
150         AC_MSG_RESULT($_gpg4win_file))
151   AS_IF([test -z "$_gpg4win_file" -a $_gpg4win_critical = yes],
152         AC_MSG_ERROR(could not find sources for $1 in $_gpg4win_dir))
153
154   # Test for duplicate.
155   _gpg4win_found=
156   for _gpg4win_f in $_gpg4win_file; do
157       AS_IF([test "$_gpg4win_found" = yes],
158             [AC_MSG_WARN(found more than one sources for $1 in $_gpg4win_dir)
159              gpg4win_dup_sources="$gpg4win_dup_sources $1"])
160       _gpg4win_found=yes
161   done
162
163   AS_IF([test ! -z "$_gpg4win_file"],
164         [gpg4win_val="$_gpg4win_file"
165         [gpg4win_version=`echo "$gpg4win_val" | sed -e "s,^.*/${_gpg4win_pat}${_gpg4win_suffix}$,\1,"`]
166          [$5]],
167         [$6])
168 ])
169
170 AC_DEFUN([GPG4WIN_CHECK_EXDEPS],
171 [
172   AC_REQUIRE([GPG4WIN_CHECK_DEPS])
173
174   AC_MSG_CHECKING([additional host build list])
175
176   gpg4win_build_ex_list=`echo $_gpg4win_ex_deps | tsort`
177   # Remove newlines.
178   gpg4win_build_ex_list=`echo $gpg4win_build_ex_list`
179   AC_MSG_RESULT($gpg4win_build_ex_list)
180   AC_SUBST(gpg4win_build_ex_list)
181
182   # Check each dependency.
183   _gpg4win_not_found=
184   _gpg4win_d=
185   _gpg4win_p=
186   for _gpg4win_p in $_gpg4win_ex_deps; do
187     AS_IF([test -z $_gpg4win_d], [_gpg4win_d=$_gpg4win_p],
188           [
189             _gpg4win_found=
190             for _gpg4win_i in $_gpg4win_pkgs; do
191               AS_IF([test $_gpg4win_d = $_gpg4win_i],
192                     _gpg4win_found=yes
193                     break)
194             done
195             AS_IF([test -z $_gpg4win_found],
196                   AC_MSG_WARN(could not find ex variant of package $_gpg4win_d required by package $_gpg4win_p)
197                   _gpg4win_not_found=yes)
198             _gpg4win_d=
199           ])
200   done
201   AS_IF([test ! -z "$_gpg4win_not_found"],
202         AC_MSG_ERROR([could not find some required packages]))
203 ])
204
205 AC_DEFUN([GPG4WIN_CHECK_DEPS],
206 [
207   AC_MSG_CHECKING(build list)
208   gpg4win_build_list=`echo $_gpg4win_deps | tsort`
209   # Remove newlines.
210   gpg4win_build_list=`echo $gpg4win_build_list`
211   AC_MSG_RESULT($gpg4win_build_list)
212   AC_SUBST(gpg4win_build_list)
213
214   # Check each dependency.
215   _gpg4win_not_found=
216   _gpg4win_d=
217   _gpg4win_p=
218   for _gpg4win_p in $_gpg4win_deps; do
219     AS_IF([test -z $_gpg4win_d], [_gpg4win_d=$_gpg4win_p],
220           [
221             _gpg4win_found=
222             for _gpg4win_i in $_gpg4win_pkgs; do
223               AS_IF([test $_gpg4win_d = $_gpg4win_i],
224                     _gpg4win_found=yes
225                     break)
226             done
227             AS_IF([test -z $_gpg4win_found],
228                   AC_MSG_WARN(could not find package $_gpg4win_d required by package $_gpg4win_p)
229                   _gpg4win_not_found=yes)
230             _gpg4win_d=
231           ])
232   done
233   AS_IF([test ! -z "$_gpg4win_not_found"],
234         AC_MSG_ERROR([could not find some required packages]))
235 ])
236
237
238 AC_DEFUN([GPG4WIN_FINALIZE],
239 [
240   AC_REQUIRE([GPG4WIN_CHECK_EXDEPS])
241
242   _gpg4win_debug=no
243   AC_ARG_ENABLE([debug],
244     AS_HELP_STRING([--enable-debug], [enable debugging [[no]]]),
245     _gpg4win_debug=$enableval)
246
247   AS_IF([test "${_gpg4win_debug}" != no],
248     GPG4WIN_DEFINE(GPG4WIN_DEBUG))
249 ])
250
251
252 # GPG4WIN_IPKG([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
253 # Set up the internal package PKG.
254 # It is provided in gpg4win_val.
255 AC_DEFUN([GPG4WIN_IPKG],
256 [
257   AC_REQUIRE([GPG4WIN_INIT])
258   AC_MSG_CHECKING([for internal package $1])
259   _gpg4win_pkg=maybe
260   AC_ARG_ENABLE([pkg-$1],
261     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
262                    [include internal package $1]),
263     _gpg4win_pkg=$enableval,
264     _gpg4win_pkg=yes)
265
266   # gpg4win_pkg_PKGNAME_deps=DEPS
267   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
268   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
269
270   AC_MSG_RESULT($_gpg4win_pkg)
271
272   AS_IF([test "$_gpg4win_pkg" != no],
273     _gpg4win_pkgs="$_gpg4win_pkgs $1"
274     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
275     # Record dependencies.  Also enter every package as node.
276     _gpg4win_deps="$_gpg4win_deps $1 $1"
277     AS_IF([test ! -z "$2"],
278           for _gpg4win_i in $2; do
279             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
280           done)
281       [$3],
282       [$4])
283 ])
284
285
286
287 # GPG4WIN_SPKG([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
288 # Set up the source package PKG.
289 # It is provided in gpg4win_val.
290 AC_DEFUN([GPG4WIN_SPKG],
291 [
292   AC_REQUIRE([GPG4WIN_INIT])
293   _gpg4win_pkg=maybe
294   AC_ARG_ENABLE([pkg-$1],
295     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
296                    [include package $1]),
297     _gpg4win_pkg=$enableval)
298   _gpg4win_spkg=no
299   _gpg4win_version=
300   AS_IF([test "$_gpg4win_pkg" != no],
301         [GPG4WIN_FIND($1,,, $_gpg4win_pkg,
302          _gpg4win_spkg=$gpg4win_val
303          _gpg4win_version=$gpg4win_version)])
304
305   # At this point, _gpg4win_spkg is no, or the actual package source file.
306
307   # gpg4win_pkg_PKGNAME=FILENAME_OF_SOURCE
308   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_spkg
309   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
310
311   # gpg4win_pkg_PKGNAME_version=VERSION
312   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
313   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
314
315   # gpg4win_pkg_PKGNAME_deps=DEPS
316   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
317   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
318
319   AS_IF([test "$_gpg4win_spkg" != no],
320     _gpg4win_pkgs="$_gpg4win_pkgs $1"
321     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
322     # Record dependencies.  Also enter every package as node.
323     _gpg4win_deps="$_gpg4win_deps $1 $1"
324     AS_IF([test ! -z "$2"],
325           for _gpg4win_i in $2; do
326             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
327           done)
328       [$3],
329       [$4])
330 ])
331
332
333 # GPG4WIN_SPKGEX([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
334 # Set up the source package PKG to be additionally built
335 # for the host provided as additional-gpgex-host
336 AC_DEFUN([GPG4WIN_SPKGEX],
337 [
338   GPG4WIN_SPKG([$1],[$2],[$3],[$4])
339
340   AS_IF([test ! -z "$GPGEX_ADD_HOST"],
341
342     # gpg4win_pkg_PKGNAME_deps=DEPS
343     gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_ex_deps="$2"
344     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_ex_deps)
345
346     gpg4win_ex_pkgs="$gpg4win_ex_pkgs $1"
347
348     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__])_EX)
349     # Record dependencies.  Also enter every package as node.
350     _gpg4win_ex_deps="$_gpg4win_ex_deps $1 $1"
351     AS_IF([test ! -z "$2"],
352           for _gpg4win_i in $2; do
353             _gpg4win_ex_deps="$_gpg4win_ex_deps $_gpg4win_i $1"
354           done)
355   )
356 ])
357
358 # GPG4WIN_BPKG_GNUWIN32([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
359 # Set up the gnuwin32 package PKG.
360 # It is provided in gpg4win_val.
361 AC_DEFUN([GPG4WIN_BPKG_GNUWIN32],
362 [
363   AC_REQUIRE([GPG4WIN_INIT])
364   _gpg4win_pkg=maybe
365   AC_ARG_ENABLE([pkg-$1],
366     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
367                    [include package $1]),
368     _gpg4win_pkg=$enableval)
369   _gpg4win_bpkg=no
370   _gpg4win_version=
371   AS_IF([test "$_gpg4win_pkg" != no],
372         [GPG4WIN_FIND($1-bin, [$1-\(.*\)-bin],,
373          $_gpg4win_pkg,
374          _gpg4win_bpkg=$gpg4win_val
375          _gpg4win_version=$gpg4win_version)])
376
377   # At this point, _gpg4win_bpkg is no, or the actual package source file.
378
379   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
380   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
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_bpkg" != "no" ],
392     GPG4WIN_FIND($1-lib, [$1-\(.*\)-lib],,
393                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
394        AC_MSG_ERROR(can not find development package for package $1))
395     # gpg4win_pkg_PKGNAME_dev=FILENAME_OF_BINARY_DEVEL
396     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev=$_gpg4win_bpkg
397     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev)
398
399     GPG4WIN_FIND($1-src, [$1-\(.*\)-src],,
400                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
401        AC_MSG_ERROR(can not find sources for package $1))
402     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
403     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
404     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
405
406     # FIXME: Add a version consistency check here.  All three packages
407     # must match!
408
409     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
410
411     _gpg4win_pkgs="$_gpg4win_pkgs $1"
412     # Record dependencies.  Also enter every package as node.
413     _gpg4win_deps="$_gpg4win_deps $1 $1"
414     AS_IF([test ! -z "$2"],
415           for _gpg4win_i in $2; do
416             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
417           done)
418           [$3],
419           [$4])
420 ])
421
422 # GPG4WIN_BPKG_GNUWIN32_LIB([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
423 # Set up the gnuwin32 package PKG.  This is a static only library version.
424 # It is provided in gpg4win_val.
425 AC_DEFUN([GPG4WIN_BPKG_GNUWIN32_LIB],
426 [
427   AC_REQUIRE([GPG4WIN_INIT])
428   _gpg4win_pkg=maybe
429   AC_ARG_ENABLE([pkg-$1],
430     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
431                    [include package $1]),
432     _gpg4win_pkg=$enableval)
433   _gpg4win_bpkg=no
434   _gpg4win_version=
435   AS_IF([test "$_gpg4win_pkg" != no],
436         [GPG4WIN_FIND($1-lib, [$1-\(.*\)-lib],,
437          $_gpg4win_pkg,
438          _gpg4win_bpkg=$gpg4win_val
439          _gpg4win_version=$gpg4win_version)])
440
441   # At this point, _gpg4win_bpkg is no, or the actual package source file.
442
443   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
444   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
445   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
446
447   # gpg4win_pkg_PKGNAME_version=VERSION
448   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
449   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
450
451   AS_IF([test "$_gpg4win_bpkg" != no],
452     GPG4WIN_FIND($1-src, [$1-\(.*\)-src],,
453                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
454        AC_MSG_ERROR(can not find sources for package $1))
455     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
456     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
457     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
458
459     # FIXME: Add a version consistency check here.  All two packages
460     # must match!
461
462     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
463
464     _gpg4win_pkgs="$_gpg4win_pkgs $1"
465     # Record dependencies.  Also enter every package as node.
466     _gpg4win_deps="$_gpg4win_deps $1 $1"
467     AS_IF([test ! -z "$2"],
468           for _gpg4win_i in $2; do
469             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
470           done)
471           [$3],
472           [$4])
473 ])
474
475
476 # GPG4WIN_BPKG_GTK([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
477 # Set up the Gtk binary package PKG.
478 # It is provided in gpg4win_val.
479 AC_DEFUN([GPG4WIN_BPKG_GTK],
480 [
481   AC_REQUIRE([GPG4WIN_INIT])
482   _gpg4win_pkg=maybe
483   AC_ARG_ENABLE([pkg-$1],
484     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
485                    [include package $1]),
486     _gpg4win_pkg=$enableval)
487   _gpg4win_bpkg=no
488   _gpg4win_version=
489   AS_IF([test "$_gpg4win_pkg" != no],
490         [GPG4WIN_FIND($1,,zip, $_gpg4win_pkg,
491          _gpg4win_bpkg=$gpg4win_val
492          _gpg4win_version=$gpg4win_version)])
493
494   # At this point, _gpg4win_bpkg is no, or the actual package source file.
495
496   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
497   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
498   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
499
500   # gpg4win_pkg_PKGNAME_version=VERSION
501   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
502   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
503
504   # gpg4win_pkg_PKGNAME_deps=DEPS
505   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
506   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
507
508   AS_IF([test "$_gpg4win_bpkg" != no],
509     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
510        AC_MSG_ERROR(can not find sources for package $1))]
511     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
512     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
513     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
514
515     # FIXME: Add a version consistency check here.  All three packages
516     # must match!
517
518     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
519
520     _gpg4win_pkgs="$_gpg4win_pkgs $1"
521     # Record dependencies.  Also enter every package as node.
522     _gpg4win_deps="$_gpg4win_deps $1 $1"
523     AS_IF([test ! -z "$2"],
524           for _gpg4win_i in $2; do
525             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
526           done)
527           [$3],
528           [$4])
529 ])
530
531
532 # GPG4WIN_BPKG_GTK_DEV([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
533 # Set up the Gtk library package PKG.
534 # It is provided in gpg4win_val.
535 AC_DEFUN([GPG4WIN_BPKG_GTK_DEV],
536 [
537   AC_REQUIRE([GPG4WIN_INIT])
538   _gpg4win_pkg=maybe
539   AC_ARG_ENABLE([pkg-$1],
540     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
541                    [include package $1]),
542     _gpg4win_pkg=$enableval)
543   _gpg4win_bpkg=no
544   _gpg4win_version=
545   AS_IF([test "$_gpg4win_pkg" != no],
546         [GPG4WIN_FIND($1,,zip, $_gpg4win_pkg,
547          _gpg4win_bpkg=$gpg4win_val
548          _gpg4win_version=$gpg4win_version)])
549
550   # At this point, _gpg4win_bpkg is no, or the actual package source file.
551
552   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
553   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
554   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
555
556   # gpg4win_pkg_PKGNAME_version=VERSION
557   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
558   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
559
560   # gpg4win_pkg_PKGNAME_deps=DEPS
561   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
562   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
563
564   AS_IF([test "$_gpg4win_bpkg" != no],
565     [GPG4WIN_FIND($1-dev,,, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
566        AC_MSG_ERROR(can not find development package for package $1))]
567     # gpg4win_pkg_PKGNAME_dev=FILENAME_OF_BINARY_DEVEL
568     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev=$_gpg4win_bpkg
569     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev)
570
571     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
572        AC_MSG_ERROR(can not find sources for package $1))]
573     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
574     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
575     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
576
577     # FIXME: Add a version consistency check here.  All three packages
578     # must match!
579
580     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
581
582     _gpg4win_pkgs="$_gpg4win_pkgs $1"
583     # Record dependencies.  Also enter every package as node.
584     _gpg4win_deps="$_gpg4win_deps $1 $1"
585     AS_IF([test ! -z "$2"],
586           for _gpg4win_i in $2; do
587             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
588           done)
589           [$3],
590           [$4])
591 ])
592
593
594 # GPG4WIN_BPKG_GNU([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
595 # Set up the source package PKG.
596 # It is provided in gpg4win_val.
597 AC_DEFUN([GPG4WIN_BPKG_GNU],
598 [
599   AC_REQUIRE([GPG4WIN_INIT])
600   _gpg4win_pkg=maybe
601   AC_ARG_ENABLE([pkg-$1],
602     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
603                    [include package $1]),
604     _gpg4win_pkg=$enableval)
605   _gpg4win_bpkg=no
606   _gpg4win_version=
607
608   AS_IF([test "$_gpg4win_pkg" != no],
609         [
610           # For some shameful reason, the gettext package is actually called
611           # gettext-runtime!
612           AS_IF([test $1 = gettext],
613                 [GPG4WIN_FIND($1-runtime,,zip, $_gpg4win_pkg,
614                              _gpg4win_bpkg=$gpg4win_val
615                              _gpg4win_version=$gpg4win_version)],
616                 [GPG4WIN_FIND($1,,zip, $_gpg4win_pkg,
617                              _gpg4win_bpkg=$gpg4win_val
618                              _gpg4win_version=$gpg4win_version)])
619         ])
620
621   # At this point, _gpg4win_bpkg is no, or the actual package source file.
622
623   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
624   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
625   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
626
627   # gpg4win_pkg_PKGNAME_version=VERSION
628   gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
629   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
630
631   # gpg4win_pkg_PKGNAME_deps=DEPS
632   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
633   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
634
635   AS_IF([test "$_gpg4win_bpkg" != no],
636     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
637        AC_MSG_ERROR(can not find sources for package $1))]
638     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
639     gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
640     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
641
642     # FIXME: Add a version consistency check here.  All two packages
643     # must match!
644
645     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
646
647     _gpg4win_pkgs="$_gpg4win_pkgs $1"
648     # Record dependencies.  Also enter every package as node.
649     _gpg4win_deps="$_gpg4win_deps $1 $1"
650     AS_IF([test ! -z "$2"],
651           for _gpg4win_i in $2; do
652             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
653           done)
654           [$3],
655           [$4])
656 ])
657
658
659 # GPG4WIN_BPKG_BINSRC([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
660 # Set up package PKG which is expected to be delivered as two ZIP files
661 # with a "-(src|source)" and a "-(bin|noinstaller)" suffix.
662 AC_DEFUN([GPG4WIN_BPKG_BINSRC],
663 [
664   AC_REQUIRE([GPG4WIN_INIT])
665   _gpg4win_pkg=maybe
666   AC_ARG_ENABLE([pkg-$1],
667     AS_HELP_STRING([--enable-pkg-$1[=DIR]],
668                    [include package $1]),
669     _gpg4win_pkg=$enableval)
670   _gpg4win_bpkg=no
671   _gpg4win_version=
672   AS_IF([test "$_gpg4win_pkg" != no],
673         [GPG4WIN_FIND($1-bin, [$1-\(.*\)-bin],,
674          $_gpg4win_pkg,
675          _gpg4win_bpkg=$gpg4win_val
676          _gpg4win_version=$gpg4win_version)])
677   AS_IF([test "$_gpg4win_pkg" != no -a "$_gpg4win_bpkg" = no],
678         [GPG4WIN_FIND($1-noinstaller, [$1-\(.*\)-noinstaller],,
679          $_gpg4win_pkg,
680          _gpg4win_bpkg=$gpg4win_val
681          _gpg4win_version=$gpg4win_version)])
682
683   # At this point, _gpg4win_bpkg is no, or the actual package binary file.
684
685   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
686   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]=$_gpg4win_bpkg
687   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__]))
688
689   # gpg4win_pkg_PKGNAME_version=VERSION
690   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_version=$_gpg4win_version
691   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_version)
692
693   # gpg4win_pkg_PKGNAME_deps=DEPS
694   gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps="$2"
695   AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_deps)
696
697   AS_IF([test "$_gpg4win_bpkg" != no],
698     tmp_binsrc=yes
699     GPG4WIN_FIND($1-src, [$1-\(.*\)-src],,
700                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val, tmp_binsrc=no)
701     if test $tmp_binsrc = no ; then
702        GPG4WIN_FIND($1-source, [$1-\(.*\)-source],,
703                     $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
704                     AC_MSG_ERROR(can not find sources for package $1))
705     fi
706     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
707     gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_src=$_gpg4win_bpkg
708     AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_src)
709
710     # FIXME: Add a version consistency check here.  Both packages
711     # must match!
712
713     GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
714
715     _gpg4win_pkgs="$_gpg4win_pkgs []m4_translit([$1],[A-Z],[a-z])"
716     # Record dependencies.  Also enter every package as node.
717     _gpg4win_deps="$_gpg4win_deps []m4_translit([$1],[A-Z],[a-z]) []m4_translit([$1],[A-Z],[a-z])"
718     AS_IF([test ! -z "$2"],
719           for _gpg4win_i in $2; do
720             _gpg4win_deps="$_gpg4win_deps $_gpg4win_i []m4_translit([$1],[A-Z],[a-z])"
721           done)
722           [$3],
723           [$4])
724 ])
725