agent: Clean up pinentry access locking.
[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 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         sha2="$(call GETVAR,$(1)_sha2)";                                \
761         sha1="$(call GETVAR,$(1)_sha1)";                                \
762         pkgsdir="$(sdir)/$(1)";                                         \
763         if [ "$(1)" = "gnupg" ]; then                                   \
764           git='';                                                       \
765           gitref='';                                                    \
766           tar='';                                                       \
767           pkgsdir="$(topsrc)";                                          \
768         fi;                                                             \
769         pkgbdir="$(bdir)/$(1)";                                         \
770         pkgcfg="$(call GETVAR,speedo_pkg_$(1)_configure)";              \
771         tmp="$(speedo_w32_cflags)                                       \
772              $(call GETVAR,speedo_pkg_$(1)_extracflags)";               \
773         if [ x$$$$(echo "$$$$tmp" | tr -d '[:space:]')x != xx ]; then   \
774           pkgextracflags="CFLAGS=\"$$$$tmp\"";                          \
775         else                                                            \
776           pkgextracflags=;                                              \
777         fi;                                                             \
778         pkgmkdir="$(call GETVAR,speedo_pkg_$(1)_make_dir)";             \
779         pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)";           \
780         pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \
781         pkgmkargs_uninst="$(call GETVAR,speedo_pkg_$(1)_make_args_uninst)"; \
782         export PKG_CONFIG="/usr/bin/pkg-config";                        \
783         export PKG_CONFIG_PATH="$(idir)/lib/pkgconfig";                 \
784         [ "$(TARGETOS)" != native ] && export PKG_CONFIG_LIBDIR="";     \
785         export SYSROOT="$(idir)";                                       \
786         export PATH="$(idir)/bin:$${PATH}";                             \
787         export LD_LIBRARY_PATH="$(idir)/lib:$${LD_LIBRARY_PATH}"
788 endef
789
790 define SETVARS_W64
791         pkg="$(1)";                                                     \
792         git="$(call GETVAR,speedo_pkg_$(1)_git)";                       \
793         gitref="$(call GETVAR,speedo_pkg_$(1)_gitref)";                 \
794         tar="$(call GETVAR,speedo_pkg_$(1)_tar)";                       \
795         sha2="$(call GETVAR,$(1)_sha2)";                                \
796         sha1="$(call GETVAR,$(1)_sha1)";                                \
797         pkgsdir="$(sdir)/$(1)";                                         \
798         if [ "$(1)" = "gnupg" ]; then                                   \
799           git='';                                                       \
800           gitref='';                                                    \
801           tar='';                                                       \
802           pkgsdir="$(topsrc)";                                          \
803         fi;                                                             \
804         pkgbdir="$(bdir6)/$(1)";                                        \
805         pkgcfg="$(call GETVAR,speedo_pkg_w64_$(1)_configure)";          \
806         tmp="$(speedo_w32_cflags)                                       \
807              $(call GETVAR,speedo_pkg_$(1)_extracflags)";               \
808         if [ x$$$$(echo "$$$$tmp" | tr -d '[:space:]')x != xx ]; then   \
809           pkgextracflags="CFLAGS=\"$$$$tmp\"";                          \
810         else                                                            \
811           pkgextracflags=;                                              \
812         fi;                                                             \
813         pkgmkdir="$(call GETVAR,speedo_pkg_$(1)_make_dir)";             \
814         pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)";           \
815         pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \
816         pkgmkargs_uninst="$(call GETVAR,speedo_pkg_$(1)_make_args_uninst)"; \
817         export PKG_CONFIG="/usr/bin/pkg-config";                        \
818         export PKG_CONFIG_PATH="$(idir6)/lib/pkgconfig";                \
819         [ "$(TARGETOS)" != native ] && export PKG_CONFIG_LIBDIR="";     \
820         export SYSROOT="$(idir6)";                                      \
821         export PATH="$(idir6)/bin:$${PATH}";                            \
822         export LD_LIBRARY_PATH="$(idir6)/lib:$${LD_LIBRARY_PATH}"
823 endef
824
825
826 # Template for source packages.
827
828 # Note that the gnupg package is special: The package source dir is
829 # the same as the topsrc dir and thus we need to detect the gnupg
830 # package and cd to that directory.  We also test that no in-source build
831 # has been done.  autogen.sh is not run for gnupg.
832 #
833 define SPKG_template
834
835 $(stampdir)/stamp-$(1)-00-unpack: $(stampdir)/stamp-directories
836         @echo "speedo: /*"
837         @echo "speedo:  *   $(1)"
838         @echo "speedo:  */"
839         @(set -e; cd $(sdir);                           \
840          $(call SETVARS,$(1));                          \
841          if [ "$(WHAT)" = "this" ]; then                \
842            echo "speedo: using included source";        \
843          elif [ "$(1)" = "gnupg" ]; then                \
844            cd $$$${pkgsdir};                            \
845            if [ -f config.log ]; then                   \
846              echo "GnuPG has already been build in-source" >&2  ;\
847              echo "Please run \"make distclean\" and retry" >&2 ;\
848              exit 1 ;                                   \
849            fi;                                          \
850            echo "speedo: unpacking gnupg not needed";   \
851          elif [ -n "$$$${git}" ]; then                  \
852            echo "speedo: unpacking $(1) from $$$${git}:$$$${gitref}"; \
853            git clone -b "$$$${gitref}" "$$$${git}" "$$$${pkg}"; \
854            cd "$$$${pkg}";                              \
855            AUTOGEN_SH_SILENT=1 ./autogen.sh;            \
856          elif [ -n "$$$${tar}" ]; then                  \
857            echo "speedo: unpacking $(1) from $$$${tar}"; \
858            case "$$$${tar}" in                          \
859              *.gz) pretar=zcat ;;                       \
860              *.bz2) pretar=bzcat ;;                     \
861              *.xz) pretar=xzcat ;;                      \
862              *) pretar=cat ;;                           \
863            esac;                                        \
864            [ -f tmp.tgz ] && rm tmp.tgz;                \
865            case "$$$${tar}" in                          \
866              /*) $$$${pretar} < $$$${tar} | tar xf - ;; \
867              *)  wget -q -O - $$$${tar} | tee tmp.tgz   \
868                   | $$$${pretar} | tar x$$$${opt}f - ;; \
869            esac;                                        \
870            if [ -f tmp.tgz ]; then                      \
871              if [ -n "$$$${sha2}" ]; then               \
872                tmp=$$$$($(SHA2SUM) <tmp.tgz|cut -d' ' -f1);\
873                if [ "$$$${tmp}" != "$$$${sha2}" ]; then \
874                  echo "speedo:";                        \
875                  echo "speedo: ERROR: SHA-256 checksum mismatch for $(1)";\
876                  echo "speedo:";                        \
877                  exit 1;                                \
878                fi;                                      \
879              elif [ -n "$$$${sha1}" ]; then            \
880                tmp=$$$$($(SHA1SUM) <tmp.tgz|cut -d' ' -f1);\
881                if [ "$$$${tmp}" != "$$$${sha1}" ]; then \
882                  echo "speedo:";                        \
883                  echo "speedo: ERROR: SHA-1 checksum mismatch for $(1)";\
884                  echo "speedo:";                        \
885                  exit 1;                                \
886                fi;                                      \
887              else                                       \
888                echo "speedo:";                          \
889                echo "speedo: Warning: No checksum known for $(1)";\
890                echo "speedo:";                          \
891              fi;                                        \
892              rm tmp.tgz;                                \
893            fi;                                          \
894            base=`echo "$$$${tar}" | sed -e 's,^.*/,,'   \
895                  | sed -e 's,\.tar.*$$$$,,'`;           \
896            mv $$$${base} $(1);                          \
897            patch="$(patdir)/$(1)-$$$${base#$(1)-}.patch";\
898            patchx="$(patdir)/$(1).patch";               \
899            if [ -x "$$$${patch}" ]; then                \
900              echo "speedo: applying patch $$$${patch}"; \
901              cd $(1); "$$$${patch}";                    \
902            elif [ -x "$$$${patchx}" ]; then             \
903              echo "speedo: applying patch $$$${patchx}";\
904              cd $(1); "$$$${patchx}";                   \
905            elif [ -f "$$$${patch}" ]; then              \
906              echo "speedo: warning: $$$${patch} is not executable"; \
907            fi;                                          \
908          else                                           \
909            echo "speedo: unpacking $(1) from UNKNOWN";  \
910          fi)
911         @touch $(stampdir)/stamp-$(1)-00-unpack
912
913 $(stampdir)/stamp-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack
914         @echo "speedo: configuring $(1)"
915 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
916         @echo "speedo: configure run not required"
917 else ifneq ($(findstring $(1),$(speedo_gnupg_style)),)
918         @($(call SETVARS,$(1));                         \
919          mkdir "$$$${pkgbdir}";                         \
920          cd "$$$${pkgbdir}";                            \
921          if [ -n "$(speedo_autogen_buildopt)" ]; then   \
922             eval AUTOGEN_SH_SILENT=1 w32root="$(idir)"  \
923                "$$$${pkgsdir}/autogen.sh"               \
924                $(speedo_autogen_buildopt)               \
925                $$$${pkgcfg} $$$${pkgextracflags};       \
926          else                                           \
927             eval "$$$${pkgsdir}/configure"              \
928                --silent                                 \
929                --enable-maintainer-mode                 \
930                --prefix="$(idir)"                       \
931                $$$${pkgcfg} $$$${pkgextracflags};       \
932          fi)
933 else
934         @($(call SETVARS,$(1));                         \
935          mkdir "$$$${pkgbdir}";                         \
936          cd "$$$${pkgbdir}";                            \
937          eval "$$$${pkgsdir}/configure"                 \
938              --silent $(speedo_host_build_option)       \
939              --prefix="$(idir)"                         \
940              $$$${pkgcfg}  $$$${pkgextracflags};        \
941          )
942 endif
943         @touch $(stampdir)/stamp-$(1)-01-configure
944
945 # Note that unpack has no 64 bit version becuase it is just the source.
946 # Fixme: We should use templates to create the standard and w64
947 # version of these rules.
948 $(stampdir)/stamp-w64-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack
949         @echo "speedo: configuring $(1) (64 bit)"
950 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
951         @echo "speedo: configure run not required"
952 else ifneq ($(findstring $(1),$(speedo_gnupg_style)),)
953         @($(call SETVARS_W64,$(1));                     \
954          mkdir "$$$${pkgbdir}";                         \
955          cd "$$$${pkgbdir}";                            \
956          if [ -n "$(speedo_autogen_buildopt)" ]; then   \
957             eval AUTOGEN_SH_SILENT=1 w64root="$(idir6)" \
958                "$$$${pkgsdir}/autogen.sh"               \
959                $(speedo_autogen_buildopt6)              \
960                $$$${pkgcfg} $$$${pkgextracflags};       \
961          else                                           \
962             eval "$$$${pkgsdir}/configure"              \
963                --silent                                 \
964                --enable-maintainer-mode                 \
965                --prefix="$(idir6)"                      \
966                $$$${pkgcfg} $$$${pkgextracflags};       \
967          fi)
968 else
969         @($(call SETVARS_W64,$(1));                     \
970          mkdir "$$$${pkgbdir}";                         \
971          cd "$$$${pkgbdir}";                            \
972          eval "$$$${pkgsdir}/configure"                 \
973              --silent $(speedo_host_build_option6)      \
974              --prefix="$(idir6)"                        \
975              $$$${pkgcfg} $$$${pkgextracflags};         \
976          )
977 endif
978         @touch $(stampdir)/stamp-w64-$(1)-01-configure
979
980
981 $(stampdir)/stamp-$(1)-02-make: $(stampdir)/stamp-$(1)-01-configure
982         @echo "speedo: making $(1)"
983 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
984         @($(call SETVARS,$(1));                         \
985           cd "$$$${pkgsdir}";                           \
986           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
987           if test "$$$${pkg}" = zlib -a "$(TARGETOS)" != w32 ; then \
988             ./configure --prefix="$(idir)" ; \
989           fi ;\
990           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
991 else
992         @($(call SETVARS,$(1));                         \
993           cd "$$$${pkgbdir}";                           \
994           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
995           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
996 endif
997         @touch $(stampdir)/stamp-$(1)-02-make
998
999 $(stampdir)/stamp-w64-$(1)-02-make: $(stampdir)/stamp-w64-$(1)-01-configure
1000         @echo "speedo: making $(1) (64 bit)"
1001 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
1002         @($(call SETVARS_W64,$(1));                             \
1003           cd "$$$${pkgsdir}";                           \
1004           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1005           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
1006 else
1007         @($(call SETVARS_W64,$(1));                             \
1008           cd "$$$${pkgbdir}";                           \
1009           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1010           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
1011 endif
1012         @touch $(stampdir)/stamp-w64-$(1)-02-make
1013
1014 # Note that post_install must come last because it may be empty and
1015 # "; ;" is a syntax error.
1016 $(stampdir)/stamp-$(1)-03-install: $(stampdir)/stamp-$(1)-02-make
1017         @echo "speedo: installing $(1)"
1018 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
1019         @($(call SETVARS,$(1));                         \
1020           cd "$$$${pkgsdir}";                           \
1021           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1022           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install V=0;\
1023           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
1024 else
1025         @($(call SETVARS,$(1));                         \
1026           cd "$$$${pkgbdir}";                           \
1027           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1028           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install-strip V=0;\
1029           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
1030 endif
1031         touch $(stampdir)/stamp-$(1)-03-install
1032
1033 $(stampdir)/stamp-w64-$(1)-03-install: $(stampdir)/stamp-w64-$(1)-02-make
1034         @echo "speedo: installing $(1) (64 bit)"
1035 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
1036         @($(call SETVARS_W64,$(1));                             \
1037           cd "$$$${pkgsdir}";                           \
1038           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1039           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install V=0;\
1040           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
1041 else
1042         @($(call SETVARS_W64,$(1));                             \
1043           cd "$$$${pkgbdir}";                           \
1044           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
1045           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install-strip V=0;\
1046           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
1047 endif
1048         touch $(stampdir)/stamp-w64-$(1)-03-install
1049
1050 $(stampdir)/stamp-final-$(1): $(stampdir)/stamp-$(1)-03-install
1051         @echo "speedo: $(1) done"
1052         @touch $(stampdir)/stamp-final-$(1)
1053
1054 $(stampdir)/stamp-w64-final-$(1): $(stampdir)/stamp-w64-$(1)-03-install
1055         @echo "speedo: $(1) (64 bit) done"
1056         @touch $(stampdir)/stamp-w64-final-$(1)
1057
1058 .PHONY : clean-$(1)
1059 clean-$(1):
1060         @echo "speedo: uninstalling $(1)"
1061         @($(call SETVARS,$(1));                           \
1062          (cd "$$$${pkgbdir}" 2>/dev/null &&               \
1063           $(MAKE) --no-print-directory                    \
1064            $$$${pkgmkargs_uninst} uninstall V=0 ) || true;\
1065          if [ "$(1)" = "gnupg" ]; then                    \
1066            rm -fR "$$$${pkgbdir}" || true                ;\
1067          else                                             \
1068            rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}" || true;\
1069          fi)
1070         -rm -f $(stampdir)/stamp-final-$(1) $(stampdir)/stamp-$(1)-*
1071
1072
1073 .PHONY : build-$(1)
1074 build-$(1): $(stampdir)/stamp-final-$(1)
1075
1076
1077 .PHONY : report-$(1)
1078 report-$(1):
1079         @($(call SETVARS,$(1));                         \
1080          echo -n $(1):\  ;                              \
1081          if [ -n "$$$${git}" ]; then                    \
1082            if [ -e "$$$${pkgsdir}/.git" ]; then         \
1083              cd "$$$${pkgsdir}" &&                      \
1084              git describe ;                             \
1085            else                                         \
1086              echo missing;                              \
1087            fi                                           \
1088          elif [ -n "$$$${tar}" ]; then                  \
1089            base=`echo "$$$${tar}" | sed -e 's,^.*/,,'   \
1090                  | sed -e 's,\.tar.*$$$$,,'`;           \
1091            echo $$$${base} ;                            \
1092          fi)
1093
1094 endef
1095
1096
1097 # Insert the template for each source package.
1098 $(foreach spkg, $(speedo_spkgs), $(eval $(call SPKG_template,$(spkg))))
1099
1100 $(stampdir)/stamp-final: $(stampdir)/stamp-directories
1101 ifeq ($(TARGETOS),w32)
1102 $(stampdir)/stamp-final: $(addprefix $(stampdir)/stamp-w64-final-,$(speedo_w64_build_list))
1103 endif
1104 $(stampdir)/stamp-final: $(addprefix $(stampdir)/stamp-final-,$(speedo_build_list))
1105         touch $(stampdir)/stamp-final
1106
1107 all-speedo: $(stampdir)/stamp-final
1108
1109 report-speedo: $(addprefix report-,$(speedo_build_list))
1110
1111 # Just to check if we catched all stamps.
1112 clean-stamps:
1113         $(RM) -fR $(stampdir)
1114
1115 clean-speedo:
1116         $(RM) -fR PLAY
1117
1118
1119 #
1120 # Windows installer
1121 #
1122 # {{{
1123 ifeq ($(TARGETOS),w32)
1124
1125 dist-source: installer
1126         for i in 00 01 02 03; do sleep 1;touch PLAY/stamps/stamp-*-${i}-*;done
1127         (set -e;\
1128          tarname="$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).tar" ;\
1129          [ -f "$$tarname" ] && rm "$$tarname" ;\
1130          tar -C $(topsrc) -cf "$$tarname" --exclude-backups --exclude-vcs \
1131              --transform='s,^\./,$(INST_NAME)-$(INST_VERSION)/,' \
1132              --anchored --exclude './PLAY' . ;\
1133          tar --totals -rf "$$tarname" --exclude-backups --exclude-vcs \
1134               --transform='s,^,$(INST_NAME)-$(INST_VERSION)/,' \
1135              PLAY/stamps/stamp-*-00-unpack PLAY/src swdb.lst swdb.lst.sig ;\
1136          [ -f "$$tarname".xz ] && rm "$$tarname".xz;\
1137          xz "$$tarname" ;\
1138         )
1139
1140
1141 # Extract the two latest news entries.  */
1142 $(bdir)/NEWS.tmp: $(topsrc)/NEWS
1143         awk '/^Notewo/ {if(okay>1){exit}; okay++};okay {print $0}' \
1144             <$(topsrc)/NEWS  >$(bdir)/NEWS.tmp
1145
1146 $(bdir)/README.txt: $(bdir)/NEWS.tmp $(topsrc)/README $(w32src)/README.txt \
1147                     $(w32src)/pkg-copyright.txt
1148         sed -e '/^;.*/d;' \
1149         -e '/!NEWSFILE!/{r $(bdir)/NEWS.tmp' -e 'd;}' \
1150         -e '/!GNUPGREADME!/{r $(topsrc)/README' -e 'd;}' \
1151         -e '/!PKG-COPYRIGHT!/{r $(w32src)/pkg-copyright.txt' -e 'd;}' \
1152         -e 's,!VERSION!,$(INST_VERSION),g' \
1153            < $(w32src)/README.txt \
1154            | sed -e '/^#/d' \
1155            | awk '{printf "%s\r\n", $$0}' >$(bdir)/README.txt
1156
1157 $(bdir)/g4wihelp.dll: $(w32src)/g4wihelp.c $(w32src)/exdll.h
1158         (set -e; cd $(bdir); \
1159          $(W32CC) -I. -shared -O2 -o g4wihelp.dll $(w32src)/g4wihelp.c \
1160                   -lwinmm -lgdi32; \
1161          $(STRIP) g4wihelp.dll)
1162
1163 w32_insthelpers: $(bdir)/g4wihelp.dll
1164
1165 $(bdir)/inst-options.ini: $(w32src)/inst-options.ini
1166         cat $(w32src)/inst-options.ini >$(bdir)/inst-options.ini
1167
1168 extra_installer_options =
1169 ifeq ($(WITH_GUI),1)
1170 extra_installer_options += -DWITH_GUI=1
1171 endif
1172
1173 installer: all w32_insthelpers $(w32src)/inst-options.ini $(bdir)/README.txt
1174         $(MAKENSIS) -V2 \
1175                     -DINST_DIR=$(idir) \
1176                     -DINST6_DIR=$(idir6) \
1177                     -DBUILD_DIR=$(bdir) \
1178                     -DTOP_SRCDIR=$(topsrc) \
1179                     -DW32_SRCDIR=$(w32src) \
1180                     -DBUILD_ISODATE=$(BUILD_ISODATE) \
1181                     -DBUILD_DATESTR=$(BUILD_DATESTR) \
1182                     -DNAME=$(INST_NAME) \
1183                     -DVERSION=$(INST_VERSION) \
1184                     -DPROD_VERSION=$(INST_PROD_VERSION) \
1185                     $(extra_installer_options) $(w32src)/inst.nsi
1186         @echo "Ready: $(idir)/$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).exe"
1187
1188
1189 define MKSWDB_commands
1190  ( pref="#+macro: gnupg22_w32_" ;\
1191    echo "$${pref}ver  $(INST_VERSION)_$(BUILD_DATESTR)"  ;\
1192    echo "$${pref}date $(2)" ;\
1193    echo "$${pref}size $$(wc -c <$(1)|awk '{print int($$1/1024)}')k";\
1194    echo "$${pref}sha1 $$(sha1sum <$(1)|cut -d' ' -f1)" ;\
1195    echo "$${pref}sha2 $$(sha256sum <$(1)|cut -d' ' -f1)" ;\
1196  ) | tee $(1).swdb
1197 endef
1198
1199
1200 # Build the installer from the source tarball.
1201 installer-from-source: dist-source
1202         (set -e;\
1203          [ -d PLAY-release ] && rm -rf PLAY-release; \
1204          mkdir PLAY-release;\
1205          cd PLAY-release; \
1206          tar xJf "../$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).tar.xz";\
1207          cd $(INST_NAME)-$(INST_VERSION); \
1208          $(MAKE) -f build-aux/speedo.mk this-w32-installer SELFCHECK=0;\
1209          reldate="$$(date -u +%Y-%m-%d)" ;\
1210          exefile="$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).exe" ;\
1211          cp "PLAY/inst/$$exefile" ../.. ;\
1212          exefile="../../$$exefile" ;\
1213          $(call MKSWDB_commands,$${exefile},$${reldate}); \
1214         )
1215
1216 # This target repeats some of the installer-from-source steps but it
1217 # is intended to be called interactively, so that the passphrase can be
1218 # entered.
1219 sign-installer:
1220         @(set -e; \
1221          cd PLAY-release; \
1222          cd $(INST_NAME)-$(INST_VERSION); \
1223          reldate="$$(date -u +%Y-%m-%d)" ;\
1224          exefile="$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).exe" ;\
1225          echo "speedo: /*" ;\
1226          echo "speedo:  * Signing installer" ;\
1227          echo "speedo:  * Key: $(AUTHENTICODE_KEY)";\
1228          echo "speedo:  */" ;\
1229          osslsigncode sign -pkcs12 $(AUTHENTICODE_KEY) -askpass \
1230             -h sha256 -in "PLAY/inst/$$exefile" -out "../../$$exefile" ;\
1231          exefile="../../$$exefile" ;\
1232          $(call MKSWDB_commands,$${exefile},$${reldate}); \
1233          echo "speedo: /*" ;\
1234          echo "speedo:  * Verification result" ;\
1235          echo "speedo:  */" ;\
1236          osslsigncode verify $${exefile} \
1237         )
1238
1239
1240
1241 endif
1242 # }}} W32
1243
1244
1245 #
1246 # Check availibility of standard tools
1247 #
1248 check-tools:
1249
1250
1251 #
1252 # Mark phony targets
1253 #
1254 .PHONY: all all-speedo report-speedo clean-stamps clean-speedo installer \
1255         w32_insthelpers check-tools