2005-10-20 Marcus Brinkmann <marcus@g10code.de>
authorMarcus Brinkmann <mb@g10code.com>
Thu, 20 Oct 2005 20:15:56 +0000 (20:15 +0000)
committerMarcus Brinkmann <mb@g10code.com>
Thu, 20 Oct 2005 20:15:56 +0000 (20:15 +0000)
* m4/gpg4win.m4 (GPG4WIN_DEFINE): New function.  Use it to define
feature symbols for NSI.  Use m4_translit instead of m4_bpatsubst.
New option --enable-debug.
* include/config.nsi.in: Catch all this new information.
* src/gpg4win.nsi (DEBUG): Define if [GPG4WIN_DEBUG].
(HAVE_PKG_GPA): Don't define here.
* src/inst-sections.nsi: Guard all package specific commands with
feature macro checks.  Calculate dependencies on .onInit, too.
* src/gpg4win.mk.in (STRIP_macro): Quote $(DEBUG) strictly.

ChangeLog
TODO
include/config.nsi.in
m4/gpg4win.m4
src/gpg4win.mk.in
src/gpg4win.nsi
src/inst-sections.nsi

index 4e82f3e..5cfa8e3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2005-10-20  Marcus Brinkmann  <marcus@g10code.de>
 
+       * m4/gpg4win.m4 (GPG4WIN_DEFINE): New function.  Use it to define
+       feature symbols for NSI.  Use m4_translit instead of m4_bpatsubst.
+       New option --enable-debug.
+       * include/config.nsi.in: Catch all this new information.
+       * src/gpg4win.nsi (DEBUG): Define if [GPG4WIN_DEBUG].
+       (HAVE_PKG_GPA): Don't define here.
+       * src/inst-sections.nsi: Guard all package specific commands with
+       feature macro checks.  Calculate dependencies on .onInit, too.
+       * src/gpg4win.mk.in (STRIP_macro): Quote $(DEBUG) strictly.
+
        * src/installer-finish.nsi: Add support for Add/Remove Programs.
 
 2005-10-20  Werner Koch  <wk@g10code.com>
diff --git a/TODO b/TODO
index 314fed2..692237d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,34 +1,30 @@
-* Record the dependencies in the build list in the gpg4win.mk.in
-   Makefile using make dependencies between the stamp-final-$(1)
-   targets.  This would hopefully ensure that parallel makes work. !
-
-* Invent something clever to cope with new versions of packages, which
+* Component related issues:
+** Check out which locale files to install and where. !!!
+** Check which iconv to use !!
+** Finish integration of GnuPG.
+** Add the missing packages: gpgee, Sylpheed, WinPT, Eudore extensions.
+** gpgol needs to be registered. !!!
+
+* The following items are related to package auto-detection and
+   configuration.  They are not critical.
+** Verify the digital signatures.  Include them in the source
+   installer.
+** BUG: If there is more than one version of a package, the script
+   breaks.  The GPG4WIN_FIND function must filter and pick one of the
+   matches.
+** GLITCH: If unnecessary dependency packages are enabled, they are
+   included in the installer, although they never will be (and can't
+   be) installed (they can't be installed because they can't be
+   selected).  To fix this, configure would need to know which
+   packages can be selected and which can't.
+** Invent something clever to cope with new versions of packages, which
    may have a different file list.  We can't use globs because Delete
    must still work.  Either have inst-PACKAGE-VERSION.nsi files, or
    have globs plus some scripting to generate the .nis files. !
+** Record the dependencies in the build list in the gpg4win.mk.in
+   Makefile using make dependencies between the stamp-final-$(1)
+   targets.  This would hopefully ensure that parallel makes work. !
 
-* Check out which locale files to install and where. !!!
-
-* Check which iconv to use !!
-
-* Finish modularization of installer.  NSIS' macro language is not up
-   to the task, so we need a bit of configure/make magic as well (a la
-   autoheader). !!!
-
-* Allow to enable debug mode from configure line. !
-
-* Finish integration of GnuPG.
-
-* Add the missing packages: gpgee, Sylpheed, WinPT, Eudore extensions.
-
-* gpgol needs to be registered. !!!
-
-* Verify the digital signatures.  Include them in the source
-   installer.
-
-* BUG: If there is more than one version of a package, the script
-   breaks.  The GPG4WIN_FIND function must filter and pick one of the
-   matches.
 
 Copyright 2005 g10 Code GmbH
 
index fa96bc3..305e231 100644 (file)
@@ -34,6 +34,8 @@
 !define INSTALL "@INSTALL@"
 !define WGET @WGET@
 
+# If debugging is desired.
+@GPG4WIN_DEBUG@
 
 # The package build list, in order.
 !define gpg4win_build_list "@gpg4win_build_list@"
 
 # The path of each package.
 
+@HAVE_PKG_LIBGPG_ERROR@
 !define gpg4win_pkg_libgpg_error @gpg4win_pkg_libgpg_error@
 !define gpg4win_pkg_libgpg_error_version @gpg4win_pkg_libgpg_error_version@
 
+@HAVE_PKG_GPGME@
 !define gpg4win_pkg_gpgme @gpg4win_pkg_gpgme@
 !define gpg4win_pkg_gpgme_version @gpg4win_pkg_gpgme_version@
 
+@HAVE_PKG_GNUPG@
 !define gpg4win_pkg_gnupg @gpg4win_pkg_gnupg@
 !define gpg4win_pkg_gnupg_version @gpg4win_pkg_gnupg_version@
 
+@HAVE_PKG_GPGOL@
 !define gpg4win_pkg_gpgol @gpg4win_pkg_gpgol@
 !define gpg4win_pkg_gpgol_version @gpg4win_pkg_gpgol_version@
 
+@HAVE_PKG_GPA@
 !define gpg4win_pkg_gpa @gpg4win_pkg_gpa@
 !define gpg4win_pkg_gpa_version @gpg4win_pkg_gpa_version@
 
+@HAVE_PKG_ZLIB@
 !define gpg4win_pkg_zlib @gpg4win_pkg_zlib@
 !define gpg4win_pkg_zlib_version @gpg4win_pkg_zlib_version@
 !define gpg4win_pkg_zlib_dev @gpg4win_pkg_zlib_dev@
 !define gpg4win_pkg_zlib_src @gpg4win_pkg_zlib_src@
 
+@HAVE_PKG_LIBPNG@
 !define gpg4win_pkg_libpng @gpg4win_pkg_libpng@
 !define gpg4win_pkg_libpng_version @gpg4win_pkg_libpng_version@
 !define gpg4win_pkg_libpng_dev @gpg4win_pkg_libpng_dev@
 !define gpg4win_pkg_libpng_src @gpg4win_pkg_libpng_src@
 
+@HAVE_PKG_PKGCONFIG@
 !define gpg4win_pkg_pkgconfig @gpg4win_pkg_pkgconfig@
 !define gpg4win_pkg_pkgconfig_version @gpg4win_pkg_pkgconfig_version@
 !define gpg4win_pkg_pkgconfig_src @gpg4win_pkg_pkgconfig_src@
 
+@HAVE_PKG_GLIB@
 !define gpg4win_pkg_glib @gpg4win_pkg_glib@
 !define gpg4win_pkg_glib_version @gpg4win_pkg_glib_version@
 !define gpg4win_pkg_glib_dev @gpg4win_pkg_glib_dev@
 !define gpg4win_pkg_glib_src @gpg4win_pkg_glib_src@
 
+@HAVE_PKG_ATK@
 !define gpg4win_pkg_atk @gpg4win_pkg_atk@
 !define gpg4win_pkg_atk_version @gpg4win_pkg_atk_version@
 !define gpg4win_pkg_atk_dev @gpg4win_pkg_atk_dev@
 !define gpg4win_pkg_atk_src @gpg4win_pkg_atk_src@
 
+@HAVE_PKG_PANGO@
 !define gpg4win_pkg_pango @gpg4win_pkg_pango@
 !define gpg4win_pkg_pango_version @gpg4win_pkg_pango_version@
 !define gpg4win_pkg_pango_dev @gpg4win_pkg_pango_dev@
 !define gpg4win_pkg_pango_src @gpg4win_pkg_pango_src@
 
+@HAVE_PKG_GTK_@
 !define gpg4win_pkg_gtk_ @gpg4win_pkg_gtk_@
 !define gpg4win_pkg_gtk__version @gpg4win_pkg_gtk__version@
 !define gpg4win_pkg_gtk__dev @gpg4win_pkg_gtk__dev@
 !define gpg4win_pkg_gtk__src @gpg4win_pkg_gtk__src@
 
+@HAVE_PKG_LIBICONV@
 !define gpg4win_pkg_libiconv @gpg4win_pkg_libiconv@
 !define gpg4win_pkg_libiconv_version @gpg4win_pkg_libiconv_version@
 !define gpg4win_pkg_libiconv_src @gpg4win_pkg_libiconv_src@
 
+@HAVE_PKG_GETTEXT@
 !define gpg4win_pkg_gettext @gpg4win_pkg_gettext@
 !define gpg4win_pkg_gettext_version @gpg4win_pkg_gettext_version@
 !define gpg4win_pkg_gettext_src @gpg4win_pkg_gettext_src@
index 7e504a9..aca8fb0 100644 (file)
@@ -19,6 +19,15 @@ dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 dnl MA 02110-1301, USA
 
 
+# GPG4WIN_DEFINE SYMBOL
+# A poor man's version of AC_DEFINE_UNQUOTED for NSIS.
+AC_DEFUN([GPG4WIN_DEFINE],
+[
+  eval $1=\"\!define $1 1\"
+  AC_SUBST($1)
+])
+
+
 # GPG4WIN_BASH
 # Gpg4Win needs bash.  This macro checks for it.
 AC_DEFUN([GPG4WIN_BASH],
@@ -182,6 +191,14 @@ AC_DEFUN([GPG4WIN_CHECK_DEPS],
 AC_DEFUN([GPG4WIN_FINALIZE],
 [
   AC_REQUIRE([GPG4WIN_CHECK_DEPS])
+
+  _gpg4win_debug=no
+  AC_ARG_ENABLE([debug],
+    AS_HELP_STRING([--enable-debug], [enable debugging [[no]]]),
+    _gpg4win_debug=$enableval)
+
+  AS_IF([test "x${_gpg4win_debug}" != "xno"],
+    GPG4WIN_DEFINE(GPG4WIN_DEBUG))
 ])
 
 
@@ -206,15 +223,16 @@ AC_DEFUN([GPG4WIN_SPKG],
   # At this point, _gpg4win_spkg is no, or the actual package source file.
 
   # gpg4win_pkg_PKGNAME=FILENAME_OF_SOURCE
-  gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]=$_gpg4win_spkg
-  AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_))
+  gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_spkg
+  AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
 
   # gpg4win_pkg_PKGNAME_version=VERSION
-  gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_version=$_gpg4win_version
-  AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_version)
+  gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
+  AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
 
   AS_IF([test "$_gpg4win_spkg" != no],
     _gpg4win_pkgs="$_gpg4win_pkgs $1"
+    GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
     # Record dependencies.  Also enter every package as node.
     _gpg4win_deps="$_gpg4win_deps $1 $1"
     AS_IF([test ! -z "$2"],
@@ -248,31 +266,33 @@ AC_DEFUN([GPG4WIN_BPKG_GNUWIN32],
   # At this point, _gpg4win_bpkg is no, or the actual package source file.
 
   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
-  gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]]-,_)[]=$_gpg4win_bpkg
-  AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_))
+  gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
+  AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
 
   # gpg4win_pkg_PKGNAME_version=VERSION
-  gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_version=$_gpg4win_version
-  AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_version)
+  gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
+  AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
 
   AS_IF([test $_gpg4win_bpkg != no],
     GPG4WIN_FIND($1-lib, [$1-\(.*\)-lib],,
                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
        AC_MSG_ERROR(can not find development package for package $1))
     # gpg4win_pkg_PKGNAME_dev=FILENAME_OF_BINARY_DEVEL
-    gpg4win_pkg_[]m4_bpatsubst([$1],-,_)[]_dev=$_gpg4win_bpkg
-    AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],-,_)[]_dev)
+    gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev=$_gpg4win_bpkg
+    AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev)
 
     GPG4WIN_FIND($1-src, [$1-\(.*\)-src],,
                  $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
        AC_MSG_ERROR(can not find sources for package $1))
     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
-    gpg4win_pkg_[]m4_bpatsubst([$1],-,_)[]_src=$_gpg4win_bpkg
-    AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],-,_)[]_src)
+    gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
+    AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
 
     # FIXME: Add a version consistency check here.  All three packages
     # must match!
 
+    GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
+
     _gpg4win_pkgs="$_gpg4win_pkgs $1"
     # Record dependencies.  Also enter every package as node.
     _gpg4win_deps="$_gpg4win_deps $1 $1"
@@ -306,23 +326,25 @@ AC_DEFUN([GPG4WIN_BPKG_GTK],
   # At this point, _gpg4win_bpkg is no, or the actual package source file.
 
   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
-  gpg4win_pkg_[]m4_bpatsubst([$1],-,_)[]=$_gpg4win_bpkg
-  AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],-,_))
+  gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
+  AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
 
   # gpg4win_pkg_PKGNAME_version=VERSION
-  gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_version=$_gpg4win_version
-  AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_version)
+  gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
+  AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
 
   AS_IF([test $_gpg4win_bpkg != no],
     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
        AC_MSG_ERROR(can not find sources for package $1))]
     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
-    gpg4win_pkg_[]m4_bpatsubst([$1],-,_)[]_src=$_gpg4win_bpkg
-    AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],-,_)[]_src)
+    gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
+    AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
 
     # FIXME: Add a version consistency check here.  All three packages
     # must match!
 
+    GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
+
     _gpg4win_pkgs="$_gpg4win_pkgs $1"
     # Record dependencies.  Also enter every package as node.
     _gpg4win_deps="$_gpg4win_deps $1 $1"
@@ -356,29 +378,31 @@ AC_DEFUN([GPG4WIN_BPKG_GTK_DEV],
   # At this point, _gpg4win_bpkg is no, or the actual package source file.
 
   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
-  gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]=$_gpg4win_bpkg
-  AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_))
+  gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
+  AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
 
   # gpg4win_pkg_PKGNAME_version=VERSION
-  gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_version=$_gpg4win_version
-  AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_version)
+  gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
+  AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
 
   AS_IF([test $_gpg4win_bpkg != no],
     [GPG4WIN_FIND($1-dev,,, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
        AC_MSG_ERROR(can not find development package for package $1))]
     # gpg4win_pkg_PKGNAME_dev=FILENAME_OF_BINARY_DEVEL
-    gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_dev=$_gpg4win_bpkg
-    AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_dev)
+    gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev=$_gpg4win_bpkg
+    AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_dev)
 
     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
        AC_MSG_ERROR(can not find sources for package $1))]
     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
-    gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_src=$_gpg4win_bpkg
-    AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_src)
+    gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
+    AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
 
     # FIXME: Add a version consistency check here.  All three packages
     # must match!
 
+    GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
+
     _gpg4win_pkgs="$_gpg4win_pkgs $1"
     # Record dependencies.  Also enter every package as node.
     _gpg4win_deps="$_gpg4win_deps $1 $1"
@@ -421,23 +445,25 @@ AC_DEFUN([GPG4WIN_BPKG_GNU],
   # At this point, _gpg4win_bpkg is no, or the actual package source file.
 
   # gpg4win_pkg_PKGNAME=FILENAME_OF_BINARY
-  gpg4win_pkg_[]m4_bpatsubst([$1],-,_)[]=$_gpg4win_bpkg
-  AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],-,_))
+  gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]=$_gpg4win_bpkg
+  AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__]))
 
   # gpg4win_pkg_PKGNAME_version=VERSION
-  gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_version=$_gpg4win_version
-  AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_version)
+  gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version=$_gpg4win_version
+  AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_version)
 
   AS_IF([test $_gpg4win_bpkg != no],
     [GPG4WIN_FIND($1,,tar, $_gpg4win_pkg, _gpg4win_bpkg=$gpg4win_val,
        AC_MSG_ERROR(can not find sources for package $1))]
     # gpg4win_pkg_PKGNAME_src=FILENAME_OF_SOURCE
-    gpg4win_pkg_[]m4_bpatsubst([$1],-,_)[]_src=$_gpg4win_bpkg
-    AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$1],-,_)[]_src)
+    gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src=$_gpg4win_bpkg
+    AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[-+],[__])[]_src)
 
     # FIXME: Add a version consistency check here.  All two packages
     # must match!
 
+    GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__]))
+
     _gpg4win_pkgs="$_gpg4win_pkgs $1"
     # Record dependencies.  Also enter every package as node.
     _gpg4win_deps="$_gpg4win_deps $1 $1"
@@ -448,5 +474,3 @@ AC_DEFUN([GPG4WIN_BPKG_GNU],
           [$3],
           [$4])
 ])
-
-
index 04bed2e..6bdcd4a 100644 (file)
@@ -81,7 +81,7 @@ endef
 
 # Support macro.  Strip all dll and exe files below $(1).
 define STRIP_macro
-       if test -z "$(DEBUG)"; then                     \
+       if test -z '$(DEBUG)'; then                     \
          (cd $(1);                                     \
           for f in `find . -name \*.dll                \
                  -o -name \*.exe`; do                  \
index 2d7f00e..b279efa 100644 (file)
@@ -18,7 +18,6 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
 !include "../include/config.nsi"
-!define HAVE_PKG_GPA 1
 
 # The package name and version.  PRETTY_PACKAGE is a user visible name
 # only while PACKAGE is useful for filenames etc.  PROD_VERSION is the
@@ -62,7 +61,9 @@
 
 
 # Define if in debug mode.
-#!define DEBUG
+!ifdef GPG4WIN_DEBUG
+!define DEBUG
+!endif
 
 
 # The installation directory.
index 98f03ec..f71ad29 100644 (file)
 
 # Sections
 
+!ifdef HAVE_PKG_GNUPG
 !include "inst-gnupg.nsi"
+!endif
+!ifdef HAVE_PKG_LIBGPG_ERROR
 !include "inst-libgpg-error.nsi"
+!endif
+!ifdef HAVE_PKG_LIBICONV
 !include "inst-libiconv.nsi"
+!endif
+!ifdef HAVE_PKG_PKGCONFIG
 !include "inst-pkgconfig.nsi"
+!endif
+!ifdef HAVE_PKG_ZLIB
 !include "inst-zlib.nsi"
+!endif
+!ifdef HAVE_PKG_GPGME
 !include "inst-gpgme.nsi"
+!endif
+!ifdef HAVE_PKG_GETTEXT
 !include "inst-gettext.nsi"
+!endif
+!ifdef HAVE_PKG_GLIB
 !include "inst-glib.nsi"
+!endif
+!ifdef HAVE_PKG_LIBPNG
 !include "inst-libpng.nsi"
+!endif
+!ifdef HAVE_PKG_GPGOL
 !include "inst-gpgol.nsi"
+!endif
+!ifdef HAVE_PKG_PANGO
 !include "inst-pango.nsi"
+!endif
+!ifdef HAVE_PKG_ATK
 !include "inst-atk.nsi"
+!endif
+!ifdef HAVE_PKG_GTK_
 !include "inst-gtk+.nsi"
+!endif
+!ifdef HAVE_PKG_GPA
 !include "inst-gpa.nsi"
+!endif
 
 # Dependency Management
 
 !include "Sections.nsh"
 
-Function .onSelChange
+Function CalcDepends
   # This section could very well be autogenerated from the
   # information in configure.ac.  Note that it doesn't hurt to have
   # stuff here for packages that we don't include.
 
   # First clear all indirect dependencies.
+!ifdef HAVE_PKG_LIBICONV
   !insertmacro UnselectSection ${SEC_libiconv}
+!endif
+!ifdef HAVE_PKG_GETTEXT
   !insertmacro UnselectSection ${SEC_gettext}
+!endif
+!ifdef HAVE_PKG_ZLIB
   !insertmacro UnselectSection ${SEC_zlib}
+!endif
+!ifdef HAVE_PKG_LIBPNG
   !insertmacro UnselectSection ${SEC_libpng}
+!endif
+!ifdef HAVE_PKG_PKGCONFIG
   !insertmacro UnselectSection ${SEC_pkgconfig}
+!endif
+!ifdef HAVE_PKG_GLIB
   !insertmacro UnselectSection ${SEC_glib}
+!endif
+!ifdef HAVE_PKG_ATK
   !insertmacro UnselectSection ${SEC_atk}
+!endif
+!ifdef HAVE_PKG_PANGO
   !insertmacro UnselectSection ${SEC_pango}
+!endif
+!ifdef HAVE_PKG_GTK_
   !insertmacro UnselectSection ${SEC_gtk_}
+!endif
+!ifdef HAVE_PKG_LIBGPG_ERROR
   !insertmacro UnselectSection ${SEC_libgpg_error}
+!endif
+!ifdef HAVE_PKG_GPGME
   !insertmacro UnselectSection ${SEC_gpgme}
+!endif
 
   # Then enable all dependencies in reverse build list order!
 
+!ifdef HAVE_PKG_GPA
   !insertmacro SectionFlagIsSet ${SEC_gpa} ${SF_SELECTED} have_gpa skip_gpa
   have_gpa:
   !insertmacro SelectSection ${SEC_zlib}
@@ -67,7 +118,9 @@ Function .onSelChange
   !insertmacro SelectSection ${SEC_gpgme}
   !insertmacro SelectSection ${SEC_gnupg}
   skip_gpa:
+!endif
 
+!ifdef HAVE_PKG_GTK_
   !insertmacro SectionFlagIsSet ${SEC_gtk_} \
                ${SF_SELECTED} have_gtk_ skip_gtk_
   have_gtk_:
@@ -78,51 +131,66 @@ Function .onSelChange
   !insertmacro SelectSection ${SEC_gettext}
   !insertmacro SelectSection ${SEC_pkgconfig}
   skip_gtk_:
+!endif
 
+!ifdef HAVE_PKG_ATK
   !insertmacro SectionFlagIsSet ${SEC_atk} \
                ${SF_SELECTED} have_atk skip_atk
   have_atk:
   !insertmacro SelectSection ${SEC_glib}
   !insertmacro SelectSection ${SEC_pkgconfig}
   skip_atk:
+!endif
 
+!ifdef HAVE_PKG_PANGO
   !insertmacro SectionFlagIsSet ${SEC_pango} \
                ${SF_SELECTED} have_pango skip_pango
   have_pango:
   !insertmacro SelectSection ${SEC_glib}
   !insertmacro SelectSection ${SEC_pkgconfig}
   skip_pango:
+!endif
 
+!ifdef HAVE_PKG_GPGOL
   !insertmacro SectionFlagIsSet ${SEC_gpgol} \
                ${SF_SELECTED} have_gpgol skip_gpgol
   have_gpgol:
   !insertmacro SelectSection ${SEC_gpgme}
   !insertmacro SelectSection ${SEC_gnupg}
   skip_gpgol:
+!endif
 
+!ifdef HAVE_PKG_LIBPNG
   !insertmacro SectionFlagIsSet ${SEC_libpng} \
                ${SF_SELECTED} have_libpng skip_libpng
   have_libpng:
   !insertmacro SelectSection ${SEC_pkgconfig}
   skip_libpng:
+!endif
 
+!ifdef HAVE_PKG_GLIB
   !insertmacro SectionFlagIsSet ${SEC_glib} \
                ${SF_SELECTED} have_glib skip_glib
   have_glib:
   !insertmacro SelectSection ${SEC_pkgconfig}
   skip_glib:
+!endif
 
+!ifdef HAVE_PKG_GETTEXT
   !insertmacro SectionFlagIsSet ${SEC_gettext} \
                ${SF_SELECTED} have_gettext skip_gettext
   have_gettext:
   !insertmacro SelectSection ${SEC_libiconv}
   skip_gettext:
+!endif
 
+!ifdef HAVE_PKG_GPGME
   !insertmacro SectionFlagIsSet ${SEC_gpgme} \
                ${SF_SELECTED} have_gpgme skip_gpgme
   have_gpgme:
   !insertmacro SelectSection ${SEC_libgpg_error}
   skip_gpgme:
+!endif
 
   # Package "zlib" has no dependencies.
   # Package "pkgconfig" has no dependencies.
@@ -132,13 +200,27 @@ Function .onSelChange
 
 FunctionEnd
 
+Function .onInit
+  Call CalcDepends
+FunctionEnd
+
+Function .onSelChange
+  Call CalcDepends
+FunctionEnd
+
 
 # This must be in a central place.  Urgs.
 
 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
+!ifdef HAVE_PKG_GPGOL
   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gpgol} $(DESC_SEC_gpgol)
+!endif
+!ifdef HAVE_PKG_GPA
   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gpa} $(DESC_SEC_gpa)
+!endif
+!ifdef HAVE_PKG_GNUPG
   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gnupg} $(DESC_SEC_gnupg)
+!endif
 !insertmacro MUI_FUNCTION_DESCRIPTION_END