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