Add macros for packages in extra architecture
authorAndre Heinecke <aheinecke@intevation.de>
Fri, 14 Jun 2013 14:50:03 +0000 (14:50 +0000)
committerAndre Heinecke <aheinecke@intevation.de>
Fri, 14 Jun 2013 14:50:03 +0000 (14:50 +0000)
    This is a requirement to build gpgEx both for x86 and
    amd64 architectures.

    * m4/gpg4win.m4 (GPG4WIN_CHECK_EXDEPS, GPG4WIN_SPKGEX): New.
    * src/gpg4win.mk.in (SETVARS_EX, STRIP_EX, GETDEPS_EX): New
    helper macros for building in another architecture.
    * src/gpg4win.mk.in (EXPKG_template): New template to build
    for an additional host as defined by GPGEX_ADD_HOST

--
    If we build for another architecture we now use an additional
    install-ex directory in which we install and stow the packages
    needed in a different architecture. The GPG4WIN_SPKGEX macro
    can be used to mark down packages that should be built in both
    the host architecture and in an additional architecture defined
    by GPGEX_ADD_HOST.

m4/gpg4win.m4
src/gpg4win.mk.in

index ac2de93..eeb13c4 100644 (file)
@@ -167,6 +167,40 @@ AC_DEFUN([GPG4WIN_FIND],
         [$6])
 ])
 
+AC_DEFUN([GPG4WIN_CHECK_EXDEPS],
+[
+  AC_REQUIRE([GPG4WIN_CHECK_DEPS])
+
+  AC_MSG_CHECKING([additional host build list])
+
+  gpg4win_build_ex_list=`echo $_gpg4win_ex_deps | tsort`
+  # Remove newlines.
+  gpg4win_build_ex_list=`echo $gpg4win_build_ex_list`
+  AC_MSG_RESULT($gpg4win_build_ex_list)
+  AC_SUBST(gpg4win_build_ex_list)
+
+  # Check each dependency.
+  _gpg4win_not_found=
+  _gpg4win_d=
+  _gpg4win_p=
+  for _gpg4win_p in $_gpg4win_ex_deps; do
+    AS_IF([test -z $_gpg4win_d], [_gpg4win_d=$_gpg4win_p],
+          [
+            _gpg4win_found=
+            for _gpg4win_i in $_gpg4win_pkgs; do
+              AS_IF([test $_gpg4win_d = $_gpg4win_i],
+                    _gpg4win_found=yes
+                    break)
+            done
+            AS_IF([test -z $_gpg4win_found],
+                  AC_MSG_WARN(could not find ex variant of package $_gpg4win_d required by package $_gpg4win_p)
+                  _gpg4win_not_found=yes)
+            _gpg4win_d=
+          ])
+  done
+  AS_IF([test ! -z "$_gpg4win_not_found"],
+        AC_MSG_ERROR([could not find some required packages]))
+])
 
 AC_DEFUN([GPG4WIN_CHECK_DEPS],
 [
@@ -203,7 +237,7 @@ AC_DEFUN([GPG4WIN_CHECK_DEPS],
 
 AC_DEFUN([GPG4WIN_FINALIZE],
 [
-  AC_REQUIRE([GPG4WIN_CHECK_DEPS])
+  AC_REQUIRE([GPG4WIN_CHECK_EXDEPS])
 
   _gpg4win_debug=no
   AC_ARG_ENABLE([debug],
@@ -296,6 +330,27 @@ AC_DEFUN([GPG4WIN_SPKG],
 ])
 
 
+# GPG4WIN_SPKGEX([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
+# Set up the source package PKG to be additionally built
+# for the host provided as additional-gpgex-host
+AC_DEFUN([GPG4WIN_SPKGEX],
+[
+  GPG4WIN_SPKG([$1],[$2],[$3],[$4])
+
+  # gpg4win_pkg_PKGNAME_deps=DEPS
+  gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_ex_deps="$2"
+  AC_SUBST(gpg4win_pkg_[]m4_translit([$1],[A-Z+-],[a-z__])[]_ex_deps)
+
+  gpg4win_ex_pkgs="$gpg4win_ex_pkgs $1"
+
+  GPG4WIN_DEFINE(HAVE_PKG_[]m4_translit([$1],[a-z+-],[A-Z__])_EX)
+  # Record dependencies.  Also enter every package as node.
+  _gpg4win_ex_deps="$_gpg4win_ex_deps $1 $1"
+  AS_IF([test ! -z "$2"],
+        for _gpg4win_i in $2; do
+          _gpg4win_ex_deps="$_gpg4win_ex_deps $_gpg4win_i $1"
+        done)
+])
 
 # GPG4WIN_BPKG_GNUWIN32([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
 # Set up the gnuwin32 package PKG.
index 6c60b56..6b89692 100644 (file)
@@ -28,6 +28,7 @@ idir := $(root)/install
 ipdir := $(root)/install/pkgs
 tsdir := $(shell pwd)/${top_srcdir}
 pdir := $(shell pwd)/${top_srcdir}/patches
+ex_idir := $(root)/install-ex
 
 # We collect the names of all pkg files used.
 pkg_files =
@@ -40,6 +41,7 @@ stamps/stamp-directories:
        $(MKDIR) $(bdir)
        $(MKDIR) $(idir)
        $(MKDIR) $(ipdir)
+       $(if $GPGEX_ADD_HOST, $(MKDIR) $(ex_idir))
        touch $(bdir)/versioninfo.txt
        touch stamps/stamp-directories
 
@@ -78,6 +80,27 @@ define SETVARS
        export CONFIG_SITE="$(tsdir)/src/config.site"
 endef
 
+# Set variables for building in an additional architecture
+define SETVARS_EX
+       pkg="$(call GETVAR,gpg4win_pkg_$(1))";                              \
+       pkg_version="$(1)-$(call GETVAR,gpg4win_pkg_$(1)_version)";         \
+       pkgsdir="$(bdir)/$$$${pkg_version}-ex";                             \
+       pkgbdir="$(bdir)/$$$${pkg_version}-ex-build";                       \
+       pkgpdir="$(pdir)/$$$${pkg_version}-ex";                             \
+       pkgpbdir="$(pdir)/$(1)-ex";                                         \
+       pkgidir="$(ipdir)/$$$${pkg_version}-ex";                            \
+       pkgidir_dev="$(ipdir)/$$$${pkg_version_dev}";                       \
+       pkgcfg="$(call GETVAR,gpg4win_pkg_$(1)_configure)";                 \
+       pkgextracflags="$(call GETVAR,gpg4win_pkg_$(1)_ex_extracflags)";    \
+       pkgmkargs="$(call GETVAR,gpg4win_pkg_$(1)_ex_make_args)";           \
+       pkgmkargs_inst="$(call GETVAR,gpg4win_pkg_$(1)_ex_make_args_inst)"; \
+       export PKG_CONFIG="$(tsdir)/src/pkg-config";                        \
+       export PKG_CONFIG_PATH="$(ex_idir)/lib/pkgconfig";                  \
+       export PKG_CONFIG_LIBDIR="";                                        \
+       export PATH="$(ex_idir)/bin:$${PATH}";                              \
+       export SYSROOT="$(ex_idir)"
+endef
+
 # Support macro.  Unpack the archive $(1).
 define DEFLATE_macro
        case "$(1)" in                  \
@@ -104,10 +127,108 @@ define STRIP_macro
        fi
 endef
 
+# Support macro.  Strip all exe files below $(1) using STRIP_EX.
+define STRIP_EX_macro
+       if test -z '$(DEBUG)'; then                     \
+         (cd $(1);                                     \
+          for f in `find . -name \*.exe -o -name \*.dll`; do           \
+          echo Calling $(STRIP_EX) "$$$${pkg_version}/$$$${f}"; \
+          $(STRIP_EX) "$$$${f}"; done);                        \
+       fi
+endef
+
 define GETDEPS
   $(addprefix stamps/stamp-final-, $(call GETVAR,gpg4win_pkg_$(1)_deps))
 endef
 
+define GETDEPS_EX
+  $(addprefix stamps/stamp-final-ex-, $(call GETVAR,gpg4win_pkg_$(1)_deps))
+endef
+
+# Template for source packages to build for an additional host
+
+define EXPKG_template_
+
+pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
+
+stamps/stamp-$(1)-ex-00-unpack: stamps/stamp-directories $(call GETDEPS_EX,$(1))
+       (cd $(bdir);                                    \
+        $(call SETVARS_EX,$(1));                               \
+        $(call DEFLATE_macro,$$$${pkg}))
+       touch stamps/stamp-$(1)-ex-00-unpack
+
+stamps/stamp-$(1)-ex-01-patch: stamps/stamp-$(1)-ex-00-unpack
+       (shopt -s nullglob;                             \
+        $(call SETVARS_EX,$(1));                               \
+        for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do  \
+          (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
+        done)
+       touch stamps/stamp-$(1)-ex-01-patch
+
+stamps/stamp-$(1)-ex-02-configure: stamps/stamp-$(1)-ex-01-patch
+       ($(call SETVARS_EX,$(1));                               \
+        mkdir "$$$${pkgbdir}";                         \
+         cd "$$$${pkgbdir}";                           \
+        eval "../$$$${pkg_version}/configure"          \
+               --prefix="$$$${pkgidir}"                \
+               --host=$(GPGEX_ADD_HOST)                \
+               --build=$(build)                        \
+               $$$${pkgcfg} CFLAGS=\"-mms-bitfields $$$${pkgextracflags}\";\
+        shopt -s nullglob;                                     \
+        for pfile in "$$$${pkgpbdir}"/*.postcfg                \
+                       "$$$${pkgpdir}"/*.postcfg ; do                  \
+          (cd "$$$${pkgsdir}"; "$$$${pfile}")                  \
+        done;                                                  \
+        for pfile in "$$$${pkgpbdir}"/*.postcfg-build          \
+                       "$$$${pkgpdir}"/*.postcfg-build ; do    \
+          (cd "$$$${pkgbdir}"; "$$$${pfile}")                  \
+        done)
+       touch stamps/stamp-$(1)-ex-02-configure
+
+stamps/stamp-$(1)-ex-03-make: stamps/stamp-$(1)-ex-02-configure
+       ($(call SETVARS_EX,$(1));                               \
+         cd "$$$${pkgbdir}";                           \
+         $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs} || \
+         $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs} || \
+         $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs})
+       touch stamps/stamp-$(1)-ex-03-make
+
+# Note that post_install must come last because it may be empty and
+# "; ;" is a syntax error.
+stamps/stamp-$(1)-ex-04-install: stamps/stamp-$(1)-ex-03-make
+       ($(call SETVARS_EX,$(1));                               \
+         cd "$$$${pkgbdir}";                           \
+         $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
+         $(call STRIP_EX_macro,"$$$${pkgidir}");               \
+         rm -f "$$$${pkgidir}/share/info/dir";         \
+         $(call gpg4win_pkg_$(call FROB_macro,$(1))_ex_post_install))
+       touch stamps/stamp-$(1)-ex-04-install
+
+stamps/stamp-$(1)-ex-05-stow: stamps/stamp-$(1)-ex-04-install
+       ($(call SETVARS_EX,$(1));                               \
+        cd $(ipdir);                                   \
+        $(STOW) "$$$${pkg_version}")
+       touch stamps/stamp-$(1)-ex-05-stow
+
+stamps/stamp-final-ex-$(1): stamps/stamp-$(1)-ex-05-stow
+       touch stamps/stamp-final-ex-$(1)
+
+.PHONY : clean-ex-$(1)
+clean-ex-$(1):
+       ($(call SETVARS_EX,$(1));                               \
+        (cd $(ipdir) &&                                \
+         ($(STOW) -D "$$$${pkg_version}";              \
+          rm -fR "$$$${pkg_version}"));                \
+        rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
+       rm -f stamps/stamp-final-ex-$(1) stamps/stamp-$(1)-ex-*
+
+endef
+
+define EXPKG_template
+$(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
+  $(call EXPKG_template_,$1))
+endef
+
 
 # Template for source packages.
 
@@ -352,6 +473,9 @@ endef
 # Insert the template for each source package.
 $(foreach spkg, $(gpg4win_spkgs), $(eval $(call SPKG_template,$(spkg))))
 
+# Insert the template for each gpgEx architecture package.
+$(foreach expkg, $(gpg4win_expkgs), $(eval $(call EXPKG_template,$(expkg))))
+
 # Insert the template for each make only source package.
 $(foreach mpkg, $(gpg4win_mpkgs), $(eval $(call MPKG_template,$(mpkg))))
 
@@ -368,7 +492,8 @@ $(foreach rll, $(gpg4win_howto_smime_ll), \
                $(eval $(call HOWTO_template,SMIME,$(rll))))
 
 stamps/stamp-final: stamps/stamp-directories
-stamps/stamp-final: $(addprefix stamps/stamp-final-,$(gpg4win_build_list))
+stamps/stamp-final: $(addprefix stamps/stamp-final-,$(gpg4win_build_list)) \
+       $(addprefix stamps/stamp-final-ex-,$(gpg4win_build_ex_list))
        touch stamps/stamp-final
 
 $(bdir)/versioninfo.txt: stamps/stamp-final