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