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