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