2005-10-18 Marcus Brinkmann <marcus@g10code.de>
authorMarcus Brinkmann <mb@g10code.com>
Tue, 18 Oct 2005 05:48:22 +0000 (05:48 +0000)
committerMarcus Brinkmann <mb@g10code.com>
Tue, 18 Oct 2005 05:48:22 +0000 (05:48 +0000)
* src/Makefile.am: First real implementation.
* src/gpg4win.mk.in: New file.
* configure.ac: Activate libiconv and gettext.
(AC_CONFIG_FILES): Add packages/Makefile and src/gpg4win.mk.
* m4/gpg4win.m4 (GPG4WIN_BPKG_GNU): New macro.
* include/config.sh.in: Add variables for libiconv and gettext.

ChangeLog
configure.ac
include/config.sh.in
m4/gpg4win.m4
src/Makefile.am
src/gpg4win.mk.in [new file with mode: 0644]

index 7a9b12a..eafc834 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-10-18  Marcus Brinkmann  <marcus@g10code.de>
+
+       * src/Makefile.am: First real implementation.
+       * src/gpg4win.mk.in: New file.
+       * configure.ac: Activate libiconv and gettext.
+       (AC_CONFIG_FILES): Add packages/Makefile and src/gpg4win.mk.
+       * m4/gpg4win.m4 (GPG4WIN_BPKG_GNU): New macro.
+       * include/config.sh.in: Add variables for libiconv and gettext.
+
 2005-10-15  Marcus Brinkmann  <marcus@g10code.de>
 
        * m4/gpg4win.m4: New file.
index e1fef2e..d449aae 100644 (file)
@@ -56,8 +56,8 @@ AC_CHECK_PROGS(WGET, wget)
 
 # Packages.
 
-#GPG4WIN_BPKG_GNU([libiconv])
-#GPG4WIN_BPKG_GNU([gettext], [libiconv])
+GPG4WIN_BPKG_GNU([libiconv])
+GPG4WIN_BPKG_GNU([gettext], [libiconv])
 
 GPG4WIN_BPKG_GNUWIN32([zlib])
 GPG4WIN_BPKG_GNUWIN32([libpng], [pkgconfig])
@@ -80,6 +80,6 @@ GPG4WIN_FINALIZE
 
 # Finalize.
 
-AC_CONFIG_FILES(Makefile src/Makefile include/Makefile)
-AC_CONFIG_FILES(include/config.sh)
-AC_OUTPUT
\ No newline at end of file
+AC_CONFIG_FILES(Makefile packages/Makefile include/Makefile src/Makefile)
+AC_CONFIG_FILES(include/config.sh src/gpg4win.mk)
+AC_OUTPUT
index c1cd450..430e391 100755 (executable)
@@ -74,3 +74,11 @@ gpg4win_pkg_gtk_=@gpg4win_pkg_gtk_@
 gpg4win_pkg_gtk__version=@gpg4win_pkg_gtk__version@
 gpg4win_pkg_gtk__dev=@gpg4win_pkg_gtk__dev@
 gpg4win_pkg_gtk__src=@gpg4win_pkg_gtk__src@
+
+gpg4win_pkg_libiconv=@gpg4win_pkg_libiconv@
+gpg4win_pkg_libiconv_version=@gpg4win_pkg_libiconv_version@
+gpg4win_pkg_libiconv_src=@gpg4win_pkg_libiconv_src@
+
+gpg4win_pkg_gettext=@gpg4win_pkg_gettext@
+gpg4win_pkg_gettext_version=@gpg4win_pkg_gettext_version@
+gpg4win_pkg_gettext_src=@gpg4win_pkg_gettext_src@
index e443ae2..27e7e02 100644 (file)
@@ -227,7 +227,7 @@ AC_DEFUN([GPG4WIN_SPKG],
 
 
 # GPG4WIN_BPKG_GNUWIN32([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
-# Set up the source package PKG.
+# Set up the gnuwin32 package PKG.
 # It is provided in gpg4win_val.
 AC_DEFUN([GPG4WIN_BPKG_GNUWIN32],
 [
@@ -286,7 +286,7 @@ AC_DEFUN([GPG4WIN_BPKG_GNUWIN32],
 
 
 # GPG4WIN_BPKG_GTK([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
-# Set up the source package PKG.
+# Set up the Gtk binary package PKG.
 # It is provided in gpg4win_val.
 AC_DEFUN([GPG4WIN_BPKG_GTK],
 [
@@ -336,7 +336,7 @@ AC_DEFUN([GPG4WIN_BPKG_GTK],
 
 
 # GPG4WIN_BPKG_GTK_DEV([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
-# Set up the source package PKG.
+# Set up the Gtk library package PKG.
 # It is provided in gpg4win_val.
 AC_DEFUN([GPG4WIN_BPKG_GTK_DEV],
 [
@@ -389,3 +389,64 @@ AC_DEFUN([GPG4WIN_BPKG_GTK_DEV],
           [$3],
           [$4])
 ])
+
+
+# GPG4WIN_BPKG_GNU([PKG],[DEPENDS],[IF-FOUND],[IF-NOT-FOUND])
+# Set up the source package PKG.
+# It is provided in gpg4win_val.
+AC_DEFUN([GPG4WIN_BPKG_GNU],
+[
+  AC_REQUIRE([GPG4WIN_INIT])
+  _gpg4win_pkg=maybe
+  AC_ARG_ENABLE([pkg-$1],
+    AS_HELP_STRING([--enable-pkg-$1[=DIR]],
+                   [include package $1]),
+    _gpg4win_pkg=$enableval)
+  _gpg4win_bpkg=no
+  _gpg4win_version=
+
+  AS_IF([test x$_gpg4win_pkg != xno],
+        [
+          # For some shameful reason, the gettext package is actually called
+          # gettext-runtime!
+          AS_IF([test $1 = gettext],
+               [GPG4WIN_FIND($1-runtime,,zip, $_gpg4win_pkg,
+                            _gpg4win_bpkg=$gpg4win_val
+                            _gpg4win_version=$gpg4win_version)],
+               [GPG4WIN_FIND($1,,zip, $_gpg4win_pkg,
+                            _gpg4win_bpkg=$gpg4win_val
+                            _gpg4win_version=$gpg4win_version)])
+       ])
+
+  # 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_PKGNAME_version=VERSION
+  gpg4win_pkg_[]m4_bpatsubst([$1],[[-+]],_)[]_version=$_gpg4win_version
+  AC_SUBST(gpg4win_pkg_[]m4_bpatsubst([$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)
+
+    # FIXME: Add a version consistency check here.  All two packages
+    # must match!
+
+    _gpg4win_pkgs="$_gpg4win_pkgs $1"
+    # Record dependencies.  Also enter every package as node.
+    _gpg4win_deps="$_gpg4win_deps $1 $1"
+    AS_IF([test ! -z "$2"],
+          for _gpg4win_i in $2; do
+           _gpg4win_deps="$_gpg4win_deps $_gpg4win_i $1"
+          done)
+          [$3],
+          [$4])
+])
+
+
index cbf3a51..0ceb955 100644 (file)
@@ -1 +1,84 @@
 EXTRA_DIST = gpg4win.sh pkg-config
+
+# Supported source packages.
+gpg4win_spkgs := gnupg libgpg-error gpgme gpgol gpa
+
+# Extra options to configure for individual packages.
+# We can use $(idir) here for the installation prefix.
+gpg4win_pkg_gpgme_configure = \
+  --with-gpg-error-prefix=$(idir) --without-gpgsm
+
+gpg4win_pkg_gpa_configure = \
+  --with-libiconv-prefix=$(idir) --with-libintl-prefix=$(idir) \
+  --with-gpgme-prefix=$(idir) --with-zlib=$(idir)
+
+gpg4win_pkg_gpgol_configure = \
+  --with-gpgme-prefix=$(idir)
+
+
+# Supported binary packages.
+gpg4win_bpkgs :=  libiconv gettext pkgconfig zlib glib libpng pango atk gtk+
+
+# Zlib needs some special magic to generate a libtool file.
+define gpg4win_pkg_zlib_post_install
+(cd $$$${pkgidir_dev};                                 \
+echo "dlname='../bin/zlib1.dll'" > lib/libz.la;        \
+echo "library_names='libz.dll.a'" >> lib/libz.la;      \
+echo "old_library='libz.a'" >> lib/libz.la;            \
+echo "dependency_libs=''" >> lib/libz.la;              \
+echo "current=1" >> lib/libz.la;                       \
+echo "age=2" >> lib/libz.la;                           \
+echo "revision=3" >> lib/libz.la;                      \
+echo "installed=yes" >> lib/libz.la;                   \
+echo "shouldnotlink=no" >> lib/libz.la;                        \
+echo "dlopen=''" >> lib/libz.la;                       \
+echo "dlpreopen=''" >> lib/libz.la;                    \
+echo "libdir=\"$$$${pkgidir}/lib\"" >> lib/libz.la;)
+endef
+
+
+# We need to fix the prefix in the various packages using pkgconfig,
+# or we can't substitute it properly in our pkg-config wrapper.
+define gpg4win_pkg_glib_post_install
+ (cd $$$${pkgidir_dev};                                                        \
+ perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
+endef
+
+define gpg4win_pkg_atk_post_install
+ (cd $$$${pkgidir_dev};                                                        \
+ perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
+endef
+
+define gpg4win_pkg_pango_post_install
+ (cd $$$${pkgidir_dev};                                                        \
+ perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
+endef
+
+define gpg4win_pkg_gtk__post_install
+ (cd $$$${pkgidir_dev};                                                        \
+ perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
+endef
+
+# In libpng, the pkg-config files are surprisingly found in the
+# runtime package.
+define gpg4win_pkg_libpng_post_install
+ (cd $$$${pkgidir};                                                    \
+ perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
+endef
+
+
+# Now do the bunch of the work.  This is a bunch of dirty magic to
+# integrate our special makefile into automake, while not actually
+# including it (make should include it).  This is in turn necessary
+# because automake can't deal with the elegant magic in the actual
+# Makefile.
+
+define INCLUDE_BY_MAKE
+include $(1)
+endef
+
+$(eval $(call INCLUDE_BY_MAKE,gpg4win.mk))
+
+all-local: all-gpg4win
+
+clean-local: clean-gpg4win
diff --git a/src/gpg4win.mk.in b/src/gpg4win.mk.in
new file mode 100644 (file)
index 0000000..f3dc9a0
--- /dev/null
@@ -0,0 +1,169 @@
+# No servicable parts below this line :)
+
+
+# These paths must be absolute, as we switch directories pretty often.
+root := $(shell pwd)/playground
+bdir := $(root)/build
+idir := $(root)/install
+ipdir := $(root)/install/pkgs
+pdir := $(shell pwd)/${top_srcdir}/patches
+
+
+# The playground area is our scratch area, where we unpack, build and
+# install the packages.
+stamps/stamp-directories:
+       $(MKDIR) stamps
+       $(MKDIR) playground
+       $(MKDIR) $(bdir)
+       $(MKDIR) $(idir)
+       $(MKDIR) $(ipdir)
+       touch stamps/stamp-directories
+
+
+# Frob the name $1 by converting all '-' and '+' characters to '_'.
+define FROB_macro
+$(subst +,_,$(subst -,_,$(1)))
+endef
+
+# Get the variable $(1) (which may contain '-' and '+' characters).
+define GETVAR
+$$($(call FROB_macro,$(1)))
+endef
+
+# Set a couple of common variables.
+define SETVARS
+       pkg="$(call GETVAR,gpg4win_pkg_$(1))";                          \
+       pkg_version="$(1)-$(call GETVAR,gpg4win_pkg_$(1)_version)";     \
+       pkgsdir="$(bdir)/$$$${pkg_version}";                            \
+       pkgbdir="$(bdir)/$$$${pkg_version}-build";                      \
+       pkgpdir="$(pdir)/$$$${pkg_version}";                            \
+       pkgidir="$(ipdir)/$$$${pkg_version}";                           \
+       pkg_dev="$(call GETVAR,gpg4win_pkg_$(1)_dev)";                  \
+       pkg_version_dev="$(1)-dev-$(call GETVAR,gpg4win_pkg_$(1)_version)"; \
+       pkgidir_dev="$(ipdir)/$$$${pkg_version_dev}";                   \
+       pkgcfg="$(call GETVAR,gpg4win_pkg_$(1)_configure)";             \
+       export PKG_CONFIG="$(shell pwd)/$(top_srcdir)/src/pkg-config";  \
+       export PKG_CONFIG_PATH="${idir}/lib/pkgconfig";                 \
+       export SYSROOT="${idir}"
+endef
+
+# Support macro.  Unpack the archive $(1).
+define DEFLATE_macro
+       case "$(1)" in                  \
+         *.tar.gz | *.tgz)             \
+           $(TAR) xzf "$(1)" ;;        \
+         *.tar.bz2 | *.tbz2 | *.tbz)   \
+           $(TAR) xjf "$(1)" ;;        \
+         *.zip)                        \
+           $(UNZIP) "$(1)" ;;  \
+       esac
+endef
+
+
+# Template for source packages.
+
+define SPKG_template
+
+stamps/stamp-$(1)-00-unpack: stamps/stamp-directories 
+       (cd $(bdir);                                    \
+        $(call SETVARS,$(1));                          \
+        $(call DEFLATE_macro,$$$${pkg}))
+       touch stamps/stamp-$(1)-00-unpack
+
+stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
+       (shopt -s nullglob;                             \
+        $(call SETVARS,$(1));                          \
+        for pfile in "$$$${pkgpdir}"/*.patch ; do      \
+          (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
+        done)
+       touch stamps/stamp-$(1)-01-patch
+
+stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
+       ($(call SETVARS,$(1));                          \
+        mkdir "$$$${pkgbdir}";                         \
+         cd "$$$${pkgbdir}";                           \
+        "$$$${pkgsdir}/configure"                      \
+               --prefix="$$$${pkgidir}"                \
+               --host=$(host_cpu)-$(host_os)           \
+               --build=$(build_cpu)-$(build_os) $$$${pkgcfg})
+       touch stamps/stamp-$(1)-02-configure
+
+stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-02-configure
+       ($(call SETVARS,$(1));                          \
+         cd "$$$${pkgbdir}";                           \
+         $(MAKE) $(AM_MAKEFLAGS))
+       touch stamps/stamp-$(1)-03-make
+
+stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
+       ($(call SETVARS,$(1));                          \
+         cd "$$$${pkgbdir}";                           \
+         $(MAKE) $(AM_MAKEFLAGS) install)
+       touch stamps/stamp-$(1)-04-install
+
+stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
+       ($(call SETVARS,$(1));                          \
+        cd $(ipdir);                                   \
+        $(STOW) "$$$${pkg_version}")
+       touch stamps/stamp-$(1)-05-stow
+
+stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
+       touch stamps/stamp-final-$(1)
+endef
+
+
+# Template for binary packages.
+
+define BPKG_template
+
+stamps/stamp-$(1)-00-install: stamps/stamp-directories 
+       ($(call SETVARS,$(1));                          \
+        $(MKDIR) "$$$${pkgidir}";                      \
+        cd $$$${pkgidir};                              \
+        $(call DEFLATE_macro,$$$${pkg}))
+       touch stamps/stamp-$(1)-00-install
+
+stamps/stamp-$(1)-01-install-dev: stamps/stamp-$(1)-00-install
+       ($(call SETVARS,$(1));                          \
+        $(MKDIR) "$$$${pkgidir_dev}";                  \
+        cd $$$${pkgidir_dev};                          \
+        $(call DEFLATE_macro,$$$${pkg_dev});           \
+        $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
+       touch stamps/stamp-$(1)-01-install-dev
+
+stamps/stamp-$(1)-02-stow: stamps/stamp-$(1)-01-install-dev
+       ($(call SETVARS,$(1));                          \
+        cd $(ipdir);                                   \
+        $(STOW) "$$$${pkg_version}")
+       touch stamps/stamp-$(1)-02-stow
+
+stamps/stamp-$(1)-03-stow-dev: stamps/stamp-$(1)-02-stow
+       ($(call SETVARS,$(1));                          \
+        cd $(ipdir);                                   \
+        $(STOW) "$$$${pkg_version_dev}")
+       touch stamps/stamp-$(1)-03-stow-dev
+
+stamps/stamp-final-$(1): stamps/stamp-$(1)-03-stow-dev
+       touch stamps/stamp-final-$(1)
+endef
+
+
+# Insert the template for each source package.
+$(foreach spkg, $(gpg4win_spkgs), $(eval $(call SPKG_template,$(spkg))))
+
+# Insert the template for each binary package.
+$(foreach bpkg, $(gpg4win_bpkgs), $(eval $(call BPKG_template,$(bpkg))))
+
+
+.PHONY : final
+
+final: $(addprefix stamps/stamp-final-,$(gpg4win_build_list))
+
+all-gpg4win: final
+
+
+# Just to check if we catched all stamps.
+clean-stamps:
+       $(RM) -fR $(stamps)
+
+clean-gpg4win:
+       $(RM) -fR playground stamps
\ No newline at end of file