speedo: Sign the windows installer with a timestamp.
[gnupg.git] / build-aux / speedo.mk
1 # speedo.mk - Speedo rebuilds speedily.
2 # Copyright (C) 2008, 2014 g10 Code GmbH
3 #
4 # speedo is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # speedo is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, see <http://www.gnu.org/licenses/>.
16
17 # speedo builds gnupg-related packages from GIT and installs them in a
18 # user directory, thereby providing a non-obstrusive test environment.
19 # speedo does only work with GNU make.  The build system is similar to
20 # that of gpg4win.  The following commands are supported:
21 #
22 #   make -f speedo.mk all  pkg2rep=/dir/with/tarballs
23 # or
24 #   make -f speedo.mk
25 #
26 # Builds all packages and installs them under PLAY/inst.  At the end,
27 # speedo prints commands that can be executed in the local shell to
28 # make use of the installed packages.
29 #
30 #   make -f speedo.mk clean
31 # or
32 #   make -f speedo.mk clean-PACKAGE
33 #
34 # Removes all packages or the package PACKAGE from the installation
35 # and build tree.  A subsequent make will rebuild these (and only
36 # these) packages.
37 #
38 #   make -f speedo.mk report
39 # or
40 #   make -f speedo.mk report-PACKAGE
41 #
42 # Lists packages and versions.
43 #
44
45 # We need to know our own name.
46 SPEEDO_MK := $(realpath $(lastword $(MAKEFILE_LIST)))
47
48 .PHONY : help native native-gui w32-installer w32-source
49 .PHONY :      git-native git-native-gui git-w32-installer git-w32-source
50 .PHONY :      this-native this-native-gui this-w32-installer this-w32-source
51
52 help:
53         @echo 'usage: make -f speedo.mk TARGET'
54         @echo '       with TARGET being one of:'
55         @echo '  help               This help'
56         @echo '  native             Native build of the GnuPG core'
57         @echo '  native-gui         Ditto but with pinentry and GPA'
58         @echo '  w32-installer      Build a Windows installer'
59         @echo '  w32-source         Pack a source archive'
60         @echo '  w32-release        Build a Windows release'
61         @echo '  w32-sign-installer Sign the installer'
62         @echo
63         @echo 'You may append INSTALL_PREFIX=<dir> for native builds.'
64         @echo 'Prepend TARGET with "git-" to build from GIT repos.'
65         @echo 'Prepend TARGET with "this-" to build from the source tarball.'
66         @echo 'Use STATIC=1 to build with statically linked libraries.'
67         @echo 'Use SELFCHECK=0 for a non-released version.'
68         @echo 'Use CUSTOM_SWDB=1 for an already downloaded swdb.lst.'
69
70 SPEEDOMAKE := $(MAKE) -f $(SPEEDO_MK) UPD_SWDB=1
71
72 native: check-tools
73         $(SPEEDOMAKE) TARGETOS=native WHAT=release WITH_GUI=0 all
74
75 git-native: check-tools
76         $(SPEEDOMAKE) TARGETOS=native WHAT=git     WITH_GUI=0 all
77
78 this-native: check-tools
79         $(SPEEDOMAKE) TARGETOS=native WHAT=this    WITH_GUI=0 all
80
81 native-gui: check-tools
82         $(SPEEDOMAKE) TARGETOS=native WHAT=release WITH_GUI=1 all
83
84 git-native-gui: check-tools
85         $(SPEEDOMAKE) TARGETOS=native WHAT=git     WITH_GUI=1 all
86
87 this-native-gui: check-tools
88         $(SPEEDOMAKE) TARGETOS=native WHAT=this    WITH_GUI=1 all
89
90 w32-installer: check-tools
91         $(SPEEDOMAKE) TARGETOS=w32    WHAT=release WITH_GUI=0 installer
92
93 git-w32-installer: check-tools
94         $(SPEEDOMAKE) TARGETOS=w32    WHAT=git     WITH_GUI=0 installer
95
96 this-w32-installer: check-tools
97         $(SPEEDOMAKE) TARGETOS=w32    WHAT=this    WITH_GUI=0 \
98                                                    CUSTOM_SWDB=1 installer
99
100 w32-source: check-tools
101         $(SPEEDOMAKE) TARGETOS=w32    WHAT=release WITH_GUI=0 dist-source
102
103 git-w32-source: check-tools
104         $(SPEEDOMAKE) TARGETOS=w32    WHAT=git     WITH_GUI=0 dist-source
105
106 this-w32-source: check-tools
107         $(SPEEDOMAKE) TARGETOS=w32    WHAT=this    WITH_GUI=0 \
108                                                    CUSTOM_SWDB=1 dist-source
109
110 w32-release: check-tools
111         $(SPEEDOMAKE) TARGETOS=w32 WHAT=release    WITH_GUI=0 SELFCHECK=0 \
112                                                    installer-from-source
113
114 w32-sign-installer: check-tools
115         $(SPEEDOMAKE) TARGETOS=w32 WHAT=release    WITH_GUI=0 SELFCHECK=0 \
116                                                    sign-installer
117
118 w32-release-offline: check-tools
119         $(SPEEDOMAKE) TARGETOS=w32 WHAT=release    WITH_GUI=0 SELFCHECK=0 \
120           CUSTOM_SWDB=1 pkgrep=${HOME}/b pkg10rep=${HOME}/b  \
121           installer-from-source
122
123
124 # Set this to "git" to build from git,
125 #          to "release" from tarballs,
126 #          to "this" from the unpacked sources.
127 WHAT=git
128
129 # Set target to "native" or "w32"
130 TARGETOS=
131
132 # Set to 1 to build the GUI tools
133 WITH_GUI=0
134
135 # Set to 1 to use a pre-installed swdb.lst instead of the online version.
136 CUSTOM_SWDB=0
137
138 # Set to 1 to really download the swdb.
139 UPD_SWDB=0
140
141 # Set to 0 to skip the GnuPG version self-check
142 SELFCHECK=1
143
144 # Set to 1 to build with statically linked libraries.
145 STATIC=0
146
147 # Set to the location of the directory with tarballs of
148 # external packages.
149 TARBALLS=$(shell pwd)/../tarballs
150
151 #  Number of parallel make jobs
152 MAKE_J=3
153
154 # Name to use for the w32 installer and sources
155 INST_NAME=gnupg-w32
156
157 # Use this to override the installaion directory for native builds.
158 INSTALL_PREFIX=none
159
160 # The Authenticode key and cert chain used to sign the Windows installer
161 AUTHENTICODE_KEY=${HOME}/.gnupg/g10code-authenticode-key.p12
162 AUTHENTICODE_CERTS=${HOME}/.gnupg/g10code-authenticode-certs.pem
163
164
165 # Directory names.
166 # They must be absolute, as we switch directories pretty often.
167 root := $(shell pwd)/PLAY
168 sdir := $(root)/src
169 bdir := $(root)/build
170 bdir6:= $(root)/build-w64
171 ifeq ($(INSTALL_PREFIX),none)
172 idir := $(root)/inst
173 else
174 idir := $(abspath $(INSTALL_PREFIX))
175 endif
176 idir6:= $(root)/inst-w64
177 stampdir := $(root)/stamps
178 topsrc := $(shell cd $(dir $(SPEEDO_MK)).. && pwd)
179 auxsrc := $(topsrc)/build-aux/speedo
180 patdir := $(topsrc)/build-aux/speedo/patches
181 w32src := $(topsrc)/build-aux/speedo/w32
182
183 # =====BEGIN LIST OF PACKAGES=====
184 # The packages that should be built.  The order is also the build order.
185 # Fixme: Do we need to build pkg-config for cross-building?
186
187 speedo_spkgs  = \
188         libgpg-error npth libgcrypt
189
190 ifeq ($(TARGETOS),w32)
191 speedo_spkgs += \
192         zlib bzip2 sqlite
193 ifeq ($(WITH_GUI),1)
194 speedo_spkgs += gettext libiconv
195 endif
196 endif
197
198 speedo_spkgs += \
199         libassuan libksba
200
201 ifeq ($(TARGETOS),w32)
202 speedo_spkgs += \
203         ntbtls
204 endif
205
206 speedo_spkgs += \
207         gnupg
208
209 ifeq ($(TARGETOS),w32)
210 ifeq ($(WITH_GUI),1)
211 speedo_spkgs += \
212         libffi glib pkg-config
213 endif
214 endif
215
216 ifeq ($(STATIC),0)
217 speedo_spkgs += \
218         gpgme
219 endif
220
221 ifeq ($(TARGETOS),w32)
222 ifeq ($(WITH_GUI),1)
223 speedo_spkgs += \
224         libpng \
225         gdk-pixbuf atk pixman cairo pango gtk+
226 endif
227 endif
228
229 ifeq ($(TARGETOS),w32)
230
231 speedo_spkgs += pinentry
232 ifeq ($(WITH_GUI),1)
233 speedo_spkgs += gpa gpgex
234 endif
235
236 else
237
238 ifeq ($(WITH_GUI),1)
239 speedo_spkgs += pinentry gpa
240 endif
241
242 endif
243
244
245 # =====END LIST OF PACKAGES=====
246
247
248 # Packages which are additionally build for 64 bit Windows.  They are
249 # only used for gpgex and thus we need to build them only if we want
250 # a full installer.
251 speedo_w64_spkgs  =
252 ifeq ($(WITH_GUI),1)
253 speedo_w64_spkgs += libgpg-error libiconv gettext libassuan gpgex
254 endif
255
256 # Packages which use the gnupg autogen.sh build style
257 speedo_gnupg_style = \
258         libgpg-error npth libgcrypt  \
259         libassuan libksba ntbtls gnupg gpgme \
260         pinentry gpa gpgex
261
262 # Packages which use only make and no build directory
263 speedo_make_only_style = \
264         zlib bzip2
265
266 # Get the content of the software DB.
267 ifeq ($(CUSTOM_SWDB),1)
268 getswdb_options = --skip-download --skip-verify
269 else
270 getswdb_options =
271 endif
272 ifeq ($(SELFCHECK),0)
273 getswdb_options += --skip-selfcheck
274 endif
275 ifeq ($(UPD_SWDB),1)
276 SWDB := $(shell $(topsrc)/build-aux/getswdb.sh $(getswdb_options) && echo okay)
277 ifeq ($(strip $(SWDB)),)
278 ifneq ($(WHAT),git)
279 $(error Error getting GnuPG software version database)
280 endif
281 endif
282
283 # Version numbers of the released packages
284 gnupg_ver_this = $(shell cat $(topsrc)/VERSION)
285
286 gnupg_ver        := $(shell awk '$$1=="gnupg24_ver" {print $$2}' swdb.lst)
287
288 libgpg_error_ver := $(shell awk '$$1=="libgpg_error_ver" {print $$2}' swdb.lst)
289 libgpg_error_sha1:= $(shell awk '$$1=="libgpg_error_sha1" {print $$2}' swdb.lst)
290 libgpg_error_sha2:= $(shell awk '$$1=="libgpg_error_sha2" {print $$2}' swdb.lst)
291
292 npth_ver  := $(shell awk '$$1=="npth_ver" {print $$2}' swdb.lst)
293 npth_sha1 := $(shell awk '$$1=="npth_sha1" {print $$2}' swdb.lst)
294 npth_sha2 := $(shell awk '$$1=="npth_sha2" {print $$2}' swdb.lst)
295
296 libgcrypt_ver  := $(shell awk '$$1=="libgcrypt_ver" {print $$2}' swdb.lst)
297 libgcrypt_sha1 := $(shell awk '$$1=="libgcrypt_sha1" {print $$2}' swdb.lst)
298 libgcrypt_sha2 := $(shell awk '$$1=="libgcrypt_sha2" {print $$2}' swdb.lst)
299
300 libassuan_ver  := $(shell awk '$$1=="libassuan_ver" {print $$2}' swdb.lst)
301 libassuan_sha1 := $(shell awk '$$1=="libassuan_sha1" {print $$2}' swdb.lst)
302 libassuan_sha2 := $(shell awk '$$1=="libassuan_sha2" {print $$2}' swdb.lst)
303
304 libksba_ver  := $(shell awk '$$1=="libksba_ver" {print $$2}' swdb.lst)
305 libksba_sha1 := $(shell awk '$$1=="libksba_sha1" {print $$2}' swdb.lst)
306 libksba_sha2 := $(shell awk '$$1=="libksba_sha2" {print $$2}' swdb.lst)
307
308 ntbtls_ver  := $(shell awk '$$1=="ntbtls_ver" {print $$2}' swdb.lst)
309 ntbtls_sha1 := $(shell awk '$$1=="ntbtls_sha1" {print $$2}' swdb.lst)
310 ntbtls_sha2 := $(shell awk '$$1=="ntbtls_sha2" {print $$2}' swdb.lst)
311
312 gpgme_ver  := $(shell awk '$$1=="gpgme_ver" {print $$2}' swdb.lst)
313 gpgme_sha1 := $(shell awk '$$1=="gpgme_sha1" {print $$2}' swdb.lst)
314 gpgme_sha2 := $(shell awk '$$1=="gpgme_sha2" {print $$2}' swdb.lst)
315
316 pinentry_ver  := $(shell awk '$$1=="pinentry_ver" {print $$2}' swdb.lst)
317 pinentry_sha1 := $(shell awk '$$1=="pinentry_sha1" {print $$2}' swdb.lst)
318 pinentry_sha2 := $(shell awk '$$1=="pinentry_sha2" {print $$2}' swdb.lst)
319
320 gpa_ver  := $(shell awk '$$1=="gpa_ver" {print $$2}' swdb.lst)
321 gpa_sha1 := $(shell awk '$$1=="gpa_sha1" {print $$2}' swdb.lst)
322 gpa_sha2 := $(shell awk '$$1=="gpa_sha2" {print $$2}' swdb.lst)
323
324 gpgex_ver  := $(shell awk '$$1=="gpgex_ver" {print $$2}' swdb.lst)
325 gpgex_sha1 := $(shell awk '$$1=="gpgex_sha1" {print $$2}' swdb.lst)
326 gpgex_sha2 := $(shell awk '$$1=="gpgex_sha2" {print $$2}' swdb.lst)
327
328 zlib_ver  := $(shell awk '$$1=="zlib_ver" {print $$2}' swdb.lst)
329 zlib_sha1 := $(shell awk '$$1=="zlib_sha1_gz" {print $$2}' swdb.lst)
330 zlib_sha2 := $(shell awk '$$1=="zlib_sha2_gz" {print $$2}' swdb.lst)
331
332 bzip2_ver  := $(shell awk '$$1=="bzip2_ver" {print $$2}' swdb.lst)
333 bzip2_sha1 := $(shell awk '$$1=="bzip2_sha1_gz" {print $$2}' swdb.lst)
334 bzip2_sha2 := $(shell awk '$$1=="bzip2_sha2_gz" {print $$2}' swdb.lst)
335
336 sqlite_ver  := $(shell awk '$$1=="sqlite_ver" {print $$2}' swdb.lst)
337 sqlite_sha1 := $(shell awk '$$1=="sqlite_sha1_gz" {print $$2}' swdb.lst)
338 sqlite_sha2 := $(shell awk '$$1=="sqlite_sha2_gz" {print $$2}' swdb.lst)
339
340
341 $(info Information from the version database)
342 $(info GnuPG ..........: $(gnupg_ver) (building $(gnupg_ver_this)))
343 $(info Libgpg-error ...: $(libgpg_error_ver))
344 $(info Npth ...........: $(npth_ver))
345 $(info Libgcrypt ......: $(libgcrypt_ver))
346 $(info Libassuan ......: $(libassuan_ver))
347 $(info Libksba ........: $(libksba_ver))
348 $(info Zlib ...........: $(zlib_ver))
349 $(info Bzip2 ..........: $(bzip2_ver))
350 $(info SQLite .........: $(sqlite_ver))
351 $(info NtbTLS .. ......: $(ntbtls_ver))
352 $(info GPGME ..........: $(gpgme_ver))
353 $(info Pinentry .......: $(pinentry_ver))
354 $(info GPA ............: $(gpa_ver))
355 $(info GpgEX.... ......: $(gpgex_ver))
356 endif
357
358 # Version number for external packages
359 pkg_config_ver = 0.23
360 libiconv_ver = 1.14
361 gettext_ver = 0.18.2.1
362 libffi_ver = 3.0.13
363 glib_ver = 2.34.3
364 libpng_ver = 1.4.12
365 gdk_pixbuf_ver = 2.26.5
366 atk_ver = 1.32.0
367 pango_ver = 1.29.4
368 pixman_ver = 0.32.4
369 cairo_ver = 1.12.16
370 gtk__ver = 2.24.17
371
372 # The GIT repository.  Using a local repo is much faster.
373 #gitrep = git://git.gnupg.org
374 gitrep = ${HOME}/s
375
376 # The tarball directories
377 pkgrep = ftp://ftp.gnupg.org/gcrypt
378 pkg10rep = ftp://ftp.g10code.com/g10code
379 pkg2rep = $(TARBALLS)
380
381 # For each package, the following variables can be defined:
382 #
383 # speedo_pkg_PACKAGE_git: The GIT repository that should be built.
384 # speedo_pkg_PACKAGE_gitref: The GIT revision to checkout
385 #
386 # speedo_pkg_PACKAGE_tar: URL to the tar file that should be built.
387 #
388 # Exactly one of the above variables is required.  Note that this
389 # version of speedo does not cache repositories or tar files, and does
390 # not test the integrity of the downloaded software.  If you care
391 # about this, you can also specify filenames to locally verified files.
392 # Filenames are differentiated from URLs by starting with a slash '/'.
393 #
394 # speedo_pkg_PACKAGE_configure: Extra arguments to configure.
395 #
396 # speedo_pkg_PACKAGE_make_args: Extra arguments to make.
397 #
398 # speedo_pkg_PACKAGE_make_args_inst: Extra arguments to make install.
399 #
400 # Note that you can override the defaults in this file in a local file
401 # "config.mk"
402
403 ifeq ($(WHAT),this)
404 else ifeq ($(WHAT),git)
405   speedo_pkg_libgpg_error_git = $(gitrep)/libgpg-error
406   speedo_pkg_libgpg_error_gitref = master
407   speedo_pkg_npth_git = $(gitrep)/npth
408   speedo_pkg_npth_gitref = master
409   speedo_pkg_libassuan_git = $(gitrep)/libassuan
410   speedo_pkg_libassuan_gitref = master
411   speedo_pkg_libgcrypt_git = $(gitrep)/libgcrypt
412   speedo_pkg_libgcrypt_gitref = master
413   speedo_pkg_libksba_git = $(gitrep)/libksba
414   speedo_pkg_libksba_gitref = master
415   speedo_pkg_ntbtls_git = $(gitrep)/ntbtls
416   speedo_pkg_ntbtls_gitref = master
417   speedo_pkg_gpgme_git = $(gitrep)/gpgme
418   speedo_pkg_gpgme_gitref = master
419   speedo_pkg_pinentry_git = $(gitrep)/pinentry
420   speedo_pkg_pinentry_gitref = master
421   speedo_pkg_gpa_git = $(gitrep)/gpa
422   speedo_pkg_gpa_gitref = master
423   speedo_pkg_gpgex_git = $(gitrep)/gpgex
424   speedo_pkg_gpgex_gitref = master
425 else ifeq ($(WHAT),release)
426   speedo_pkg_libgpg_error_tar = \
427         $(pkgrep)/libgpg-error/libgpg-error-$(libgpg_error_ver).tar.bz2
428   speedo_pkg_npth_tar = \
429         $(pkgrep)/npth/npth-$(npth_ver).tar.bz2
430   speedo_pkg_libassuan_tar = \
431         $(pkgrep)/libassuan/libassuan-$(libassuan_ver).tar.bz2
432   speedo_pkg_libgcrypt_tar = \
433         $(pkgrep)/libgcrypt/libgcrypt-$(libgcrypt_ver).tar.bz2
434   speedo_pkg_libksba_tar = \
435         $(pkgrep)/libksba/libksba-$(libksba_ver).tar.bz2
436   speedo_pkg_ntbtls_tar = \
437         $(pkgrep)/ntbtls/ntbtls-$(ntbtls_ver).tar.bz2
438   speedo_pkg_gpgme_tar = \
439         $(pkgrep)/gpgme/gpgme-$(gpgme_ver).tar.bz2
440   speedo_pkg_pinentry_tar = \
441         $(pkgrep)/pinentry/pinentry-$(pinentry_ver).tar.bz2
442   speedo_pkg_gpa_tar = \
443         $(pkgrep)/gpa/gpa-$(gpa_ver).tar.bz2
444   speedo_pkg_gpgex_tar = \
445         $(pkg10rep)/gpgex/gpgex-$(gpgex_ver).tar.bz2
446 else
447   $(error invalid value for WHAT (use on of: git release this))
448 endif
449
450 speedo_pkg_pkg_config_tar = $(pkg2rep)/pkg-config-$(pkg_config_ver).tar.gz
451 speedo_pkg_zlib_tar       = $(pkgrep)/zlib/zlib-$(zlib_ver).tar.gz
452 speedo_pkg_bzip2_tar      = $(pkgrep)/bzip2/bzip2-$(bzip2_ver).tar.gz
453 speedo_pkg_sqlite_tar     = $(pkgrep)/sqlite/sqlite-autoconf-$(sqlite_ver).tar.gz
454 speedo_pkg_libiconv_tar   = $(pkg2rep)/libiconv-$(libiconv_ver).tar.gz
455 speedo_pkg_gettext_tar    = $(pkg2rep)/gettext-$(gettext_ver).tar.gz
456 speedo_pkg_libffi_tar     = $(pkg2rep)/libffi-$(libffi_ver).tar.gz
457 speedo_pkg_glib_tar       = $(pkg2rep)/glib-$(glib_ver).tar.xz
458 speedo_pkg_libpng_tar     = $(pkg2rep)/libpng-$(libpng_ver).tar.bz2
459 speedo_pkg_gdk_pixbuf_tar = $(pkg2rep)/gdk-pixbuf-$(gdk_pixbuf_ver).tar.xz
460 speedo_pkg_atk_tar        = $(pkg2rep)/atk-$(atk_ver).tar.bz2
461 speedo_pkg_pango_tar      = $(pkg2rep)/pango-$(pango_ver).tar.bz2
462 speedo_pkg_pixman_tar     = $(pkg2rep)/pixman-$(pixman_ver).tar.gz
463 speedo_pkg_cairo_tar      = $(pkg2rep)/cairo-$(cairo_ver).tar.xz
464 speedo_pkg_gtk__tar       = $(pkg2rep)/gtk+-$(gtk__ver).tar.xz
465
466
467 #
468 # Package build options
469 #
470
471 speedo_pkg_npth_configure = --enable-static
472
473 speedo_pkg_libgpg_error_configure = --enable-static
474 speedo_pkg_w64_libgpg_error_configure = --enable-static
475
476 speedo_pkg_libassuan_configure = --enable-static
477 speedo_pkg_w64_libassuan_configure = --enable-static
478
479 speedo_pkg_libgcrypt_configure = --disable-static
480
481 speedo_pkg_libksba_configure = --disable-static
482
483 speedo_pkg_ntbtls_configure = --enable-static
484
485
486 ifeq ($(STATIC),1)
487 speedo_pkg_npth_configure += --disable-shared
488
489 speedo_pkg_libgpg_error_configure += --disable-shared
490
491 speedo_pkg_libassuan_configure += --disable-shared
492
493 speedo_pkg_libgcrypt_configure += --disable-shared
494
495 speedo_pkg_libksba_configure += --disable-shared
496 endif
497
498 # For now we build ntbtls only static
499 speedo_pkg_ntbtls_configure = --disable-shared
500
501 ifeq ($(TARGETOS),w32)
502 speedo_pkg_gnupg_configure = \
503         --disable-g13 --enable-ntbtls \
504         --enable-build-timestamp
505 else
506 speedo_pkg_gnupg_configure = --disable-g13 --enable-wks-tools
507 endif
508 speedo_pkg_gnupg_extracflags = -g
509
510 # Create the version info files only for W32 so that they won't get
511 # installed if for example INSTALL_PREFIX=/usr/local is used.
512 ifeq ($(TARGETOS),w32)
513 define speedo_pkg_gnupg_post_install
514 (set -e; \
515  sed -n  's/.*PACKAGE_VERSION "\(.*\)"/\1/p' config.h >$(idir)/INST_VERSION; \
516  sed -n  's/.*W32INFO_VI_PRODUCTVERSION \(.*\)/\1/p' common/w32info-rc.h \
517     |sed 's/,/./g' >$(idir)/INST_PROD_VERSION )
518 endef
519 endif
520
521 # The LDFLAGS is needed for -lintl for glib.
522 ifeq ($(WITH_GUI),1)
523 speedo_pkg_gpgme_configure = \
524         --enable-static --enable-w32-glib --disable-w32-qt \
525         --with-gpg-error-prefix=$(idir) \
526         LDFLAGS=-L$(idir)/lib
527 else
528 speedo_pkg_gpgme_configure = \
529         --disable-static --disable-w32-glib --disable-w32-qt \
530         --with-gpg-error-prefix=$(idir) \
531         LDFLAGS=-L$(idir)/lib
532 endif
533
534
535 ifeq ($(TARGETOS),w32)
536 speedo_pkg_pinentry_configure = --disable-pinentry-gtk2
537 else
538 speedo_pkg_pinentry_configure = --enable-pinentry-gtk2
539 endif
540 speedo_pkg_pinentry_configure += \
541         --disable-pinentry-qt5   \
542         --disable-pinentry-qt    \
543         --disable-pinentry-fltk  \
544         --disable-pinentry-tty   \
545         CPPFLAGS=-I$(idir)/include   \
546         LDFLAGS=-L$(idir)/lib        \
547         CXXFLAGS=-static-libstdc++
548
549
550 speedo_pkg_gpa_configure = \
551         --with-libiconv-prefix=$(idir) --with-libintl-prefix=$(idir) \
552         --with-gpgme-prefix=$(idir) --with-zlib=$(idir) \
553         --with-libassuan-prefix=$(idir) --with-gpg-error-prefix=$(idir)
554
555 speedo_pkg_gpgex_configure = \
556         --with-gpg-error-prefix=$(idir) \
557         --with-libassuan-prefix=$(idir) \
558         --enable-gpa-only
559
560 speedo_pkg_w64_gpgex_configure = \
561         --with-gpg-error-prefix=$(idir6) \
562         --with-libassuan-prefix=$(idir6) \
563         --enable-gpa-only
564
565
566 #
567 # External packages
568 #
569
570 ifeq ($(TARGETOS),w32)
571 speedo_pkg_zlib_make_args = \
572         -fwin32/Makefile.gcc PREFIX=$(host)- IMPLIB=libz.dll.a
573
574 speedo_pkg_zlib_make_args_inst = \
575         -fwin32/Makefile.gcc \
576         BINARY_PATH=$(idir)/bin INCLUDE_PATH=$(idir)/include \
577         LIBRARY_PATH=$(idir)/lib SHARED_MODE=1 IMPLIB=libz.dll.a
578
579 # Zlib needs some special magic to generate a libtool file.
580 # We also install the pc file here.
581 define speedo_pkg_zlib_post_install
582 (set -e; mkdir $(idir)/lib/pkgconfig || true;           \
583 cp $(auxsrc)/zlib.pc $(idir)/lib/pkgconfig/;            \
584 cd $(idir);                                             \
585 echo "# Generated by libtool" > lib/libz.la             \
586 echo "dlname='../bin/zlib1.dll'" >> lib/libz.la;        \
587 echo "library_names='libz.dll.a'" >> lib/libz.la;       \
588 echo "old_library='libz.a'" >> lib/libz.la;             \
589 echo "dependency_libs=''" >> lib/libz.la;               \
590 echo "current=1" >> lib/libz.la;                        \
591 echo "age=2" >> lib/libz.la;                            \
592 echo "revision=5" >> lib/libz.la;                       \
593 echo "installed=yes" >> lib/libz.la;                    \
594 echo "shouldnotlink=no" >> lib/libz.la;                 \
595 echo "dlopen=''" >> lib/libz.la;                        \
596 echo "dlpreopen=''" >> lib/libz.la;                     \
597 echo "libdir=\"$(idir)/lib\"" >> lib/libz.la)
598 endef
599
600 endif
601
602 ifeq ($(TARGETOS),w32)
603 speedo_pkg_bzip2_make_args = \
604         CC="$(host)-gcc" AR="$(host)-ar" RANLIB="$(host)-ranlib"
605
606 speedo_pkg_bzip2_make_args_inst = \
607         PREFIX=$(idir) CC="$(host)-gcc" AR="$(host)-ar" RANLIB="$(host)-ranlib"
608 endif
609
610 speedo_pkg_w64_libiconv_configure = \
611         --enable-shared=no --enable-static=yes
612
613 speedo_pkg_gettext_configure = \
614         --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
615         CPPFLAGS=-I$(idir)/include LDFLAGS=-L$(idir)/lib
616 speedo_pkg_w64_gettext_configure = \
617         --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
618         CPPFLAGS=-I$(idir6)/include LDFLAGS=-L$(idir6)/lib
619 speedo_pkg_gettext_extracflags = -O2
620 # We only need gettext-runtime and there is sadly no top level
621 # configure option for this
622 speedo_pkg_gettext_make_dir = gettext-runtime
623
624
625 speedo_pkg_glib_configure = \
626         --disable-modular-tests \
627         --with-libiconv=gnu \
628         CPPFLAGS=-I$(idir)/include \
629         LDFLAGS=-L$(idir)/lib \
630         CCC=$(host)-g++ \
631         LIBFFI_CFLAGS=-I$(idir)/lib/libffi-$(libffi_ver)/include \
632         LIBFFI_LIBS=\"-L$(idir)/lib -lffi\"
633 ifeq ($(TARGETOS),w32)
634 speedo_pkg_glib_extracflags = -march=i486
635 endif
636
637 ifeq ($(TARGETOS),w32)
638 speedo_pkg_libpng_configure = \
639         CPPFLAGS=\"-I$(idir)/include -DPNG_BUILD_DLL\" \
640         LDFLAGS=\"-L$(idir)/lib\" LIBPNG_DEFINES=\"-DPNG_BUILD_DLL\"
641 else
642 speedo_pkg_libpng_configure = \
643         CPPFLAGS=\"-I$(idir)/include\" \
644         LDFLAGS=\"-L$(idir)/lib\"
645 endif
646
647 ifneq ($(TARGETOS),w32)
648 speedo_pkg_gdk_pixbuf_configure = --without-libtiff --without-libjpeg
649 endif
650
651 speedo_pkg_pixman_configure = \
652         CPPFLAGS=-I$(idir)/include \
653         LDFLAGS=-L$(idir)/lib
654
655 ifeq ($(TARGETOS),w32)
656 speedo_pkg_cairo_configure = \
657         --disable-qt --disable-ft --disable-fc \
658         --enable-win32 --enable-win32-font \
659         CPPFLAGS=-I$(idir)/include \
660         LDFLAGS=-L$(idir)/lib
661 else
662 speedo_pkg_cairo_configure = \
663         --disable-qt \
664         CPPFLAGS=-I$(idir)/include \
665         LDFLAGS=-L$(idir)/lib
666 endif
667
668 speedo_pkg_pango_configure = \
669         --disable-gtk-doc  \
670         CPPFLAGS=-I$(idir)/include \
671         LDFLAGS=-L$(idir)/lib
672
673 speedo_pkg_gtk__configure = \
674         --disable-cups \
675         CPPFLAGS=-I$(idir)/include \
676         LDFLAGS=-L$(idir)/lib
677
678
679 # ---------
680
681 all: all-speedo
682
683 report: report-speedo
684
685 clean: clean-speedo
686
687 ifeq ($(TARGETOS),w32)
688 STRIP = i686-w64-mingw32-strip
689 else
690 STRIP = strip
691 endif
692 W32CC = i686-w64-mingw32-gcc
693
694 -include config.mk
695
696 #
697 #  The generic speedo code
698 #
699
700 MKDIR=mkdir
701 MAKENSIS=makensis
702 SHA1SUM := $(shell $(topsrc)/build-aux/getswdb.sh --find-sha1sum)
703 ifeq ($(SHA1SUM),false)
704 $(error The sha1sum tool is missing)
705 endif
706 SHA2SUM := $(shell $(topsrc)/build-aux/getswdb.sh --find-sha256sum)
707 ifeq ($(SHA2SUM),false)
708 $(error The sha256sum tool is missing)
709 endif
710
711
712 BUILD_ISODATE=$(shell date -u +%Y-%m-%d)
713 BUILD_DATESTR=$(subst -,,$(BUILD_ISODATE))
714
715 # The next two macros will work only after gnupg has been build.
716 ifeq ($(TARGETOS),w32)
717 INST_VERSION=$(shell head -1 $(idir)/INST_VERSION)
718 INST_PROD_VERSION=$(shell head -1 $(idir)/INST_PROD_VERSION)
719 endif
720
721 # List with packages
722 speedo_build_list = $(speedo_spkgs)
723 speedo_w64_build_list = $(speedo_w64_spkgs)
724
725 # To avoid running external commands during the read phase (":=" style
726 # assignments), we check that the targetos has been given
727 ifneq ($(TARGETOS),)
728
729 # Determine build and host system
730 build := $(shell $(topsrc)/autogen.sh --silent --print-build)
731 ifeq ($(TARGETOS),w32)
732   speedo_autogen_buildopt := --build-w32
733   speedo_autogen_buildopt6 := --build-w64
734   host := $(shell $(topsrc)/autogen.sh --silent --print-host --build-w32)
735   host6:= $(shell $(topsrc)/autogen.sh --silent --print-host --build-w64)
736   speedo_host_build_option := --host=$(host) --build=$(build)
737   speedo_host_build_option6 := --host=$(host6) --build=$(build)
738   speedo_w32_cflags := -mms-bitfields
739 else
740   speedo_autogen_buildopt :=
741   host :=
742   speedo_host_build_option :=
743   speedo_w32_cflags :=
744 endif
745
746 ifeq ($(MAKE_J),)
747   speedo_makeopt=
748 else
749   speedo_makeopt=-j$(MAKE_J)
750 endif
751
752 # End non-empty TARGETOS
753 endif
754
755
756
757 # The playground area is our scratch area, where we unpack, build and
758 # install the packages.
759 $(stampdir)/stamp-directories:
760         $(MKDIR) $(root) || true
761         $(MKDIR) $(stampdir) || true
762         $(MKDIR) $(sdir)  || true
763         $(MKDIR) $(bdir)  || true
764         $(MKDIR) $(idir)   || true
765 ifeq ($(TARGETOS),w32)
766         $(MKDIR) $(bdir6)  || true
767         $(MKDIR) $(idir6)   || true
768 endif
769         touch $(stampdir)/stamp-directories
770
771 # Frob the name $1 by converting all '-' and '+' characters to '_'.
772 define FROB_macro
773 $(subst +,_,$(subst -,_,$(1)))
774 endef
775
776 # Get the variable $(1) (which may contain '-' and '+' characters).
777 define GETVAR
778 $($(call FROB_macro,$(1)))
779 endef
780
781 # Set a couple of common variables.
782 define SETVARS
783         pkg="$(1)";                                                     \
784         git="$(call GETVAR,speedo_pkg_$(1)_git)";                       \
785         gitref="$(call GETVAR,speedo_pkg_$(1)_gitref)";                 \
786         tar="$(call GETVAR,speedo_pkg_$(1)_tar)";                       \
787         ver="$(call GETVAR,$(1)_ver)";                                  \
788         sha2="$(call GETVAR,$(1)_sha2)";                                \
789         sha1="$(call GETVAR,$(1)_sha1)";                                \
790         pkgsdir="$(sdir)/$(1)";                                         \
791         if [ "$(1)" = "gnupg" ]; then                                   \
792           git='';                                                       \
793           gitref='';                                                    \
794           tar='';                                                       \
795           pkgsdir="$(topsrc)";                                          \
796         fi;                                                             \
797         pkgbdir="$(bdir)/$(1)";                                         \
798         pkgcfg="$(call GETVAR,speedo_pkg_$(1)_configure)";              \
799         tmp="$(speedo_w32_cflags)                                       \
800              $(call GETVAR,speedo_pkg_$(1)_extracflags)";               \
801         if [ x$$$$(echo "$$$$tmp" | tr -d '[:space:]')x != xx ]; then   \
802           pkgextracflags="CFLAGS=\"$$$$tmp\"";                          \
803         else                                                            \
804           pkgextracflags=;                                              \
805         fi;                                                             \
806         pkgmkdir="$(call GETVAR,speedo_pkg_$(1)_make_dir)";             \
807         pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)";           \
808         pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \
809         pkgmkargs_uninst="$(call GETVAR,speedo_pkg_$(1)_make_args_uninst)"; \
810         export PKG_CONFIG="/usr/bin/pkg-config";                        \
811         export PKG_CONFIG_PATH="$(idir)/lib/pkgconfig";                 \
812         [ "$(TARGETOS)" != native ] && export PKG_CONFIG_LIBDIR="";     \
813         export SYSROOT="$(idir)";                                       \
814         export PATH="$(idir)/bin:$${PATH}";                             \
815         export LD_LIBRARY_PATH="$(idir)/lib:$${LD_LIBRARY_PATH}"
816 endef
817
818 define SETVARS_W64
819         pkg="$(1)";                                                     \
820         git="$(call GETVAR,speedo_pkg_$(1)_git)";                       \
821         gitref="$(call GETVAR,speedo_pkg_$(1)_gitref)";                 \
822         tar="$(call GETVAR,speedo_pkg_$(1)_tar)";                       \
823         ver="$(call GETVAR,$(1)_ver)";                                  \
824         sha2="$(call GETVAR,$(1)_sha2)";                                \
825         sha1="$(call GETVAR,$(1)_sha1)";                                \
826         pkgsdir="$(sdir)/$(1)";                                         \
827         if [ "$(1)" = "gnupg" ]; then                                   \
828           git='';                                                       \
829           gitref='';                                                    \
830           tar='';                                                       \
831           pkgsdir="$(topsrc)";                                          \
832         fi;                                                             \
833         pkgbdir="$(bdir6)/$(1)";                                        \
834         pkgcfg="$(call GETVAR,speedo_pkg_w64_$(1)_configure)";          \
835         tmp="$(speedo_w32_cflags)                                       \
836              $(call GETVAR,speedo_pkg_$(1)_extracflags)";               \
837         if [ x$$$$(echo "$$$$tmp" | tr -d '[:space:]')x != xx ]; then   \
838           pkgextracflags="CFLAGS=\"$$$$tmp\"";                          \
839         else                                                            \
840           pkgextracflags=;                                              \
841         fi;                                                             \
842         pkgmkdir="$(call GETVAR,speedo_pkg_$(1)_make_dir)";             \
843         pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)";           \
844         pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \
845         pkgmkargs_uninst="$(call GETVAR,speedo_pkg_$(1)_make_args_uninst)"; \
846         export PKG_CONFIG="/usr/bin/pkg-config";                        \
847         export PKG_CONFIG_PATH="$(idir6)/lib/pkgconfig";                \
848         [ "$(TARGETOS)" != native ] && export PKG_CONFIG_LIBDIR="";     \
849         export SYSROOT="$(idir6)";                                      \
850         export PATH="$(idir6)/bin:$${PATH}";                            \
851         export LD_LIBRARY_PATH="$(idir6)/lib:$${LD_LIBRARY_PATH}"
852 endef
853
854
855 # Template for source packages.
856
857 # Note that the gnupg package is special: The package source dir is
858 # the same as the topsrc dir and thus we need to detect the gnupg
859 # package and cd to that directory.  We also test that no in-source build
860 # has been done.  autogen.sh is not run for gnupg.
861 #
862 define SPKG_template
863
864 $(stampdir)/stamp-$(1)-00-unpack: $(stampdir)/stamp-directories
865         @echo "speedo: /*"
866         @echo "speedo:  *   $(1)"
867         @echo "speedo:  */"
868         @(set -e; cd $(sdir);                           \
869          $(call SETVARS,$(1));                          \
870          if [ "$(WHAT)" = "this" ]; then                \
871            echo "speedo: using included source";        \
872          elif [ "$(1)" = "gnupg" ]; then                \
873            cd $$$${pkgsdir};                            \
874            if [ -f config.log ]; then                   \
875              echo "GnuPG has already been build in-source" >&2  ;\
876              echo "Please run \"make distclean\" and retry" >&2 ;\
877              exit 1 ;                                   \
878            fi;                                          \
879            echo "speedo: unpacking gnupg not needed";   \
880          elif [ -n "$$$${git}" ]; then                  \
881            echo "speedo: unpacking $(1) from $$$${git}:$$$${gitref}"; \
882            git clone -b "$$$${gitref}" "$$$${git}" "$$$${pkg}"; \
883            cd "$$$${pkg}";                              \
884            AUTOGEN_SH_SILENT=1 ./autogen.sh;            \
885          elif [ -n "$$$${tar}" ]; then                  \
886            echo "speedo: unpacking $(1) from $$$${tar}"; \
887            case "$$$${tar}" in                          \
888              *.gz) pretar=zcat ;;                       \
889              *.bz2) pretar=bzcat ;;                     \
890              *.xz) pretar=xzcat ;;                      \
891              *) pretar=cat ;;                           \
892            esac;                                        \
893            [ -f tmp.tgz ] && rm tmp.tgz;                \
894            case "$$$${tar}" in                          \
895              /*) $$$${pretar} < $$$${tar} | tar xf - ;; \
896              *)  wget -q -O - $$$${tar} | tee tmp.tgz   \
897                   | $$$${pretar} | tar x$$$${opt}f - ;; \
898            esac;                                        \
899            if [ -f tmp.tgz ]; then                      \
900              if [ -n "$$$${sha2}" ]; then               \
901                tmp=$$$$($(SHA2SUM) <tmp.tgz|cut -d' ' -f1);\
902                if [ "$$$${tmp}" != "$$$${sha2}" ]; then \
903                  echo "speedo:";                        \
904                  echo "speedo: ERROR: SHA-256 checksum mismatch for $(1)";\
905                  echo "speedo:";                        \
906                  exit 1;                                \
907                fi;                                      \
908              elif [ -n "$$$${sha1}" ]; then            \
909                tmp=$$$$($(SHA1SUM) <tmp.tgz|cut -d' ' -f1);\
910                if [ "$$$${tmp}" != "$$$${sha1}" ]; then \
911                  echo "speedo:";                        \
912                  echo "speedo: ERROR: SHA-1 checksum mismatch for $(1)";\
913                  echo "speedo:";                        \
914                  exit 1;                                \
915                fi;                                      \
916              else                                       \
917                echo "speedo:";                          \
918                echo "speedo: Warning: No checksum known for $(1)";\
919                echo "speedo:";                          \
920              fi;                                        \
921              rm tmp.tgz;                                \
922            fi;                                          \
923            base=`echo "$$$${tar}" | sed -e 's,^.*/,,'   \
924                  | sed -e 's,\.tar.*$$$$,,'`;           \
925            mv $$$${base} $(1);                          \
926            patch="$(patdir)/$(1)-$$$${base#$(1)-}.patch";\
927            patchx="$(patdir)/$(1).patch";               \
928            if [ -x "$$$${patch}" ]; then                \
929              echo "speedo: applying patch $$$${patch}"; \
930              cd $(1); "$$$${patch}";                    \
931            elif [ -x "$$$${patchx}" ]; then             \
932              echo "speedo: applying patch $$$${patchx}";\
933              cd $(1); "$$$${patchx}";                   \
934            elif [ -f "$$$${patch}" ]; then              \
935              echo "speedo: warning: $$$${patch} is not executable"; \
936            fi;                                          \
937          else                                           \
938            echo "speedo: unpacking $(1) from UNKNOWN";  \
939          fi)
940         @touch $(stampdir)/stamp-$(1)-00-unpack
941
942 $(stampdir)/stamp-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack
943         @echo "speedo: configuring $(1)"
944 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
945         @echo "speedo: configure run not required"
946 else ifneq ($(findstring $(1),$(speedo_gnupg_style)),)
947         @($(call SETVARS,$(1));                         \
948          mkdir "$$$${pkgbdir}";                         \
949          cd "$$$${pkgbdir}";                            \
950          if [ -n "$(speedo_autogen_buildopt)" ]; then   \
951             eval AUTOGEN_SH_SILENT=1 w32root="$(idir)"  \
952                "$$$${pkgsdir}/autogen.sh"               \
953                $(speedo_autogen_buildopt)               \
954                $$$${pkgcfg} $$$${pkgextracflags};       \
955          else                                           \
956             eval "$$$${pkgsdir}/configure"              \
957                --silent                                 \
958                --enable-maintainer-mode                 \
959                --prefix="$(idir)"                       \
960                $$$${pkgcfg} $$$${pkgextracflags};       \
961          fi)
962 else
963         @($(call SETVARS,$(1));                         \
964          mkdir "$$$${pkgbdir}";                         \
965          cd "$$$${pkgbdir}";                            \
966          eval "$$$${pkgsdir}/configure"                 \
967              --silent $(speedo_host_build_option)       \
968              --prefix="$(idir)"                         \
969              $$$${pkgcfg}  $$$${pkgextracflags};        \
970          )
971 endif
972         @touch $(stampdir)/stamp-$(1)-01-configure
973
974 # Note that unpack has no 64 bit version becuase it is just the source.
975 # Fixme: We should use templates to create the standard and w64
976 # version of these rules.
977 $(stampdir)/stamp-w64-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack
978         @echo "speedo: configuring $(1) (64 bit)"
979 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
980         @echo "speedo: configure run not required"
981 else ifneq ($(findstring $(1),$(speedo_gnupg_style)),)
982         @($(call SETVARS_W64,$(1));                     \
983          mkdir "$$$${pkgbdir}";                         \
984          cd "$$$${pkgbdir}";                            \
985          if [ -n "$(speedo_autogen_buildopt)" ]; then   \
986             eval AUTOGEN_SH_SILENT=1 w64root="$(idir6)" \
987                "$$$${pkgsdir}/autogen.sh"               \
988                $(speedo_autogen_buildopt6)              \
989                $$$${pkgcfg} $$$${pkgextracflags};       \
990          else                                           \
991             eval "$$$${pkgsdir}/configure"              \
992                --silent                                 \
993                --enable-maintainer-mode                 \
994                --prefix="$(idir6)"                      \
995                $$$${pkgcfg} $$$${pkgextracflags};       \
996          fi)
997 else
998         @($(call SETVARS_W64,$(1));                     \
999          mkdir "$$$${pkgbdir}";                         \
1000          cd "$$$${pkgbdir}";                            \
1001          eval "$$$${pkgsdir}/configure"                 \
1002              --silent $(speedo_host_build_option6)      \
1003              --prefix="$(idir6)"                        \
1004              $$$${pkgcfg} $$$${pkgextracflags};         \
1005          )
1006 endif
1007         @touch $(stampdir)/stamp-w64-$(1)-01-configure
1008
1009
1010 $(stampdir)/stamp-$(1)-02-make: $(stampdir)/stamp-$(1)-01-configure
1011         @echo "speedo: making $(1)"
1012 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
1013         @($(call SETVARS,$(1));                         \
1014           cd "$$$${pkgsdir}";                           \
1015           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1016           if test "$$$${pkg}" = zlib -a "$(TARGETOS)" != w32 ; then \
1017             ./configure --prefix="$(idir)" ; \
1018           fi ;\
1019           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
1020 else
1021         @($(call SETVARS,$(1));                         \
1022           cd "$$$${pkgbdir}";                           \
1023           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1024           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
1025 endif
1026         @touch $(stampdir)/stamp-$(1)-02-make
1027
1028 $(stampdir)/stamp-w64-$(1)-02-make: $(stampdir)/stamp-w64-$(1)-01-configure
1029         @echo "speedo: making $(1) (64 bit)"
1030 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
1031         @($(call SETVARS_W64,$(1));                             \
1032           cd "$$$${pkgsdir}";                           \
1033           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1034           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
1035 else
1036         @($(call SETVARS_W64,$(1));                             \
1037           cd "$$$${pkgbdir}";                           \
1038           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1039           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
1040 endif
1041         @touch $(stampdir)/stamp-w64-$(1)-02-make
1042
1043 # Note that post_install must come last because it may be empty and
1044 # "; ;" is a syntax error.
1045 $(stampdir)/stamp-$(1)-03-install: $(stampdir)/stamp-$(1)-02-make
1046         @echo "speedo: installing $(1)"
1047 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
1048         @($(call SETVARS,$(1));                         \
1049           cd "$$$${pkgsdir}";                           \
1050           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1051           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install V=0;\
1052           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
1053 else
1054         @($(call SETVARS,$(1));                         \
1055           cd "$$$${pkgbdir}";                           \
1056           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1057           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install-strip V=0;\
1058           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
1059 endif
1060         touch $(stampdir)/stamp-$(1)-03-install
1061
1062 $(stampdir)/stamp-w64-$(1)-03-install: $(stampdir)/stamp-w64-$(1)-02-make
1063         @echo "speedo: installing $(1) (64 bit)"
1064 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
1065         @($(call SETVARS_W64,$(1));                             \
1066           cd "$$$${pkgsdir}";                           \
1067           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1068           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install V=0;\
1069           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
1070 else
1071         @($(call SETVARS_W64,$(1));                             \
1072           cd "$$$${pkgbdir}";                           \
1073           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1074           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install-strip V=0;\
1075           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
1076 endif
1077         touch $(stampdir)/stamp-w64-$(1)-03-install
1078
1079 $(stampdir)/stamp-final-$(1): $(stampdir)/stamp-$(1)-03-install
1080         @($(call SETVARS,$(1));                                  \
1081           printf "%-14s %-12s %s\n" $(1) "$$$${ver}" "$$$${sha1}" \
1082               >> $(bdir)/pkg-versions.txt)
1083         @echo "speedo: $(1) done"
1084         @touch $(stampdir)/stamp-final-$(1)
1085
1086 $(stampdir)/stamp-w64-final-$(1): $(stampdir)/stamp-w64-$(1)-03-install
1087         @echo "speedo: $(1) (64 bit) done"
1088         @touch $(stampdir)/stamp-w64-final-$(1)
1089
1090 .PHONY : clean-$(1)
1091 clean-$(1):
1092         @echo "speedo: uninstalling $(1)"
1093         @($(call SETVARS,$(1));                           \
1094          (cd "$$$${pkgbdir}" 2>/dev/null &&               \
1095           $(MAKE) --no-print-directory                    \
1096            $$$${pkgmkargs_uninst} uninstall V=0 ) || true;\
1097          if [ "$(1)" = "gnupg" ]; then                    \
1098            rm -fR "$$$${pkgbdir}" || true                ;\
1099          else                                             \
1100            rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}" || true;\
1101          fi)
1102         -rm -f $(stampdir)/stamp-final-$(1) $(stampdir)/stamp-$(1)-*
1103
1104
1105 .PHONY : build-$(1)
1106 build-$(1): $(stampdir)/stamp-final-$(1)
1107
1108
1109 .PHONY : report-$(1)
1110 report-$(1):
1111         @($(call SETVARS,$(1));                         \
1112          echo -n $(1):\  ;                              \
1113          if [ -n "$$$${git}" ]; then                    \
1114            if [ -e "$$$${pkgsdir}/.git" ]; then         \
1115              cd "$$$${pkgsdir}" &&                      \
1116              git describe ;                             \
1117            else                                         \
1118              echo missing;                              \
1119            fi                                           \
1120          elif [ -n "$$$${tar}" ]; then                  \
1121            base=`echo "$$$${tar}" | sed -e 's,^.*/,,'   \
1122                  | sed -e 's,\.tar.*$$$$,,'`;           \
1123            echo $$$${base} ;                            \
1124          fi)
1125
1126 endef
1127
1128
1129 # Insert the template for each source package.
1130 $(foreach spkg, $(speedo_spkgs), $(eval $(call SPKG_template,$(spkg))))
1131
1132 $(stampdir)/stamp-final: $(stampdir)/stamp-directories clean-pkg-versions
1133 ifeq ($(TARGETOS),w32)
1134 $(stampdir)/stamp-final: $(addprefix $(stampdir)/stamp-w64-final-,$(speedo_w64_build_list))
1135 endif
1136 $(stampdir)/stamp-final: $(addprefix $(stampdir)/stamp-final-,$(speedo_build_list))
1137         touch $(stampdir)/stamp-final
1138
1139 clean-pkg-versions:
1140         @: >$(bdir)/pkg-versions.txt
1141
1142 all-speedo: $(stampdir)/stamp-final
1143
1144 report-speedo: $(addprefix report-,$(speedo_build_list))
1145
1146 # Just to check if we catched all stamps.
1147 clean-stamps:
1148         $(RM) -fR $(stampdir)
1149
1150 clean-speedo:
1151         $(RM) -fR PLAY
1152
1153
1154 #
1155 # Windows installer
1156 #
1157 # {{{
1158 ifeq ($(TARGETOS),w32)
1159
1160 dist-source: installer
1161         for i in 00 01 02 03; do sleep 1;touch PLAY/stamps/stamp-*-${i}-*;done
1162         (set -e;\
1163          tarname="$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).tar" ;\
1164          [ -f "$$tarname" ] && rm "$$tarname" ;\
1165          tar -C $(topsrc) -cf "$$tarname" --exclude-backups --exclude-vcs \
1166              --transform='s,^\./,$(INST_NAME)-$(INST_VERSION)/,' \
1167              --anchored --exclude './PLAY' . ;\
1168          tar --totals -rf "$$tarname" --exclude-backups --exclude-vcs \
1169               --transform='s,^,$(INST_NAME)-$(INST_VERSION)/,' \
1170              PLAY/stamps/stamp-*-00-unpack PLAY/src swdb.lst swdb.lst.sig ;\
1171          [ -f "$$tarname".xz ] && rm "$$tarname".xz;\
1172          xz "$$tarname" ;\
1173         )
1174
1175
1176 # Extract the two latest news entries.  */
1177 $(bdir)/NEWS.tmp: $(topsrc)/NEWS
1178         awk '/^Notewo/ {if(okay>1){exit}; okay++};okay {print $0}' \
1179             <$(topsrc)/NEWS  >$(bdir)/NEWS.tmp
1180
1181 # Sort the file with the package versions.
1182 $(bdir)/pkg-versions.sorted: $(bdir)/pkg-versions.txt
1183         grep -v '^gnupg ' <$(bdir)/pkg-versions.txt \
1184             | sort | uniq >$(bdir)/pkg-versions.sorted
1185
1186 $(bdir)/README.txt: $(bdir)/NEWS.tmp $(topsrc)/README $(w32src)/README.txt \
1187                     $(w32src)/pkg-copyright.txt $(bdir)/pkg-versions.sorted
1188         sed -e '/^;.*/d;' \
1189         -e '/!NEWSFILE!/{r $(bdir)/NEWS.tmp' -e 'd;}' \
1190         -e '/!GNUPGREADME!/{r $(topsrc)/README' -e 'd;}' \
1191         -e '/!PKG-COPYRIGHT!/{r $(w32src)/pkg-copyright.txt' -e 'd;}' \
1192         -e '/!PKG-VERSIONS!/{r $(bdir)/pkg-versions.sorted' -e 'd;}' \
1193         -e 's,!VERSION!,$(INST_VERSION),g' \
1194            < $(w32src)/README.txt \
1195            | sed -e '/^#/d' \
1196            | awk '{printf "%s\r\n", $$0}' >$(bdir)/README.txt
1197
1198 $(bdir)/g4wihelp.dll: $(w32src)/g4wihelp.c $(w32src)/exdll.h
1199         (set -e; cd $(bdir); \
1200          $(W32CC) -I. -shared -O2 -o g4wihelp.dll $(w32src)/g4wihelp.c \
1201                   -lwinmm -lgdi32; \
1202          $(STRIP) g4wihelp.dll)
1203
1204 w32_insthelpers: $(bdir)/g4wihelp.dll
1205
1206 $(bdir)/inst-options.ini: $(w32src)/inst-options.ini
1207         cat $(w32src)/inst-options.ini >$(bdir)/inst-options.ini
1208
1209 extra_installer_options =
1210 ifeq ($(WITH_GUI),1)
1211 extra_installer_options += -DWITH_GUI=1
1212 endif
1213
1214 installer: all w32_insthelpers $(w32src)/inst-options.ini $(bdir)/README.txt
1215         $(MAKENSIS) -V2 \
1216                     -DINST_DIR=$(idir) \
1217                     -DINST6_DIR=$(idir6) \
1218                     -DBUILD_DIR=$(bdir) \
1219                     -DTOP_SRCDIR=$(topsrc) \
1220                     -DW32_SRCDIR=$(w32src) \
1221                     -DBUILD_ISODATE=$(BUILD_ISODATE) \
1222                     -DBUILD_DATESTR=$(BUILD_DATESTR) \
1223                     -DNAME=$(INST_NAME) \
1224                     -DVERSION=$(INST_VERSION) \
1225                     -DPROD_VERSION=$(INST_PROD_VERSION) \
1226                     $(extra_installer_options) $(w32src)/inst.nsi
1227         @echo "Ready: $(idir)/$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).exe"
1228
1229
1230 define MKSWDB_commands
1231  ( pref="#+macro: gnupg24_w32_" ;\
1232    echo "$${pref}ver  $(INST_VERSION)_$(BUILD_DATESTR)"  ;\
1233    echo "$${pref}date $(2)" ;\
1234    echo "$${pref}size $$(wc -c <$(1)|awk '{print int($$1/1024)}')k";\
1235    echo "$${pref}sha1 $$(sha1sum <$(1)|cut -d' ' -f1)" ;\
1236    echo "$${pref}sha2 $$(sha256sum <$(1)|cut -d' ' -f1)" ;\
1237  ) | tee $(1).swdb
1238 endef
1239
1240
1241 # Build the installer from the source tarball.
1242 installer-from-source: dist-source
1243         (set -e;\
1244          [ -d PLAY-release ] && rm -rf PLAY-release; \
1245          mkdir PLAY-release;\
1246          cd PLAY-release; \
1247          tar xJf "../$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).tar.xz";\
1248          cd $(INST_NAME)-$(INST_VERSION); \
1249          $(MAKE) -f build-aux/speedo.mk this-w32-installer SELFCHECK=0;\
1250          reldate="$$(date -u +%Y-%m-%d)" ;\
1251          exefile="$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).exe" ;\
1252          cp "PLAY/inst/$$exefile" ../.. ;\
1253          exefile="../../$$exefile" ;\
1254          $(call MKSWDB_commands,$${exefile},$${reldate}); \
1255         )
1256
1257 # This target repeats some of the installer-from-source steps but it
1258 # is intended to be called interactively, so that the passphrase can be
1259 # entered.
1260 sign-installer:
1261         @(set -e; \
1262          cd PLAY-release; \
1263          cd $(INST_NAME)-$(INST_VERSION); \
1264          reldate="$$(date -u +%Y-%m-%d)" ;\
1265          exefile="$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).exe" ;\
1266          echo "speedo: /*" ;\
1267          echo "speedo:  * Signing installer" ;\
1268          echo "speedo:  * Key: $(AUTHENTICODE_KEY)";\
1269          echo "speedo:  */" ;\
1270          osslsigncode sign -certs $(AUTHENTICODE_CERTS)\
1271             -pkcs12 $(AUTHENTICODE_KEY) -askpass \
1272             -ts "http://timestamp.globalsign.com/scripts/timstamp.dll" \
1273             -h sha256 -n GnuPG -i https://gnupg.org \
1274             -in "PLAY/inst/$$exefile" -out "../../$$exefile" ;\
1275          exefile="../../$$exefile" ;\
1276          $(call MKSWDB_commands,$${exefile},$${reldate}); \
1277          echo "speedo: /*" ;\
1278          echo "speedo:  * Verification result" ;\
1279          echo "speedo:  */" ;\
1280          osslsigncode verify $${exefile} \
1281         )
1282
1283
1284
1285 endif
1286 # }}} W32
1287
1288
1289 #
1290 # Check availibility of standard tools
1291 #
1292 check-tools:
1293
1294
1295 #
1296 # Mark phony targets
1297 #
1298 .PHONY: all all-speedo report-speedo clean-stamps clean-speedo installer \
1299         w32_insthelpers check-tools clean-pkg-versions