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