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