speedo: Get version numbers from online database.
[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
49 # Set this to "git" to build from git,
50 #          to "release" from tarballs,
51 #          to "this" from the unpacked sources.
52 WHAT=git
53
54 # Set target to "native" or "w32"
55 TARGETOS=w32
56
57 # Set to the location of the directory with tarballs of
58 # external packages.
59 TARBALLS=$(shell pwd)/../tarballs
60
61 #  Number of parallel make jobs
62 MAKE_J=3
63
64 # Name to use for the w32 installer and sources
65 INST_NAME=gnupg-w32
66
67
68 # Directory names.
69 # They must be absolute, as we switch directories pretty often.
70 root := $(shell pwd)/PLAY
71 sdir := $(root)/src
72 bdir := $(root)/build
73 bdir6:= $(root)/build-w64
74 idir := $(root)/inst
75 idir6:= $(root)/inst-w64
76 stampdir := $(root)/stamps
77 topsrc := $(shell cd $(dir $(SPEEDO_MK)).. && pwd)
78 auxsrc := $(topsrc)/build-aux/speedo
79 patdir := $(topsrc)/build-aux/speedo/patches
80 w32src := $(topsrc)/build-aux/speedo/w32
81
82 # =====BEGIN LIST OF PACKAGES=====
83 # The packages that should be built.  The order is also the build order.
84 # Fixme: Do we need to build pkg-config for cross-building?
85
86 speedo_spkgs  = \
87         libgpg-error npth libgcrypt
88
89 ifeq ($(TARGETOS),w32)
90 speedo_spkgs += \
91         zlib libiconv gettext
92 endif
93
94 speedo_spkgs += \
95         libassuan libksba gnupg
96
97 ifeq ($(TARGETOS),w32)
98 speedo_spkgs += \
99         libffi glib pkg-config
100 endif
101
102 speedo_spkgs += \
103         gpgme
104
105 ifeq ($(TARGETOS),w32)
106 speedo_spkgs += \
107         libpng \
108         gdk-pixbuf atk pixman cairo pango gtk+
109 endif
110
111 speedo_spkgs += \
112         pinentry gpa
113
114 ifeq ($(TARGETOS),w32)
115 speedo_spkgs += \
116         gpgex
117 endif
118
119 # =====END LIST OF PACKAGES=====
120
121
122 # Packages which are additionally build for 64 bit Windows
123 speedo_w64_spkgs  = \
124         libgpg-error libiconv gettext libassuan gpgex
125
126 # Packages which use the gnupg autogen.sh build style
127 speedo_gnupg_style = \
128         libgpg-error npth libgcrypt  \
129         libassuan libksba gnupg gpgme \
130         pinentry gpa gpgex
131
132 # Packages which use only make and no build directory
133 speedo_make_only_style = \
134         zlib
135
136 # Get the content of the software DB.
137 SWDB := $(shell $(topsrc)/build-aux/getswdb.sh && echo okay)
138 ifeq ($(strip $(SWDB)),)
139 $(error Error getting GnuPG software version database)
140 endif
141
142 # Version numbers of the released packages
143 gnupg_ver = $(shell cat $(topsrc)/VERSION)
144 libgpg_error_ver = $(shell awk '$$1=="libgpg_error_ver" {print $$2}' swdb.lst)
145 npth_ver = $(shell awk '$$1=="npth_ver" {print $$2}' swdb.lst)
146 libgcrypt_ver = $(shell awk '$$1=="libgcrypt_ver" {print $$2}' swdb.lst)
147 libassuan_ver = $(shell awk '$$1=="libassuan_ver" {print $$2}' swdb.lst)
148 libksba_ver = $(shell awk '$$1=="libksba_ver" {print $$2}' swdb.lst)
149 gpgme_ver = $(shell awk '$$1=="gpgme_ver" {print $$2}' swdb.lst)
150 pinentry_ver = $(shell awk '$$1=="pinentry_ver" {print $$2}' swdb.lst)
151 gpa_ver = $(shell awk '$$1=="gpa_ver" {print $$2}' swdb.lst)
152 gpgex_ver = $(shell awk '$$1=="gpgex_ver" {print $$2}' swdb.lst)
153
154 $(info Information from the version database)
155 $(info GnuPG ..........: $(gnupg_ver))
156 $(info Libgpg-error ...: $(libgpg_error_ver))
157 $(info Npth ...........: $(npth_ver))
158 $(info Libgcrypt ......: $(libgcrypt_ver))
159 $(info Libassuan ......: $(libassuan_ver))
160 $(info GPGME ..........: $(gpgme_ver))
161 $(info Pinentry .......: $(pinentry_ver))
162 $(info GPA ............: $(gpa_ver))
163 $(info GpgEX.... ......: $(gpgex_ver))
164
165
166 # Version number for external packages
167 pkg_config_ver = 0.23
168 zlib_ver = 1.2.8
169 libiconv_ver = 1.14
170 gettext_ver = 0.18.2.1
171 libffi_ver = 3.0.13
172 glib_ver = 2.34.3
173 libpng_ver = 1.4.12
174 gdk_pixbuf_ver = 2.26.5
175 atk_ver = 1.32.0
176 pango_ver = 1.29.4
177 pixman_ver = 0.32.4
178 cairo_ver = 1.12.16
179 gtk__ver = 2.24.17
180
181
182 # The GIT repository.  Using a local repo is much faster.
183 #gitrep = git://git.gnupg.org
184 gitrep = ${HOME}/s
185
186 # The tarball directories
187 pkgrep = ftp://ftp.gnupg.org/gcrypt
188 pkg2rep = $(TARBALLS)
189
190 # For each package, the following variables can be defined:
191 #
192 # speedo_pkg_PACKAGE_git: The GIT repository that should be built.
193 # speedo_pkg_PACKAGE_gitref: The GIT revision to checkout
194 #
195 # speedo_pkg_PACKAGE_tar: URL to the tar file that should be built.
196 #
197 # Exactly one of the above variables is required.  Note that this
198 # version of speedo does not cache repositories or tar files, and does
199 # not test the integrity of the downloaded software.  If you care
200 # about this, you can also specify filenames to locally verified files.
201 # Filenames are differentiated from URLs by starting with a slash '/'.
202 #
203 # speedo_pkg_PACKAGE_configure: Extra arguments to configure.
204 #
205 # speedo_pkg_PACKAGE_make_args: Extra arguments to make.
206 #
207 # speedo_pkg_PACKAGE_make_args_inst: Extra arguments to make install.
208 #
209 # Note that you can override the defaults in this file in a local file
210 # "config.mk"
211
212 ifeq ($(WHAT),this)
213 else ifeq ($(WHAT),git)
214   speedo_pkg_libgpg_error_git = $(gitrep)/libgpg-error
215   speedo_pkg_libgpg_error_gitref = master
216   speedo_pkg_npth_git = $(gitrep)/npth
217   speedo_pkg_npth_gitref = master
218   speedo_pkg_libassuan_git = $(gitrep)/libassuan
219   speedo_pkg_libassuan_gitref = master
220   speedo_pkg_libgcrypt_git = $(gitrep)/libgcrypt
221   speedo_pkg_libgcrypt_gitref = LIBGCRYPT-1-6-BRANCH
222   speedo_pkg_libksba_git = $(gitrep)/libksba
223   speedo_pkg_libksba_gitref = master
224   speedo_pkg_gpgme_git = $(gitrep)/gpgme
225   speedo_pkg_gpgme_gitref = master
226   speedo_pkg_pinentry_git = $(gitrep)/pinentry
227   speedo_pkg_pinentry_gitref = master
228   speedo_pkg_gpa_git = $(gitrep)/gpa
229   speedo_pkg_gpa_gitref = master
230   speedo_pkg_gpgex_git = $(gitrep)/gpgex
231   speedo_pkg_gpgex_gitref = master
232 else ifeq ($(WHAT),release)
233   speedo_pkg_libgpg_error_tar = \
234         $(pkgrep)/libgpg-error/libgpg-error-$(libgpg_error_ver).tar.bz2
235   speedo_pkg_npth_tar = \
236         $(pkgrep)/npth/npth-$(npth_ver).tar.bz2
237   speedo_pkg_libassuan_tar = \
238         $(pkgrep)/libassuan/libassuan-$(libassuan_ver).tar.bz2
239   speedo_pkg_libgcrypt_tar = \
240         $(pkgrep)/libgcrypt/libgcrypt-$(libgcrypt_ver).tar.bz2
241   speedo_pkg_libksba_tar = \
242         $(pkgrep)/libksba/libksba-$(libksba_ver).tar.bz2
243   speedo_pkg_gpgme_tar = \
244         $(pkgrep)/gpgme/gpgme-$(gpgme_ver).tar.bz2
245   speedo_pkg_pinentry_tar = \
246         $(pkgrep)/pinentry/pinentry-$(pinentry_ver).tar.bz2
247   speedo_pkg_gpa_tar = \
248         $(pkgrep)/gpa/gpa-$(gpa_ver).tar.bz2
249   speedo_pkg_gpgex_tar = \
250         $(pkgrep)/gpex/gpgex-$(gpa_ver).tar.bz2
251 else
252   $(error invalid value for WHAT (use on of: git release this))
253 endif
254
255 speedo_pkg_pkg_config_tar = $(pkg2rep)/pkg-config-$(pkg_config_ver).tar.gz
256 speedo_pkg_zlib_tar       = $(pkg2rep)/zlib-$(zlib_ver).tar.gz
257 speedo_pkg_libiconv_tar   = $(pkg2rep)/libiconv-$(libiconv_ver).tar.gz
258 speedo_pkg_gettext_tar    = $(pkg2rep)/gettext-$(gettext_ver).tar.gz
259 speedo_pkg_libffi_tar     = $(pkg2rep)/libffi-$(libffi_ver).tar.gz
260 speedo_pkg_glib_tar       = $(pkg2rep)/glib-$(glib_ver).tar.xz
261 speedo_pkg_libpng_tar     = $(pkg2rep)/libpng-$(libpng_ver).tar.bz2
262 speedo_pkg_gdk_pixbuf_tar = $(pkg2rep)/gdk-pixbuf-$(gdk_pixbuf_ver).tar.xz
263 speedo_pkg_atk_tar        = $(pkg2rep)/atk-$(atk_ver).tar.bz2
264 speedo_pkg_pango_tar      = $(pkg2rep)/pango-$(pango_ver).tar.bz2
265 speedo_pkg_pixman_tar     = $(pkg2rep)/pixman-$(pixman_ver).tar.gz
266 speedo_pkg_cairo_tar      = $(pkg2rep)/cairo-$(cairo_ver).tar.xz
267 speedo_pkg_gtk__tar       = $(pkg2rep)/gtk+-$(gtk__ver).tar.xz
268
269
270 #
271 # Package build options
272 #
273
274 speedo_pkg_libgpg_error_configure = --enable-static
275 speedo_pkg_w64_libgpg_error_configure = --enable-static
276
277 speedo_pkg_libassuan_configure = --enable-static
278 speedo_pkg_w64_libassuan_configure = --enable-static
279
280 speedo_pkg_libgcrypt_configure = --disable-static
281
282 speedo_pkg_libksba_configure = --disable-static
283
284 speedo_pkg_gnupg_configure = --enable-gpg2-is-gpg --disable-g13
285 speedo_pkg_gnupg_extracflags = -g
286
287 define speedo_pkg_gnupg_post_install
288 (set -e; \
289  sed -n  's/.*PACKAGE_VERSION "\(.*\)"/\1/p' config.h >$(idir)/INST_VERSION; \
290  sed -n  's/.*W32INFO_VI_PRODUCTVERSION \(.*\)/\1/p' common/w32info-rc.h \
291     |sed 's/,/./g' >$(idir)/INST_PROD_VERSION )
292 endef
293
294
295 # The LDFLAGS is needed for -lintl for glib.
296 speedo_pkg_gpgme_configure = \
297         --enable-static --enable-w32-glib --disable-w32-qt \
298         --with-gpg-error-prefix=$(idir) \
299         LDFLAGS=-L$(idir)/lib
300
301 speedo_pkg_pinentry_configure = \
302         --disable-pinentry-qt --disable-pinentry-qt4 --disable-pinentry-gtk \
303         --enable-pinentry-gtk2 \
304         --with-glib-prefix=$(idir) --with-gtk-prefix=$(idir) \
305         CPPFLAGS=-I$(idir)/include   \
306         LDFLAGS=-L$(idir)/lib        \
307         CXXFLAGS=-static-libstdc++
308
309 speedo_pkg_gpa_configure = \
310         --with-libiconv-prefix=$(idir) --with-libintl-prefix=$(idir) \
311         --with-gpgme-prefix=$(idir) --with-zlib=$(idir) \
312         --with-libassuan-prefix=$(idir) --with-gpg-error-prefix=$(idir)
313
314 speedo_pkg_gpgex_configure = \
315         --with-gpg-error-prefix=$(idir) \
316         --with-libassuan-prefix=$(idir)
317
318 speedo_pkg_w64_gpgex_configure = \
319         --with-gpg-error-prefix=$(idir6) \
320         --with-libassuan-prefix=$(idir6)
321
322
323 #
324 # External packages
325 #
326
327 speedo_pkg_zlib_make_args = \
328         -fwin32/Makefile.gcc PREFIX=$(host)- IMPLIB=libz.dll.a
329
330 speedo_pkg_zlib_make_args_inst = \
331         -fwin32/Makefile.gcc \
332         BINARY_PATH=$(idir)/bin INCLUDE_PATH=$(idir)/include \
333         LIBRARY_PATH=$(idir)/lib SHARED_MODE=1 IMPLIB=libz.dll.a
334
335 # Zlib needs some special magic to generate a libtool file.
336 # We also install the pc file here.
337 define speedo_pkg_zlib_post_install
338 (set -e; mkdir $(idir)/lib/pkgconfig || true;           \
339 cp $(auxsrc)/zlib.pc $(idir)/lib/pkgconfig/;            \
340 cd $(idir);                                             \
341 echo "# Generated by libtool" > lib/libz.la             \
342 echo "dlname='../bin/zlib1.dll'" >> lib/libz.la;        \
343 echo "library_names='libz.dll.a'" >> lib/libz.la;       \
344 echo "old_library='libz.a'" >> lib/libz.la;             \
345 echo "dependency_libs=''" >> lib/libz.la;               \
346 echo "current=1" >> lib/libz.la;                        \
347 echo "age=2" >> lib/libz.la;                            \
348 echo "revision=5" >> lib/libz.la;                       \
349 echo "installed=yes" >> lib/libz.la;                    \
350 echo "shouldnotlink=no" >> lib/libz.la;                 \
351 echo "dlopen=''" >> lib/libz.la;                        \
352 echo "dlpreopen=''" >> lib/libz.la;                     \
353 echo "libdir=\"$(idir)/lib\"" >> lib/libz.la)
354 endef
355
356 speedo_pkg_w64_libiconv_configure = \
357         --enable-shared=no --enable-static=yes
358
359 speedo_pkg_gettext_configure = \
360         --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
361         CPPFLAGS=-I$(idir)/include LDFLAGS=-L$(idir)/lib
362 speedo_pkg_w64_gettext_configure = \
363         --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
364         CPPFLAGS=-I$(idir6)/include LDFLAGS=-L$(idir6)/lib
365 speedo_pkg_gettext_extracflags = -O2
366 # We only need gettext-runtime and there is sadly no top level
367 # configure option for this
368 speedo_pkg_gettext_make_dir = gettext-runtime
369
370
371 speedo_pkg_glib_configure = \
372         --disable-modular-tests \
373         --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
374         CPPFLAGS=-I$(idir)/include \
375         LDFLAGS=-L$(idir)/lib \
376         CCC=$(host)-g++ \
377         LIBFFI_CFLAGS=-I$(idir)/lib/libffi-$(libffi_ver)/include \
378         LIBFFI_LIBS=\"-L$(idir)/lib -lffi\"
379 speedo_pkg_glib_extracflags = -march=i486
380
381
382 speedo_pkg_libpng_configure = \
383         CPPFLAGS=\"-I$(idir)/include -DPNG_BUILD_DLL\" \
384         LDFLAGS=\"-L$(idir)/lib\" LIBPNG_DEFINES=\"-DPNG_BUILD_DLL\"
385
386 speedo_pkg_pixman_configure = \
387         CPPFLAGS=-I$(idir)/include \
388         LDFLAGS=-L$(idir)/lib
389
390 speedo_pkg_cairo_configure = \
391         --disable-qt --disable-ft --disable-fc \
392         --enable-win32 --enable-win32-font \
393         CPPFLAGS=-I$(idir)/include \
394         LDFLAGS=-L$(idir)/lib
395
396 speedo_pkg_pango_configure = \
397         --disable-gtk-doc  \
398         CPPFLAGS=-I$(idir)/include \
399         LDFLAGS=-L$(idir)/lib
400
401 speedo_pkg_gtk__configure = \
402         --disable-cups \
403         CPPFLAGS=-I$(idir)/include \
404         LDFLAGS=-L$(idir)/lib
405
406
407 # ---------
408
409 all: all-speedo
410
411 report: report-speedo
412
413 clean: clean-speedo
414
415 ifeq ($(TARGETOS),w32)
416 STRIP = i686-w64-mingw32-strip
417 else
418 STRIP = strip
419 endif
420 W32CC = i686-w64-mingw32-gcc
421
422 -include config.mk
423
424 #
425 #  The generic speedo code
426 #
427
428 MKDIR=mkdir
429 MAKENSIS=makensis
430 BUILD_ISODATE=$(shell date -u +%Y-%m-%d)
431
432 # The next two macros will work only after gnupg has been build.
433 INST_VERSION=$(shell head -1 $(idir)/INST_VERSION)
434 INST_PROD_VERSION=$(shell head -1 $(idir)/INST_PROD_VERSION)
435
436 # List with packages
437 speedo_build_list = $(speedo_spkgs)
438 speedo_w64_build_list = $(speedo_w64_spkgs)
439
440 # Determine build and host system
441 build := $(shell $(topsrc)/autogen.sh --silent --print-build)
442 ifeq ($(TARGETOS),w32)
443   speedo_autogen_buildopt := --build-w32
444   speedo_autogen_buildopt6 := --build-w64
445   host := $(shell $(topsrc)/autogen.sh --silent --print-host --build-w32)
446   host6:= $(shell $(topsrc)/autogen.sh --silent --print-host --build-w64)
447   speedo_host_build_option := --host=$(host) --build=$(build)
448   speedo_host_build_option6 := --host=$(host6) --build=$(build)
449   speedo_w32_cflags := -mms-bitfields
450 else
451   speedo_autogen_buildopt :=
452   host :=
453   speedo_host_build_option :=
454   speedo_w32_cflags :=
455 endif
456
457 ifeq ($(MAKE_J),)
458   speedo_makeopt=
459 else
460   speedo_makeopt=-j$(MAKE_J)
461 endif
462
463
464
465
466 # The playground area is our scratch area, where we unpack, build and
467 # install the packages.
468 $(stampdir)/stamp-directories:
469         $(MKDIR) $(root) || true
470         $(MKDIR) $(stampdir) || true
471         $(MKDIR) $(sdir)  || true
472         $(MKDIR) $(bdir)  || true
473         $(MKDIR) $(idir)   || true
474 ifeq ($(TARGETOS),w32)
475         $(MKDIR) $(bdir6)  || true
476         $(MKDIR) $(idir6)   || true
477 endif
478         touch $(stampdir)/stamp-directories
479
480 # Frob the name $1 by converting all '-' and '+' characters to '_'.
481 define FROB_macro
482 $(subst +,_,$(subst -,_,$(1)))
483 endef
484
485 # Get the variable $(1) (which may contain '-' and '+' characters).
486 define GETVAR
487 $($(call FROB_macro,$(1)))
488 endef
489
490 # Set a couple of common variables.
491 define SETVARS
492         pkg="$(1)";                                                     \
493         git="$(call GETVAR,speedo_pkg_$(1)_git)";                       \
494         gitref="$(call GETVAR,speedo_pkg_$(1)_gitref)";                 \
495         tar="$(call GETVAR,speedo_pkg_$(1)_tar)";                       \
496         pkgsdir="$(sdir)/$(1)";                                         \
497         if [ "$(1)" = "gnupg" ]; then                                   \
498           git='';                                                       \
499           gitref='';                                                    \
500           tar='';                                                       \
501           pkgsdir="$(topsrc)";                                          \
502         fi;                                                             \
503         pkgbdir="$(bdir)/$(1)";                                         \
504         pkgcfg="$(call GETVAR,speedo_pkg_$(1)_configure)";              \
505         pkgextracflags="$(call GETVAR,speedo_pkg_$(1)_extracflags)";    \
506         pkgmkdir="$(call GETVAR,speedo_pkg_$(1)_make_dir)";             \
507         pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)";           \
508         pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \
509         export PKG_CONFIG="/usr/bin/pkg-config";                        \
510         export PKG_CONFIG_PATH="$(idir)/lib/pkgconfig";                 \
511         export PKG_CONFIG_LIBDIR="";                                    \
512         export SYSROOT="$(idir)";                                       \
513         export PATH="$(idir)/bin:$${PATH}";                             \
514         export LD_LIBRARY_PATH="$(idir)/lib:$${LD_LIBRARY_PATH}"
515 endef
516
517 define SETVARS_W64
518         pkg="$(1)";                                                     \
519         git="$(call GETVAR,speedo_pkg_$(1)_git)";                       \
520         gitref="$(call GETVAR,speedo_pkg_$(1)_gitref)";                 \
521         tar="$(call GETVAR,speedo_pkg_$(1)_tar)";                       \
522         pkgsdir="$(sdir)/$(1)";                                         \
523         if [ "$(1)" = "gnupg" ]; then                                   \
524           git='';                                                       \
525           gitref='';                                                    \
526           tar='';                                                       \
527           pkgsdir="$(topsrc)";                                          \
528         fi;                                                             \
529         pkgbdir="$(bdir6)/$(1)";                                        \
530         pkgcfg="$(call GETVAR,speedo_pkg_w64_$(1)_configure)";          \
531         pkgextracflags="$(call GETVAR,speedo_pkg_$(1)_extracflags)";    \
532         pkgmkdir="$(call GETVAR,speedo_pkg_$(1)_make_dir)";             \
533         pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)";           \
534         pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \
535         export PKG_CONFIG="/usr/bin/pkg-config";                        \
536         export PKG_CONFIG_PATH="$(idir6)/lib/pkgconfig";                \
537         export PKG_CONFIG_LIBDIR="";                                    \
538         export SYSROOT="$(idir6)";                                      \
539         export PATH="$(idir6)/bin:$${PATH}";                            \
540         export LD_LIBRARY_PATH="$(idir6)/lib:$${LD_LIBRARY_PATH}"
541 endef
542
543
544 # Template for source packages.
545 #
546 # Note that the gnupg package is special: The package source dir is
547 # the same as the topsrc dir and thus we need to detect the gnupg
548 # package and cd to that directory.  We also test that no in-source build
549 # has been done.  autogen.sh is not run for gnupg.
550 #
551 define SPKG_template
552
553 $(stampdir)/stamp-$(1)-00-unpack: $(stampdir)/stamp-directories
554         @echo "speedo: /*"
555         @echo "speedo:  *   $(1)"
556         @echo "speedo:  */"
557         @(set -e; cd $(sdir);                           \
558          $(call SETVARS,$(1));                          \
559          if [ "$(WHAT)" = "this" ]; then                \
560            echo "speedo: using included source";        \
561          elif [ "$(1)" = "gnupg" ]; then                \
562            cd $$$${pkgsdir};                            \
563            if [ -f config.log ]; then                   \
564              echo "GnuPG has already been build in-source" >&2  ;\
565              echo "Please run \"make distclean\" and retry" >&2 ;\
566              exit 1 ;                                   \
567            fi;                                          \
568            echo "speedo: unpacking gnupg not needed";   \
569          elif [ -n "$$$${git}" ]; then                  \
570            echo "speedo: unpacking $(1) from $$$${git}:$$$${gitref}"; \
571            git clone -b "$$$${gitref}" "$$$${git}" "$$$${pkg}"; \
572            cd "$$$${pkg}";                              \
573            AUTOGEN_SH_SILENT=1 ./autogen.sh;            \
574          elif [ -n "$$$${tar}" ]; then                  \
575            echo "speedo: unpacking $(1) from $$$${tar}"; \
576            case "$$$${tar}" in                          \
577              *.gz) opt=z ;;                             \
578              *.bz2) opt=j ;;                            \
579              *.xz) opt=J ;;                             \
580              *) opt= ;;                                 \
581            esac;                                        \
582            case "$$$${tar}" in                          \
583              /*) cmd=cat ;;                             \
584              *) cmd="wget -q -O -" ;;                   \
585            esac;                                        \
586            $$$${cmd} "$$$${tar}" | tar x$$$${opt}f - ;  \
587            base=`echo "$$$${tar}" | sed -e 's,^.*/,,'   \
588                  | sed -e 's,\.tar.*$$$$,,'`;           \
589            mv $$$${base} $(1);                          \
590            patch="$(patdir)/$(1)-$$$${base#$(1)-}.patch";\
591            if [ -x "$$$${patch}" ]; then                \
592              echo "speedo: applying patch $$$${patch}"; \
593              cd $(1); "$$$${patch}";                    \
594            elif [ -f "$$$${patch}" ]; then              \
595              echo "speedo: warning: $$$${patch} is not executable"; \
596            fi;                                          \
597          else                                           \
598            echo "speedo: unpacking $(1) from UNKNOWN";  \
599          fi)
600         @touch $(stampdir)/stamp-$(1)-00-unpack
601
602 $(stampdir)/stamp-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack
603         @echo "speedo: configuring $(1)"
604 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
605         @echo "speedo: configure run not required"
606 else ifneq ($(findstring $(1),$(speedo_gnupg_style)),)
607         @($(call SETVARS,$(1));                         \
608          mkdir "$$$${pkgbdir}";                         \
609          cd "$$$${pkgbdir}";                            \
610          if [ -n "$(speedo_autogen_buildopt)" ]; then   \
611             eval AUTOGEN_SH_SILENT=1 w32root="$(idir)"  \
612                "$$$${pkgsdir}/autogen.sh"               \
613                $(speedo_autogen_buildopt)               \
614                $$$${pkgcfg}                             \
615                CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
616          else                                           \
617             eval "$$$${pkgsdir}/configure"              \
618                --silent                                 \
619                --enable-maintainer-mode                 \
620                --prefix="$(idir)"                       \
621                $$$${pkgcfg}                             \
622                CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
623          fi)
624 else
625         @($(call SETVARS,$(1));                         \
626          mkdir "$$$${pkgbdir}";                         \
627          cd "$$$${pkgbdir}";                            \
628          eval "$$$${pkgsdir}/configure"                 \
629              --silent $(speedo_host_build_option)       \
630              --prefix="$(idir)"                         \
631              $$$${pkgcfg}                               \
632              CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
633          )
634 endif
635         @touch $(stampdir)/stamp-$(1)-01-configure
636
637 # Note that unpack has no 64 bit version becuase it is just the source.
638 # Fixme: We should use templates to create the standard and w64
639 # version of these rules.
640 $(stampdir)/stamp-w64-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack
641         @echo "speedo: configuring $(1) (64 bit)"
642 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
643         @echo "speedo: configure run not required"
644 else ifneq ($(findstring $(1),$(speedo_gnupg_style)),)
645         @($(call SETVARS_W64,$(1));                     \
646          mkdir "$$$${pkgbdir}";                         \
647          cd "$$$${pkgbdir}";                            \
648          if [ -n "$(speedo_autogen_buildopt)" ]; then   \
649             eval AUTOGEN_SH_SILENT=1 w64root="$(idir6)" \
650                "$$$${pkgsdir}/autogen.sh"               \
651                $(speedo_autogen_buildopt6)              \
652                $$$${pkgcfg}                             \
653                CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
654          else                                           \
655             eval "$$$${pkgsdir}/configure"              \
656                --silent                                 \
657                --enable-maintainer-mode                 \
658                --prefix="$(idir6)"                      \
659                $$$${pkgcfg}                             \
660                CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
661          fi)
662 else
663         @($(call SETVARS_W64,$(1));                     \
664          mkdir "$$$${pkgbdir}";                         \
665          cd "$$$${pkgbdir}";                            \
666          eval "$$$${pkgsdir}/configure"                 \
667              --silent $(speedo_host_build_option6)      \
668              --prefix="$(idir6)"                        \
669              $$$${pkgcfg}                               \
670              CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
671          )
672 endif
673         @touch $(stampdir)/stamp-w64-$(1)-01-configure
674
675
676 $(stampdir)/stamp-$(1)-02-make: $(stampdir)/stamp-$(1)-01-configure
677         @echo "speedo: making $(1)"
678 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
679         @($(call SETVARS,$(1));                         \
680           cd "$$$${pkgsdir}";                           \
681           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
682           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
683 else
684         @($(call SETVARS,$(1));                         \
685           cd "$$$${pkgbdir}";                           \
686           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
687           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=1)
688 endif
689         @touch $(stampdir)/stamp-$(1)-02-make
690
691 $(stampdir)/stamp-w64-$(1)-02-make: $(stampdir)/stamp-w64-$(1)-01-configure
692         @echo "speedo: making $(1) (64 bit)"
693 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
694         @($(call SETVARS_W64,$(1));                             \
695           cd "$$$${pkgsdir}";                           \
696           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
697           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
698 else
699         @($(call SETVARS_W64,$(1));                             \
700           cd "$$$${pkgbdir}";                           \
701           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
702           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=1)
703 endif
704         @touch $(stampdir)/stamp-w64-$(1)-02-make
705
706 # Note that post_install must come last because it may be empty and
707 # "; ;" is a syntax error.
708 $(stampdir)/stamp-$(1)-03-install: $(stampdir)/stamp-$(1)-02-make
709         @echo "speedo: installing $(1)"
710 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
711         @($(call SETVARS,$(1));                         \
712           cd "$$$${pkgsdir}";                           \
713           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
714           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install V=1;\
715           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
716 else
717         @($(call SETVARS,$(1));                         \
718           cd "$$$${pkgbdir}";                           \
719           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
720           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install-strip V=0;\
721           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
722 endif
723         touch $(stampdir)/stamp-$(1)-03-install
724
725 $(stampdir)/stamp-w64-$(1)-03-install: $(stampdir)/stamp-w64-$(1)-02-make
726         @echo "speedo: installing $(1) (64 bit)"
727 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
728         @($(call SETVARS_W64,$(1));                             \
729           cd "$$$${pkgsdir}";                           \
730           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
731           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install V=1;\
732           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
733 else
734         @($(call SETVARS_W64,$(1));                             \
735           cd "$$$${pkgbdir}";                           \
736           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
737           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install-strip V=0;\
738           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
739 endif
740         touch $(stampdir)/stamp-w64-$(1)-03-install
741
742 $(stampdir)/stamp-final-$(1): $(stampdir)/stamp-$(1)-03-install
743         @echo "speedo: $(1) done"
744         @touch $(stampdir)/stamp-final-$(1)
745
746 $(stampdir)/stamp-w64-final-$(1): $(stampdir)/stamp-w64-$(1)-03-install
747         @echo "speedo: $(1) (64 bit) done"
748         @touch $(stampdir)/stamp-w64-final-$(1)
749
750 .PHONY : clean-$(1)
751 clean-$(1):
752         @echo "speedo: uninstalling $(1)"
753         @($(call SETVARS,$(1));                           \
754          (cd "$$$${pkgbdir}" 2>/dev/null &&               \
755           $(MAKE) --no-print-directory                    \
756            $$$${pkgmkargs_inst} uninstall V=0 ) || true  ;\
757          if [ "$(1)" = "gnupg" ]; then                    \
758            rm -fR "$$$${pkgbdir}" || true                ;\
759          else                                             \
760            rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}" || true;\
761          fi)
762         -rm -f $(stampdir)/stamp-final-$(1) $(stampdir)/stamp-$(1)-*
763
764
765 .PHONY : build-$(1)
766 build-$(1): $(stampdir)/stamp-final-$(1)
767
768
769 .PHONY : report-$(1)
770 report-$(1):
771         @($(call SETVARS,$(1));                         \
772          echo -n $(1):\  ;                              \
773          if [ -n "$$$${git}" ]; then                    \
774            if [ -e "$$$${pkgsdir}/.git" ]; then         \
775              cd "$$$${pkgsdir}" &&                      \
776              git describe ;                             \
777            else                                         \
778              echo missing;                              \
779            fi                                           \
780          elif [ -n "$$$${tar}" ]; then                  \
781            base=`echo "$$$${tar}" | sed -e 's,^.*/,,'   \
782                  | sed -e 's,\.tar.*$$$$,,'`;           \
783            echo $$$${base} ;                            \
784          fi)
785
786 endef
787
788
789 # Insert the template for each source package.
790 $(foreach spkg, $(speedo_spkgs), $(eval $(call SPKG_template,$(spkg))))
791
792 $(stampdir)/stamp-final: $(stampdir)/stamp-directories
793 ifeq ($(TARGETOS),w32)
794 $(stampdir)/stamp-final: $(addprefix $(stampdir)/stamp-w64-final-,$(speedo_w64_build_list))
795 endif
796 $(stampdir)/stamp-final: $(addprefix $(stampdir)/stamp-final-,$(speedo_build_list))
797         touch $(stampdir)/stamp-final
798
799 all-speedo: $(stampdir)/stamp-final
800
801 report-speedo: $(addprefix report-,$(speedo_build_list))
802
803 # Just to check if we catched all stamps.
804 clean-stamps:
805         $(RM) -fR $(stampdir)
806
807 clean-speedo:
808         $(RM) -fR PLAY
809
810
811 #
812 # Windows installer
813 #
814
815 dist-source: all
816         for i in 00 01 02 03; do sleep 1;touch PLAY/stamps/stamp-*-${i}-*;done
817         (set -e;\
818          tarname="$(INST_NAME)-$(INST_VERSION)_$(BUILD_ISODATE).tar" ;\
819          [ -f "$$tarname" ] && rm "$$tarname" ;\
820          tar -C $(topsrc) -cf "$$tarname" --exclude-backups --exclude-vc \
821              --transform='s,^\./,$(INST_NAME)-$(INST_VERSION)/,' \
822              --anchored --exclude './PLAY' . ;\
823          tar --totals -rf "$$tarname" --exclude-backups --exclude-vc \
824               --transform='s,^,$(INST_NAME)-$(INST_VERSION)/,' \
825              PLAY/stamps/stamp-*-00-unpack PLAY/src ;\
826          xz "$$tarname" ;\
827         )
828
829
830 $(bdir)/NEWS.tmp: $(topsrc)/NEWS
831         sed -e '/^#/d' <$(topsrc)/NEWS >$(bdir)/NEWS.tmp
832
833 $(bdir)/README.txt: $(bdir)/NEWS.tmp $(w32src)/README.txt \
834                     $(w32src)/pkg-copyright.txt
835         sed -e '/^;.*/d;' \
836         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
837         -e '/!PKG-COPYRIGHT!/{r $(w32src)/pkg-copyright.txt' -e 'd;}' \
838         -e 's,!VERSION!,$(INST_VERSION),g' \
839            < $(w32src)/README.txt \
840            | awk '{printf "%s\r\n", $$0}' >$(bdir)/README.txt
841
842 $(bdir)/g4wihelp.dll: $(w32src)/g4wihelp.c $(w32src)/exdll.h
843         (set -e; cd $(bdir); \
844          $(W32CC) -I. -shared -O2 -o g4wihelp.dll $(w32src)/g4wihelp.c \
845                   -lwinmm -lgdi32; \
846          $(STRIP) g4wihelp.dll)
847
848 w32_insthelpers: $(bdir)/g4wihelp.dll
849
850 $(bdir)/inst-options.ini: $(w32src)/inst-options.ini
851         cat $(w32src)/inst-options.ini >$(bdir)/inst-options.ini
852
853 installer: all w32_insthelpers $(bdir)/inst-options.ini $(bdir)/README.txt
854         $(MAKENSIS) -V2 \
855                     -DINST_DIR=$(idir) \
856                     -DINST6_DIR=$(idir6) \
857                     -DBUILD_DIR=$(bdir) \
858                     -DTOP_SRCDIR=$(topsrc) \
859                     -DW32_SRCDIR=$(w32src) \
860                     -DBUILD_ISODATE=$(BUILD_ISODATE) \
861                     -DNAME=$(INST_NAME) \
862                     -DVERSION=$(INST_VERSION) \
863                     -DPROD_VERSION=$(INST_PROD_VERSION) \
864                     $(w32src)/inst.nsi
865         @echo "Ready: $(idir)/$(INST_NAME)-$(INST_VERSION)"
866
867 #
868 # Mark phony targets
869 #
870 .PHONY: all-speedo report-speedo clean-stamps clean-speedo installer \
871         w32_insthelpers