Merge branch 'wk/test-gpgrt-estream'
[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 ifeq ($(TARGETOS),w32)
380 speedo_pkg_glib_extracflags = -march=i486
381 endif
382
383 speedo_pkg_libpng_configure = \
384         CPPFLAGS=\"-I$(idir)/include -DPNG_BUILD_DLL\" \
385         LDFLAGS=\"-L$(idir)/lib\" LIBPNG_DEFINES=\"-DPNG_BUILD_DLL\"
386
387 speedo_pkg_pixman_configure = \
388         CPPFLAGS=-I$(idir)/include \
389         LDFLAGS=-L$(idir)/lib
390
391 speedo_pkg_cairo_configure = \
392         --disable-qt --disable-ft --disable-fc \
393         --enable-win32 --enable-win32-font \
394         CPPFLAGS=-I$(idir)/include \
395         LDFLAGS=-L$(idir)/lib
396
397 speedo_pkg_pango_configure = \
398         --disable-gtk-doc  \
399         CPPFLAGS=-I$(idir)/include \
400         LDFLAGS=-L$(idir)/lib
401
402 speedo_pkg_gtk__configure = \
403         --disable-cups \
404         CPPFLAGS=-I$(idir)/include \
405         LDFLAGS=-L$(idir)/lib
406
407
408 # ---------
409
410 all: all-speedo
411
412 report: report-speedo
413
414 clean: clean-speedo
415
416 ifeq ($(TARGETOS),w32)
417 STRIP = i686-w64-mingw32-strip
418 else
419 STRIP = strip
420 endif
421 W32CC = i686-w64-mingw32-gcc
422
423 -include config.mk
424
425 #
426 #  The generic speedo code
427 #
428
429 MKDIR=mkdir
430 MAKENSIS=makensis
431 BUILD_ISODATE=$(shell date -u +%Y-%m-%d)
432
433 # The next two macros will work only after gnupg has been build.
434 INST_VERSION=$(shell head -1 $(idir)/INST_VERSION)
435 INST_PROD_VERSION=$(shell head -1 $(idir)/INST_PROD_VERSION)
436
437 # List with packages
438 speedo_build_list = $(speedo_spkgs)
439 speedo_w64_build_list = $(speedo_w64_spkgs)
440
441 # Determine build and host system
442 build := $(shell $(topsrc)/autogen.sh --silent --print-build)
443 ifeq ($(TARGETOS),w32)
444   speedo_autogen_buildopt := --build-w32
445   speedo_autogen_buildopt6 := --build-w64
446   host := $(shell $(topsrc)/autogen.sh --silent --print-host --build-w32)
447   host6:= $(shell $(topsrc)/autogen.sh --silent --print-host --build-w64)
448   speedo_host_build_option := --host=$(host) --build=$(build)
449   speedo_host_build_option6 := --host=$(host6) --build=$(build)
450   speedo_w32_cflags := -mms-bitfields
451 else
452   speedo_autogen_buildopt :=
453   host :=
454   speedo_host_build_option :=
455   speedo_w32_cflags :=
456 endif
457
458 ifeq ($(MAKE_J),)
459   speedo_makeopt=
460 else
461   speedo_makeopt=-j$(MAKE_J)
462 endif
463
464
465
466
467 # The playground area is our scratch area, where we unpack, build and
468 # install the packages.
469 $(stampdir)/stamp-directories:
470         $(MKDIR) $(root) || true
471         $(MKDIR) $(stampdir) || true
472         $(MKDIR) $(sdir)  || true
473         $(MKDIR) $(bdir)  || true
474         $(MKDIR) $(idir)   || true
475 ifeq ($(TARGETOS),w32)
476         $(MKDIR) $(bdir6)  || true
477         $(MKDIR) $(idir6)   || true
478 endif
479         touch $(stampdir)/stamp-directories
480
481 # Frob the name $1 by converting all '-' and '+' characters to '_'.
482 define FROB_macro
483 $(subst +,_,$(subst -,_,$(1)))
484 endef
485
486 # Get the variable $(1) (which may contain '-' and '+' characters).
487 define GETVAR
488 $($(call FROB_macro,$(1)))
489 endef
490
491 # Set a couple of common variables.
492 define SETVARS
493         pkg="$(1)";                                                     \
494         git="$(call GETVAR,speedo_pkg_$(1)_git)";                       \
495         gitref="$(call GETVAR,speedo_pkg_$(1)_gitref)";                 \
496         tar="$(call GETVAR,speedo_pkg_$(1)_tar)";                       \
497         pkgsdir="$(sdir)/$(1)";                                         \
498         if [ "$(1)" = "gnupg" ]; then                                   \
499           git='';                                                       \
500           gitref='';                                                    \
501           tar='';                                                       \
502           pkgsdir="$(topsrc)";                                          \
503         fi;                                                             \
504         pkgbdir="$(bdir)/$(1)";                                         \
505         pkgcfg="$(call GETVAR,speedo_pkg_$(1)_configure)";              \
506         pkgextracflags="$(call GETVAR,speedo_pkg_$(1)_extracflags)";    \
507         pkgmkdir="$(call GETVAR,speedo_pkg_$(1)_make_dir)";             \
508         pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)";           \
509         pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \
510         export PKG_CONFIG="/usr/bin/pkg-config";                        \
511         export PKG_CONFIG_PATH="$(idir)/lib/pkgconfig";                 \
512         export PKG_CONFIG_LIBDIR="";                                    \
513         export SYSROOT="$(idir)";                                       \
514         export PATH="$(idir)/bin:$${PATH}";                             \
515         export LD_LIBRARY_PATH="$(idir)/lib:$${LD_LIBRARY_PATH}"
516 endef
517
518 define SETVARS_W64
519         pkg="$(1)";                                                     \
520         git="$(call GETVAR,speedo_pkg_$(1)_git)";                       \
521         gitref="$(call GETVAR,speedo_pkg_$(1)_gitref)";                 \
522         tar="$(call GETVAR,speedo_pkg_$(1)_tar)";                       \
523         pkgsdir="$(sdir)/$(1)";                                         \
524         if [ "$(1)" = "gnupg" ]; then                                   \
525           git='';                                                       \
526           gitref='';                                                    \
527           tar='';                                                       \
528           pkgsdir="$(topsrc)";                                          \
529         fi;                                                             \
530         pkgbdir="$(bdir6)/$(1)";                                        \
531         pkgcfg="$(call GETVAR,speedo_pkg_w64_$(1)_configure)";          \
532         pkgextracflags="$(call GETVAR,speedo_pkg_$(1)_extracflags)";    \
533         pkgmkdir="$(call GETVAR,speedo_pkg_$(1)_make_dir)";             \
534         pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)";           \
535         pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \
536         export PKG_CONFIG="/usr/bin/pkg-config";                        \
537         export PKG_CONFIG_PATH="$(idir6)/lib/pkgconfig";                \
538         export PKG_CONFIG_LIBDIR="";                                    \
539         export SYSROOT="$(idir6)";                                      \
540         export PATH="$(idir6)/bin:$${PATH}";                            \
541         export LD_LIBRARY_PATH="$(idir6)/lib:$${LD_LIBRARY_PATH}"
542 endef
543
544
545 # Template for source packages.
546 #
547 # Note that the gnupg package is special: The package source dir is
548 # the same as the topsrc dir and thus we need to detect the gnupg
549 # package and cd to that directory.  We also test that no in-source build
550 # has been done.  autogen.sh is not run for gnupg.
551 #
552 define SPKG_template
553
554 $(stampdir)/stamp-$(1)-00-unpack: $(stampdir)/stamp-directories
555         @echo "speedo: /*"
556         @echo "speedo:  *   $(1)"
557         @echo "speedo:  */"
558         @(set -e; cd $(sdir);                           \
559          $(call SETVARS,$(1));                          \
560          if [ "$(WHAT)" = "this" ]; then                \
561            echo "speedo: using included source";        \
562          elif [ "$(1)" = "gnupg" ]; then                \
563            cd $$$${pkgsdir};                            \
564            if [ -f config.log ]; then                   \
565              echo "GnuPG has already been build in-source" >&2  ;\
566              echo "Please run \"make distclean\" and retry" >&2 ;\
567              exit 1 ;                                   \
568            fi;                                          \
569            echo "speedo: unpacking gnupg not needed";   \
570          elif [ -n "$$$${git}" ]; then                  \
571            echo "speedo: unpacking $(1) from $$$${git}:$$$${gitref}"; \
572            git clone -b "$$$${gitref}" "$$$${git}" "$$$${pkg}"; \
573            cd "$$$${pkg}";                              \
574            AUTOGEN_SH_SILENT=1 ./autogen.sh;            \
575          elif [ -n "$$$${tar}" ]; then                  \
576            echo "speedo: unpacking $(1) from $$$${tar}"; \
577            case "$$$${tar}" in                          \
578              *.gz) opt=z ;;                             \
579              *.bz2) opt=j ;;                            \
580              *.xz) opt=J ;;                             \
581              *) opt= ;;                                 \
582            esac;                                        \
583            case "$$$${tar}" in                          \
584              /*) cmd=cat ;;                             \
585              *) cmd="wget -q -O -" ;;                   \
586            esac;                                        \
587            $$$${cmd} "$$$${tar}" | tar x$$$${opt}f - ;  \
588            base=`echo "$$$${tar}" | sed -e 's,^.*/,,'   \
589                  | sed -e 's,\.tar.*$$$$,,'`;           \
590            mv $$$${base} $(1);                          \
591            patch="$(patdir)/$(1)-$$$${base#$(1)-}.patch";\
592            if [ -x "$$$${patch}" ]; then                \
593              echo "speedo: applying patch $$$${patch}"; \
594              cd $(1); "$$$${patch}";                    \
595            elif [ -f "$$$${patch}" ]; then              \
596              echo "speedo: warning: $$$${patch} is not executable"; \
597            fi;                                          \
598          else                                           \
599            echo "speedo: unpacking $(1) from UNKNOWN";  \
600          fi)
601         @touch $(stampdir)/stamp-$(1)-00-unpack
602
603 $(stampdir)/stamp-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack
604         @echo "speedo: configuring $(1)"
605 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
606         @echo "speedo: configure run not required"
607 else ifneq ($(findstring $(1),$(speedo_gnupg_style)),)
608         @($(call SETVARS,$(1));                         \
609          mkdir "$$$${pkgbdir}";                         \
610          cd "$$$${pkgbdir}";                            \
611          if [ -n "$(speedo_autogen_buildopt)" ]; then   \
612             eval AUTOGEN_SH_SILENT=1 w32root="$(idir)"  \
613                "$$$${pkgsdir}/autogen.sh"               \
614                $(speedo_autogen_buildopt)               \
615                $$$${pkgcfg}                             \
616                CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
617          else                                           \
618             eval "$$$${pkgsdir}/configure"              \
619                --silent                                 \
620                --enable-maintainer-mode                 \
621                --prefix="$(idir)"                       \
622                $$$${pkgcfg}                             \
623                CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
624          fi)
625 else
626         @($(call SETVARS,$(1));                         \
627          mkdir "$$$${pkgbdir}";                         \
628          cd "$$$${pkgbdir}";                            \
629          eval "$$$${pkgsdir}/configure"                 \
630              --silent $(speedo_host_build_option)       \
631              --prefix="$(idir)"                         \
632              $$$${pkgcfg}                               \
633              CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
634          )
635 endif
636         @touch $(stampdir)/stamp-$(1)-01-configure
637
638 # Note that unpack has no 64 bit version becuase it is just the source.
639 # Fixme: We should use templates to create the standard and w64
640 # version of these rules.
641 $(stampdir)/stamp-w64-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack
642         @echo "speedo: configuring $(1) (64 bit)"
643 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
644         @echo "speedo: configure run not required"
645 else ifneq ($(findstring $(1),$(speedo_gnupg_style)),)
646         @($(call SETVARS_W64,$(1));                     \
647          mkdir "$$$${pkgbdir}";                         \
648          cd "$$$${pkgbdir}";                            \
649          if [ -n "$(speedo_autogen_buildopt)" ]; then   \
650             eval AUTOGEN_SH_SILENT=1 w64root="$(idir6)" \
651                "$$$${pkgsdir}/autogen.sh"               \
652                $(speedo_autogen_buildopt6)              \
653                $$$${pkgcfg}                             \
654                CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
655          else                                           \
656             eval "$$$${pkgsdir}/configure"              \
657                --silent                                 \
658                --enable-maintainer-mode                 \
659                --prefix="$(idir6)"                      \
660                $$$${pkgcfg}                             \
661                CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
662          fi)
663 else
664         @($(call SETVARS_W64,$(1));                     \
665          mkdir "$$$${pkgbdir}";                         \
666          cd "$$$${pkgbdir}";                            \
667          eval "$$$${pkgsdir}/configure"                 \
668              --silent $(speedo_host_build_option6)      \
669              --prefix="$(idir6)"                        \
670              $$$${pkgcfg}                               \
671              CFLAGS=\"$(speedo_w32_cflags) $$$${pkgextracflags}\";\
672          )
673 endif
674         @touch $(stampdir)/stamp-w64-$(1)-01-configure
675
676
677 $(stampdir)/stamp-$(1)-02-make: $(stampdir)/stamp-$(1)-01-configure
678         @echo "speedo: making $(1)"
679 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
680         @($(call SETVARS,$(1));                         \
681           cd "$$$${pkgsdir}";                           \
682           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
683           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
684 else
685         @($(call SETVARS,$(1));                         \
686           cd "$$$${pkgbdir}";                           \
687           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
688           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=1)
689 endif
690         @touch $(stampdir)/stamp-$(1)-02-make
691
692 $(stampdir)/stamp-w64-$(1)-02-make: $(stampdir)/stamp-w64-$(1)-01-configure
693         @echo "speedo: making $(1) (64 bit)"
694 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
695         @($(call SETVARS_W64,$(1));                             \
696           cd "$$$${pkgsdir}";                           \
697           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
698           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
699 else
700         @($(call SETVARS_W64,$(1));                             \
701           cd "$$$${pkgbdir}";                           \
702           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
703           $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=1)
704 endif
705         @touch $(stampdir)/stamp-w64-$(1)-02-make
706
707 # Note that post_install must come last because it may be empty and
708 # "; ;" is a syntax error.
709 $(stampdir)/stamp-$(1)-03-install: $(stampdir)/stamp-$(1)-02-make
710         @echo "speedo: installing $(1)"
711 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
712         @($(call SETVARS,$(1));                         \
713           cd "$$$${pkgsdir}";                           \
714           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
715           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install V=1;\
716           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
717 else
718         @($(call SETVARS,$(1));                         \
719           cd "$$$${pkgbdir}";                           \
720           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
721           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install-strip V=0;\
722           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
723 endif
724         touch $(stampdir)/stamp-$(1)-03-install
725
726 $(stampdir)/stamp-w64-$(1)-03-install: $(stampdir)/stamp-w64-$(1)-02-make
727         @echo "speedo: installing $(1) (64 bit)"
728 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
729         @($(call SETVARS_W64,$(1));                             \
730           cd "$$$${pkgsdir}";                           \
731           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
732           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install V=1;\
733           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
734 else
735         @($(call SETVARS_W64,$(1));                             \
736           cd "$$$${pkgbdir}";                           \
737           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
738           $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install-strip V=0;\
739           $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
740 endif
741         touch $(stampdir)/stamp-w64-$(1)-03-install
742
743 $(stampdir)/stamp-final-$(1): $(stampdir)/stamp-$(1)-03-install
744         @echo "speedo: $(1) done"
745         @touch $(stampdir)/stamp-final-$(1)
746
747 $(stampdir)/stamp-w64-final-$(1): $(stampdir)/stamp-w64-$(1)-03-install
748         @echo "speedo: $(1) (64 bit) done"
749         @touch $(stampdir)/stamp-w64-final-$(1)
750
751 .PHONY : clean-$(1)
752 clean-$(1):
753         @echo "speedo: uninstalling $(1)"
754         @($(call SETVARS,$(1));                           \
755          (cd "$$$${pkgbdir}" 2>/dev/null &&               \
756           $(MAKE) --no-print-directory                    \
757            $$$${pkgmkargs_inst} uninstall V=0 ) || true  ;\
758          if [ "$(1)" = "gnupg" ]; then                    \
759            rm -fR "$$$${pkgbdir}" || true                ;\
760          else                                             \
761            rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}" || true;\
762          fi)
763         -rm -f $(stampdir)/stamp-final-$(1) $(stampdir)/stamp-$(1)-*
764
765
766 .PHONY : build-$(1)
767 build-$(1): $(stampdir)/stamp-final-$(1)
768
769
770 .PHONY : report-$(1)
771 report-$(1):
772         @($(call SETVARS,$(1));                         \
773          echo -n $(1):\  ;                              \
774          if [ -n "$$$${git}" ]; then                    \
775            if [ -e "$$$${pkgsdir}/.git" ]; then         \
776              cd "$$$${pkgsdir}" &&                      \
777              git describe ;                             \
778            else                                         \
779              echo missing;                              \
780            fi                                           \
781          elif [ -n "$$$${tar}" ]; then                  \
782            base=`echo "$$$${tar}" | sed -e 's,^.*/,,'   \
783                  | sed -e 's,\.tar.*$$$$,,'`;           \
784            echo $$$${base} ;                            \
785          fi)
786
787 endef
788
789
790 # Insert the template for each source package.
791 $(foreach spkg, $(speedo_spkgs), $(eval $(call SPKG_template,$(spkg))))
792
793 $(stampdir)/stamp-final: $(stampdir)/stamp-directories
794 ifeq ($(TARGETOS),w32)
795 $(stampdir)/stamp-final: $(addprefix $(stampdir)/stamp-w64-final-,$(speedo_w64_build_list))
796 endif
797 $(stampdir)/stamp-final: $(addprefix $(stampdir)/stamp-final-,$(speedo_build_list))
798         touch $(stampdir)/stamp-final
799
800 all-speedo: $(stampdir)/stamp-final
801
802 report-speedo: $(addprefix report-,$(speedo_build_list))
803
804 # Just to check if we catched all stamps.
805 clean-stamps:
806         $(RM) -fR $(stampdir)
807
808 clean-speedo:
809         $(RM) -fR PLAY
810
811
812 #
813 # Windows installer
814 #
815
816 dist-source: all
817         for i in 00 01 02 03; do sleep 1;touch PLAY/stamps/stamp-*-${i}-*;done
818         (set -e;\
819          tarname="$(INST_NAME)-$(INST_VERSION)_$(BUILD_ISODATE).tar" ;\
820          [ -f "$$tarname" ] && rm "$$tarname" ;\
821          tar -C $(topsrc) -cf "$$tarname" --exclude-backups --exclude-vc \
822              --transform='s,^\./,$(INST_NAME)-$(INST_VERSION)/,' \
823              --anchored --exclude './PLAY' . ;\
824          tar --totals -rf "$$tarname" --exclude-backups --exclude-vc \
825               --transform='s,^,$(INST_NAME)-$(INST_VERSION)/,' \
826              PLAY/stamps/stamp-*-00-unpack PLAY/src ;\
827          xz "$$tarname" ;\
828         )
829
830
831 $(bdir)/NEWS.tmp: $(topsrc)/NEWS
832         sed -e '/^#/d' <$(topsrc)/NEWS >$(bdir)/NEWS.tmp
833
834 $(bdir)/README.txt: $(bdir)/NEWS.tmp $(w32src)/README.txt \
835                     $(w32src)/pkg-copyright.txt
836         sed -e '/^;.*/d;' \
837         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
838         -e '/!PKG-COPYRIGHT!/{r $(w32src)/pkg-copyright.txt' -e 'd;}' \
839         -e 's,!VERSION!,$(INST_VERSION),g' \
840            < $(w32src)/README.txt \
841            | awk '{printf "%s\r\n", $$0}' >$(bdir)/README.txt
842
843 $(bdir)/g4wihelp.dll: $(w32src)/g4wihelp.c $(w32src)/exdll.h
844         (set -e; cd $(bdir); \
845          $(W32CC) -I. -shared -O2 -o g4wihelp.dll $(w32src)/g4wihelp.c \
846                   -lwinmm -lgdi32; \
847          $(STRIP) g4wihelp.dll)
848
849 w32_insthelpers: $(bdir)/g4wihelp.dll
850
851 $(bdir)/inst-options.ini: $(w32src)/inst-options.ini
852         cat $(w32src)/inst-options.ini >$(bdir)/inst-options.ini
853
854 installer: all w32_insthelpers $(bdir)/inst-options.ini $(bdir)/README.txt
855         $(MAKENSIS) -V2 \
856                     -DINST_DIR=$(idir) \
857                     -DINST6_DIR=$(idir6) \
858                     -DBUILD_DIR=$(bdir) \
859                     -DTOP_SRCDIR=$(topsrc) \
860                     -DW32_SRCDIR=$(w32src) \
861                     -DBUILD_ISODATE=$(BUILD_ISODATE) \
862                     -DNAME=$(INST_NAME) \
863                     -DVERSION=$(INST_VERSION) \
864                     -DPROD_VERSION=$(INST_PROD_VERSION) \
865                     $(w32src)/inst.nsi
866         @echo "Ready: $(idir)/$(INST_NAME)-$(INST_VERSION)"
867
868 #
869 # Mark phony targets
870 #
871 .PHONY: all-speedo report-speedo clean-stamps clean-speedo installer \
872         w32_insthelpers