Update kleopatra
[gpg4win.git] / src / gpg4win.mk.in
index 3724da0..9e20bf9 100644 (file)
@@ -1,5 +1,5 @@
 # gpg4win.m4.in - Installer for GnuPG 4 Windows Makefile.   -*- makefile -*-
-# Copyright (C) 2005 g10 Code GmbH
+# Copyright (C) 2005, 2009 g10 Code GmbH
 # 
 # This file is part of GPG4Win.
 # 
@@ -29,6 +29,8 @@ ipdir := $(root)/install/pkgs
 tsdir := $(shell pwd)/${top_srcdir}
 pdir := $(shell pwd)/${top_srcdir}/patches
 
+# We collect the names of all pkg files used.
+pkg_files =
 
 # The playground area is our scratch area, where we unpack, build and
 # install the packages.
@@ -59,6 +61,7 @@ define SETVARS
        pkgsdir="$(bdir)/$$$${pkg_version}";                            \
        pkgbdir="$(bdir)/$$$${pkg_version}-build";                      \
        pkgpdir="$(pdir)/$$$${pkg_version}";                            \
+       pkgpbdir="$(pdir)/$(1)";                                        \
        pkgidir="$(ipdir)/$$$${pkg_version}";                           \
        pkg_dev="$(call GETVAR,gpg4win_pkg_$(1)_dev)";                  \
        pkg_version_dev="$(1)-dev-$(call GETVAR,gpg4win_pkg_$(1)_version)"; \
@@ -68,15 +71,12 @@ define SETVARS
        pkgmkargs_inst="$(call GETVAR,gpg4win_pkg_$(1)_make_args_inst)";\
        export PKG_CONFIG="$(tsdir)/src/pkg-config";                    \
        export PKG_CONFIG_PATH="$(idir)/lib/pkgconfig";                 \
+       export PKG_CONFIG_LIBDIR="";                                    \
+       export PATH="$(idir)/bin:$${PATH}";                             \
        export SYSROOT="$(idir)";                                       \
        export CONFIG_SITE="$(tsdir)/src/config.site"
 endef
 
-# Support macro.  Record version number of file $(1).
-define VERSIONINFO_macro
-         $(SHA1SUM) "$(1)" >> "$(bdir)/versioninfo.txt" 
-endef
-
 # Support macro.  Unpack the archive $(1).
 define DEFLATE_macro
        case "$(1)" in                  \
@@ -101,22 +101,27 @@ define STRIP_macro
        fi
 endef
 
+define GETDEPS
+  $(addprefix stamps/stamp-final-, $(call GETVAR,gpg4win_pkg_$(1)_deps))
+endef
+
 
 # Template for source packages.
 
-define SPKG_template
+define SPKG_template_
 
-stamps/stamp-$(1)-00-unpack: stamps/stamp-directories 
+pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
+
+stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
        (cd $(bdir);                                    \
         $(call SETVARS,$(1));                          \
-        $(call VERSIONINFO_macro,$$$${pkg});           \
         $(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      \
+        for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do  \
           (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
         done)
        touch stamps/stamp-$(1)-01-patch
@@ -125,7 +130,7 @@ stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
        ($(call SETVARS,$(1));                          \
         mkdir "$$$${pkgbdir}";                         \
          cd "$$$${pkgbdir}";                           \
-        "$$$${pkgsdir}/configure"                      \
+        eval "../$$$${pkg_version}/configure"          \
                --prefix="$$$${pkgidir}"                \
                --host=$(host_cpu)-$(host_os)           \
                --build=$(build_cpu)-$(build_os)        \
@@ -135,6 +140,8 @@ stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-02-configure
        ($(call SETVARS,$(1));                          \
          cd "$$$${pkgbdir}";                           \
+         $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs} || \
+         $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs} || \
          $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs})
        touch stamps/stamp-$(1)-03-make
 
@@ -144,7 +151,8 @@ stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
        ($(call SETVARS,$(1));                          \
          cd "$$$${pkgbdir}";                           \
          $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
-         $(call STRIP_macro,"$$$${pkgidir}"); \
+         $(call STRIP_macro,"$$$${pkgidir}");          \
+         rm -f "$$$${pkgidir}/share/info/dir";         \
          $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
        touch stamps/stamp-$(1)-04-install
 
@@ -156,25 +164,41 @@ stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
 
 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
        touch stamps/stamp-final-$(1)
+
+.PHONY : clean-$(1)
+clean-$(1):
+       ($(call SETVARS,$(1));                          \
+        (cd $(ipdir) &&                                \
+         ($(STOW) -D "$$$${pkg_version}";              \
+          rm -fR "$$$${pkg_version}"));                \
+        rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
+       rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
+
+endef
+
+define SPKG_template
+$(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
+  $(call SPKG_template_,$1))
 endef
 
 
 # Template for source packages using only make and no build
 # directory.
 
-define MPKG_template
+define MPKG_template_
 
-stamps/stamp-$(1)-00-unpack: stamps/stamp-directories 
+pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
+
+stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
        (cd $(bdir);                                    \
         $(call SETVARS,$(1));                          \
-        $(call VERSIONINFO_macro,$$$${pkg});           \
         $(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      \
+        for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do \
           (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
         done)
        touch stamps/stamp-$(1)-01-patch
@@ -200,19 +224,36 @@ stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
 
 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
        touch stamps/stamp-final-$(1)
+
+.PHONY : clean-$(1)
+clean-$(1):
+       ($(call SETVARS,$(1));                          \
+        (cd $(ipdir) &&                                \
+         ($(STOW) -D "$$$${pkg_version}";              \
+          rm -fR "$$$${pkg_version}"));                \
+        rm -fR "$$$${pkgsdir}"
+       rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
+
+endef
+
+define MPKG_template
+$(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
+  $(call MPKG_template_,$1))
 endef
 
 
 
 # Template for binary packages.
 
-define BPKG_template
+define BPKG_template_
+
+pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
+pkg_files += $(call GETVAR,gpg4win_pkg_$(1)_dev)
 
-stamps/stamp-$(1)-00-install: stamps/stamp-directories 
+stamps/stamp-$(1)-00-install: stamps/stamp-directories $(call GETDEPS,$(1))
        ($(call SETVARS,$(1));                          \
         $(MKDIR) "$$$${pkgidir}";                      \
         cd $$$${pkgidir};                              \
-        $(call VERSIONINFO_macro,$$$${pkg});           \
         $(call DEFLATE_macro,$$$${pkg}))
        touch stamps/stamp-$(1)-00-install
 
@@ -222,7 +263,6 @@ stamps/stamp-$(1)-01-install-dev: stamps/stamp-$(1)-00-install
        ($(call SETVARS,$(1));                          \
         $(MKDIR) "$$$${pkgidir_dev}";                  \
         (cd $$$${pkgidir_dev};                         \
-          $(call VERSIONINFO_macro,$$$${pkg_dev});      \
          $(call DEFLATE_macro,$$$${pkg_dev}));         \
         $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
        touch stamps/stamp-$(1)-01-install-dev
@@ -241,17 +281,48 @@ stamps/stamp-$(1)-03-stow-dev: stamps/stamp-$(1)-02-stow
 
 stamps/stamp-final-$(1): stamps/stamp-$(1)-03-stow-dev
        touch stamps/stamp-final-$(1)
+
+.PHONY : clean-$(1)
+clean-$(1):
+       ($(call SETVARS,$(1));                          \
+        cd $(ipdir) &&                                 \
+        ($(STOW) -D "$$$${pkg_version}";               \
+         $(STOW) -D "$$$${pkg_version_dev}";           \
+         rm -fR "$$$${pkg_version}" "$$$${pkg_version_dev}"))
+       rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
+
 endef
 
+define BPKG_template
+$(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
+  $(call BPKG_template_,$1))
+endef
 
-# Template for source packages.
+
+# Template for internal packages.
 
 define IPKG_template
 
-stamps/stamp-final-$(1): stamps/stamp-directories 
+stamps/stamp-final-$(1): stamps/stamp-directories $(call GETDEPS,$(1))
        touch stamps/stamp-final-$(1)
 endef
 
+# Template for README files
+
+define README_template
+README.$(1).txt : versioninfo.txt NEWS.tmp $(top_srcdir)/doc/README.$(1).txt \
+                  $(top_srcdir)/doc/beta-warning.txt
+       sed -e '/^;.*/d;/!VERSIONINFO!/{r versioninfo.txt' -e 'd;}' \
+       -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
+       -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
+        -e '/!PKG-COPYRIGHT!/{r $(top_srcdir)/doc/pkg-copyright.txt' -e 'd;}' \
+        -e 's,!VERSION!,$(VERSION),g' \
+          < $(top_srcdir)/doc/README.$(1).txt \
+          | (if echo "$(VERSION)" | egrep 'svn|rc|beta' >/dev/null; then \
+              sed -e '/!BETA-WARNING!/{r $(top_srcdir)/doc/beta-warning.txt' \
+               -e 'd;}'; else sed -e 's,!BETA-WARNING!,,g'; fi) \
+           | awk '{printf "%s\r\n", $$$$0}' >README.$(1).txt
+endef
 
 # Insert the template for each source package.
 $(foreach spkg, $(gpg4win_spkgs), $(eval $(call SPKG_template,$(spkg))))
@@ -265,10 +336,17 @@ $(foreach bpkg, $(gpg4win_bpkgs), $(eval $(call BPKG_template,$(bpkg))))
 # Insert the template for each internal package.
 $(foreach ipkg, $(gpg4win_ipkgs), $(eval $(call IPKG_template,$(ipkg))))
 
+# Insert the template for each README file.
+$(foreach rll, $(gpg4win_readme_ll), $(eval $(call README_template,$(rll))))
+
 stamps/stamp-final: stamps/stamp-directories
 stamps/stamp-final: $(addprefix stamps/stamp-final-,$(gpg4win_build_list))
        touch stamps/stamp-final
 
+$(bdir)/versioninfo.txt: stamps/stamp-final
+       touch $(bdir)/versioninfo.txt
+
+
 all-gpg4win: stamps/stamp-final
 
 # Just to check if we catched all stamps.