speedo: Add make option SELFCHECK=0 to build a new release.
[gnupg.git] / build-aux / speedo.mk
index a9ba6d4..0dd5e2e 100644 (file)
@@ -58,8 +58,11 @@ help:
        @echo '  w32-installer  Build a Windows installer'
        @echo '  w32-source     Pack a source archive'
        @echo
-       @echo 'Prepend TARGET with "git-" to build from GIT repos'
-       @echo 'Prepend TARGET with "this-" to build from the source tarball'
+       @echo 'You may append INSTALL_PREFIX=<dir> for native builds.'
+       @echo 'Prepend TARGET with "git-" to build from GIT repos.'
+       @echo 'Prepend TARGET with "this-" to build from the source tarball.'
+       @echo 'Use SELFCHECK=0 for a non-released version.'
+       @echo 'Use CUSTOM_SWDB=1 for an already downloaded swdb.lst.'
 
 SPEEDOMAKE := $(MAKE) -f $(SPEEDO_MK) UPD_SWDB=1
 
@@ -82,22 +85,22 @@ this-native-gui: check-tools
        $(SPEEDOMAKE) TARGETOS=native WHAT=this    WITH_GUI=1 all
 
 w32-installer: check-tools
-       $(SPEEDOMAKE) TARGETOS=w32    WHAT=release WITH_GUI=1 installer
+       $(SPEEDOMAKE) TARGETOS=w32    WHAT=release WITH_GUI=0 installer
 
 git-w32-installer: check-tools
-       $(SPEEDOMAKE) TARGETOS=w32    WHAT=git     WITH_GUI=1 installer
+       $(SPEEDOMAKE) TARGETOS=w32    WHAT=git     WITH_GUI=0 installer
 
 this-w32-installer: check-tools
-       $(SPEEDOMAKE) TARGETOS=w32    WHAT=this    WITH_GUI=1 installer
+       $(SPEEDOMAKE) TARGETOS=w32    WHAT=this    WITH_GUI=0 installer
 
 w32-source: check-tools
-       $(SPEEDOMAKE) TARGETOS=w32    WHAT=release WITH_GUI=1 dist-source
+       $(SPEEDOMAKE) TARGETOS=w32    WHAT=release WITH_GUI=0 dist-source
 
 git-w32-source: check-tools
-       $(SPEEDOMAKE) TARGETOS=w32    WHAT=git     WITH_GUI=1 dist-source
+       $(SPEEDOMAKE) TARGETOS=w32    WHAT=git     WITH_GUI=0 dist-source
 
 this-w32-source: check-tools
-       $(SPEEDOMAKE) TARGETOS=w32    WHAT=git     WITH_GUI=1 dist-source
+       $(SPEEDOMAKE) TARGETOS=w32    WHAT=git     WITH_GUI=0 dist-source
 
 
 # Set this to "git" to build from git,
@@ -106,14 +109,20 @@ this-w32-source: check-tools
 WHAT=git
 
 # Set target to "native" or "w32"
-TARGETOS=w32
+TARGETOS=
 
 # Set to 1 to build the GUI tools
 WITH_GUI=0
 
+# Set to 1 to use a pre-installed swdb.lst instead of the online version.
+CUSTOM_SWDB=0
+
 # Set to 1 to really download the swdb.
 UPD_SWDB=0
 
+# Set to 0 to skip the GnuPG version self-check
+SELFCHECK=1
+
 # Set to the location of the directory with tarballs of
 # external packages.
 TARBALLS=$(shell pwd)/../tarballs
@@ -124,6 +133,9 @@ MAKE_J=3
 # Name to use for the w32 installer and sources
 INST_NAME=gnupg-w32
 
+# Use this to override the installaion directory for native builds.
+INSTALL_PREFIX=none
+
 
 # Directory names.
 # They must be absolute, as we switch directories pretty often.
@@ -131,7 +143,11 @@ root := $(shell pwd)/PLAY
 sdir := $(root)/src
 bdir := $(root)/build
 bdir6:= $(root)/build-w64
+ifeq ($(INSTALL_PREFIX),none)
 idir := $(root)/inst
+else
+idir := $(abspath $(INSTALL_PREFIX))
+endif
 idir6:= $(root)/inst-w64
 stampdir := $(root)/stamps
 topsrc := $(shell cd $(dir $(SPEEDO_MK)).. && pwd)
@@ -148,43 +164,59 @@ speedo_spkgs  = \
 
 ifeq ($(TARGETOS),w32)
 speedo_spkgs += \
-       zlib bzip2 libiconv gettext
+       zlib bzip2 adns libiconv
+ifeq ($(WITH_GUI),1)
+speedo_spkgs += gettext
+endif
 endif
 
 speedo_spkgs += \
        libassuan libksba gnupg
 
 ifeq ($(TARGETOS),w32)
+ifeq ($(WITH_GUI),1)
 speedo_spkgs += \
        libffi glib pkg-config
 endif
+endif
 
 speedo_spkgs += \
        gpgme
 
 ifeq ($(TARGETOS),w32)
+ifeq ($(WITH_GUI),1)
 speedo_spkgs += \
        libpng \
        gdk-pixbuf atk pixman cairo pango gtk+
 endif
+endif
 
+ifeq ($(TARGETOS),w32)
 
+speedo_spkgs += pinentry
 ifeq ($(WITH_GUI),1)
-speedo_spkgs += \
-       pinentry gpa
+speedo_spkgs += gpa gpgex
+endif
+
+else
+
+ifeq ($(WITH_GUI),1)
+speedo_spkgs += pinentry gpa
 endif
 
-ifeq ($(TARGETOS),w32)
-speedo_spkgs += \
-       gpgex
 endif
 
+
 # =====END LIST OF PACKAGES=====
 
 
-# Packages which are additionally build for 64 bit Windows
-speedo_w64_spkgs  = \
-       libgpg-error libiconv gettext libassuan gpgex
+# Packages which are additionally build for 64 bit Windows.  They are
+# only used for gpgex and thus we need to build them only if we want
+# a full installer.
+speedo_w64_spkgs  =
+ifeq ($(WITH_GUI),1)
+speedo_w64_spkgs += libgpg-error libiconv gettext libassuan gpgex
+endif
 
 # Packages which use the gnupg autogen.sh build style
 speedo_gnupg_style = \
@@ -197,14 +229,26 @@ speedo_make_only_style = \
        zlib bzip2
 
 # Get the content of the software DB.
+ifeq ($(CUSTOM_SWDB),1)
+getswdb_options = --skip-download --skip-verify
+else
+getswdb_options =
+endif
+ifeq ($(SELFCHECK),0)
+getswdb_options += --skip-selfcheck
+endif
 ifeq ($(UPD_SWDB),1)
-SWDB := $(shell $(topsrc)/build-aux/getswdb.sh && echo okay)
+SWDB := $(shell $(topsrc)/build-aux/getswdb.sh $(getswdb_options) && echo okay)
 ifeq ($(strip $(SWDB)),)
+ifneq ($(WHAT),git)
 $(error Error getting GnuPG software version database)
 endif
+endif
 
 # Version numbers of the released packages
-gnupg_ver = $(shell cat $(topsrc)/VERSION)
+gnupg_ver_this = $(shell cat $(topsrc)/VERSION)
+
+gnupg_ver        := $(shell awk '$$1=="gnupg21_ver" {print $$2}' swdb.lst)
 
 libgpg_error_ver := $(shell awk '$$1=="libgpg_error_ver" {print $$2}' swdb.lst)
 libgpg_error_sha1:= $(shell awk '$$1=="libgpg_error_sha1" {print $$2}' swdb.lst)
@@ -239,14 +283,18 @@ zlib_sha1 := $(shell awk '$$1=="zlib_sha1_gz" {print $$2}' swdb.lst)
 bzip2_ver  := $(shell awk '$$1=="bzip2_ver" {print $$2}' swdb.lst)
 bzip2_sha1 := $(shell awk '$$1=="bzip2_sha1_gz" {print $$2}' swdb.lst)
 
+adns_ver  := $(shell awk '$$1=="adns_ver" {print $$2}' swdb.lst)
+adns_sha1 := $(shell awk '$$1=="adns_sha1" {print $$2}' swdb.lst)
+
 $(info Information from the version database)
-$(info GnuPG ..........: $(gnupg_ver))
+$(info GnuPG ..........: $(gnupg_ver) (building $(gnupg_ver_this)))
 $(info Libgpg-error ...: $(libgpg_error_ver))
 $(info Npth ...........: $(npth_ver))
 $(info Libgcrypt ......: $(libgcrypt_ver))
 $(info Libassuan ......: $(libassuan_ver))
 $(info Zlib ...........: $(zlib_ver))
 $(info Bzip2 ..........: $(bzip2_ver))
+$(info ADNS ...........: $(adns_ver))
 $(info GPGME ..........: $(gpgme_ver))
 $(info Pinentry .......: $(pinentry_ver))
 $(info GPA ............: $(gpa_ver))
@@ -255,7 +303,6 @@ endif
 
 # Version number for external packages
 pkg_config_ver = 0.23
-zlib_ver = 1.2.8
 libiconv_ver = 1.14
 gettext_ver = 0.18.2.1
 libffi_ver = 3.0.13
@@ -268,7 +315,6 @@ pixman_ver = 0.32.4
 cairo_ver = 1.12.16
 gtk__ver = 2.24.17
 
-
 # The GIT repository.  Using a local repo is much faster.
 #gitrep = git://git.gnupg.org
 gitrep = ${HOME}/s
@@ -309,7 +355,7 @@ else ifeq ($(WHAT),git)
   speedo_pkg_libassuan_git = $(gitrep)/libassuan
   speedo_pkg_libassuan_gitref = master
   speedo_pkg_libgcrypt_git = $(gitrep)/libgcrypt
-  speedo_pkg_libgcrypt_gitref = LIBGCRYPT-1-6-BRANCH
+  speedo_pkg_libgcrypt_gitref = master
   speedo_pkg_libksba_git = $(gitrep)/libksba
   speedo_pkg_libksba_gitref = master
   speedo_pkg_gpgme_git = $(gitrep)/gpgme
@@ -346,6 +392,7 @@ endif
 speedo_pkg_pkg_config_tar = $(pkg2rep)/pkg-config-$(pkg_config_ver).tar.gz
 speedo_pkg_zlib_tar       = $(pkgrep)/zlib/zlib-$(zlib_ver).tar.gz
 speedo_pkg_bzip2_tar      = $(pkgrep)/bzip2/bzip2-$(bzip2_ver).tar.gz
+speedo_pkg_adns_tar       = $(pkg10rep)/adns/adns-$(adns_ver).tar.bz2
 speedo_pkg_libiconv_tar   = $(pkg2rep)/libiconv-$(libiconv_ver).tar.gz
 speedo_pkg_gettext_tar    = $(pkg2rep)/gettext-$(gettext_ver).tar.gz
 speedo_pkg_libffi_tar     = $(pkg2rep)/libffi-$(libffi_ver).tar.gz
@@ -373,31 +420,50 @@ speedo_pkg_libgcrypt_configure = --disable-static
 
 speedo_pkg_libksba_configure = --disable-static
 
-speedo_pkg_gnupg_configure = --enable-gpg2-is-gpg --disable-g13
+ifeq ($(TARGETOS),w32)
+speedo_pkg_gnupg_configure = --enable-gpg2-is-gpg --disable-g13 --disable-ntbtls
+else
+speedo_pkg_gnupg_configure = --disable-g13
+endif
 speedo_pkg_gnupg_extracflags = -g
 
+# Create the version info files only for W32 so that they won't get
+# installed if for example INSTALL_PREFIX=/usr/local is used.
+ifeq ($(TARGETOS),w32)
 define speedo_pkg_gnupg_post_install
 (set -e; \
  sed -n  's/.*PACKAGE_VERSION "\(.*\)"/\1/p' config.h >$(idir)/INST_VERSION; \
  sed -n  's/.*W32INFO_VI_PRODUCTVERSION \(.*\)/\1/p' common/w32info-rc.h \
     |sed 's/,/./g' >$(idir)/INST_PROD_VERSION )
 endef
-
+endif
 
 # The LDFLAGS is needed for -lintl for glib.
+ifeq ($(WITH_GUI),1)
 speedo_pkg_gpgme_configure = \
        --enable-static --enable-w32-glib --disable-w32-qt \
        --with-gpg-error-prefix=$(idir) \
        LDFLAGS=-L$(idir)/lib
+else
+speedo_pkg_gpgme_configure = \
+       --disable-static --disable-w32-glib --disable-w32-qt \
+       --with-gpg-error-prefix=$(idir) \
+       LDFLAGS=-L$(idir)/lib
+endif
 
-speedo_pkg_pinentry_configure = \
-       --disable-pinentry-qt --disable-pinentry-qt4 --disable-pinentry-gtk \
-       --enable-pinentry-gtk2 \
-       --with-glib-prefix=$(idir) --with-gtk-prefix=$(idir) \
+
+ifeq ($(TARGETOS),w32)
+speedo_pkg_pinentry_configure = --disable-pinentry-gtk2
+else
+speedo_pkg_pinentry_configure = --enable-pinentry-gtk2
+endif
+speedo_pkg_pinentry_configure += \
+        --disable-pinentry-qt4 \
        CPPFLAGS=-I$(idir)/include   \
        LDFLAGS=-L$(idir)/lib        \
        CXXFLAGS=-static-libstdc++
 
+
 speedo_pkg_gpa_configure = \
         --with-libiconv-prefix=$(idir) --with-libintl-prefix=$(idir) \
         --with-gpgme-prefix=$(idir) --with-zlib=$(idir) \
@@ -405,11 +471,13 @@ speedo_pkg_gpa_configure = \
 
 speedo_pkg_gpgex_configure = \
        --with-gpg-error-prefix=$(idir) \
-       --with-libassuan-prefix=$(idir)
+       --with-libassuan-prefix=$(idir) \
+       --enable-gpa-only
 
 speedo_pkg_w64_gpgex_configure = \
        --with-gpg-error-prefix=$(idir6) \
-       --with-libassuan-prefix=$(idir6)
+       --with-libassuan-prefix=$(idir6) \
+       --enable-gpa-only
 
 
 #
@@ -555,15 +623,22 @@ endif
 
 
 BUILD_ISODATE=$(shell date -u +%Y-%m-%d)
+BUILD_DATESTR=$(subst -,,$(BUILD_ISODATE))
 
 # The next two macros will work only after gnupg has been build.
+ifeq ($(TARGETOS),w32)
 INST_VERSION=$(shell head -1 $(idir)/INST_VERSION)
 INST_PROD_VERSION=$(shell head -1 $(idir)/INST_PROD_VERSION)
+endif
 
 # List with packages
 speedo_build_list = $(speedo_spkgs)
 speedo_w64_build_list = $(speedo_w64_spkgs)
 
+# To avoid running external commands during the read phase (":=" style
+# assignments), we check that the targetos has been given
+ifneq ($(TARGETOS),)
+
 # Determine build and host system
 build := $(shell $(topsrc)/autogen.sh --silent --print-build)
 ifeq ($(TARGETOS),w32)
@@ -587,6 +662,9 @@ else
   speedo_makeopt=-j$(MAKE_J)
 endif
 
+# End non-empty TARGETOS
+endif
+
 
 
 # The playground area is our scratch area, where we unpack, build and
@@ -716,15 +794,16 @@ $(stampdir)/stamp-$(1)-00-unpack: $(stampdir)/stamp-directories
          elif [ -n "$$$${tar}" ]; then                 \
           echo "speedo: unpacking $(1) from $$$${tar}"; \
            case "$$$${tar}" in                         \
-             *.gz) opt=z ;;                            \
-             *.bz2) opt=j ;;                           \
-            *.xz) opt=J ;;                             \
-             *) opt= ;;                                        \
+             *.gz) pretar=zcat ;;                      \
+             *.bz2) pretar=bzcat ;;                    \
+            *.xz) pretar=xzcat ;;                      \
+             *) pretar=cat ;;                          \
            esac;                                       \
            [ -f tmp.tgz ] && rm tmp.tgz;                \
            case "$$$${tar}" in                         \
-            /*) tar x$$$${opt}f - < $$$${tar} ;;       \
-            *)  wget -q -O - $$$${tar} | tee tmp.tgz | tar x$$$${opt}f - ;; \
+            /*) $$$${pretar} < $$$${tar} | tar xf - ;; \
+            *)  wget -q -O - $$$${tar} | tee tmp.tgz   \
+                  | $$$${pretar} | tar x$$$${opt}f - ;; \
           esac;                                        \
           if [ -f tmp.tgz ]; then                      \
             if [ -n "$$$${sha1}" ]; then               \
@@ -966,11 +1045,13 @@ clean-speedo:
 #
 # Windows installer
 #
+# {{{
+ifeq ($(TARGETOS),w32)
 
 dist-source: all
        for i in 00 01 02 03; do sleep 1;touch PLAY/stamps/stamp-*-${i}-*;done
        (set -e;\
-        tarname="$(INST_NAME)-$(INST_VERSION)_$(BUILD_ISODATE).tar" ;\
+        tarname="$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).tar" ;\
         [ -f "$$tarname" ] && rm "$$tarname" ;\
          tar -C $(topsrc) -cf "$$tarname" --exclude-backups --exclude-vc \
              --transform='s,^\./,$(INST_NAME)-$(INST_VERSION)/,' \
@@ -982,16 +1063,20 @@ dist-source: all
        )
 
 
+# Extract the two latest news entries.  */
 $(bdir)/NEWS.tmp: $(topsrc)/NEWS
-       sed -e '/^#/d' <$(topsrc)/NEWS >$(bdir)/NEWS.tmp
+       awk '/^Notewo/ {if(okay>1){exit}; okay++};okay {print $0}' \
+           <$(topsrc)/NEWS  >$(bdir)/NEWS.tmp
 
-$(bdir)/README.txt: $(bdir)/NEWS.tmp $(w32src)/README.txt \
+$(bdir)/README.txt: $(bdir)/NEWS.tmp $(topsrc)/README $(w32src)/README.txt \
                     $(w32src)/pkg-copyright.txt
        sed -e '/^;.*/d;' \
-       -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
+       -e '/!NEWSFILE!/{r $(bdir)/NEWS.tmp' -e 'd;}' \
+       -e '/!GNUPGREADME!/{r $(topsrc)/README' -e 'd;}' \
         -e '/!PKG-COPYRIGHT!/{r $(w32src)/pkg-copyright.txt' -e 'd;}' \
         -e 's,!VERSION!,$(INST_VERSION),g' \
           < $(w32src)/README.txt \
+           | sed -e '/^#/d' \
            | awk '{printf "%s\r\n", $$0}' >$(bdir)/README.txt
 
 $(bdir)/g4wihelp.dll: $(w32src)/g4wihelp.c $(w32src)/exdll.h
@@ -1005,6 +1090,11 @@ w32_insthelpers: $(bdir)/g4wihelp.dll
 $(bdir)/inst-options.ini: $(w32src)/inst-options.ini
        cat $(w32src)/inst-options.ini >$(bdir)/inst-options.ini
 
+extra_installer_options =
+ifeq ($(WITH_GUI),1)
+extra_installer_options += -DWITH_GUI=1
+endif
+
 installer: all w32_insthelpers $(w32src)/inst-options.ini $(bdir)/README.txt
        $(MAKENSIS) -V2 \
                     -DINST_DIR=$(idir) \
@@ -1013,11 +1103,16 @@ installer: all w32_insthelpers $(w32src)/inst-options.ini $(bdir)/README.txt
                     -DTOP_SRCDIR=$(topsrc) \
                     -DW32_SRCDIR=$(w32src) \
                     -DBUILD_ISODATE=$(BUILD_ISODATE) \
+                    -DBUILD_DATESTR=$(BUILD_DATESTR) \
                    -DNAME=$(INST_NAME) \
                    -DVERSION=$(INST_VERSION) \
                    -DPROD_VERSION=$(INST_PROD_VERSION) \
-                   $(w32src)/inst.nsi
-       @echo "Ready: $(idir)/$(INST_NAME)-$(INST_VERSION)"
+                   $(extra_installer_options) $(w32src)/inst.nsi
+       @echo "Ready: $(idir)/$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).exe"
+
+endif
+# }}} W32
+
 
 #
 # Check availibility of standard tools