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