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