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