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