1 # speedo.mk - Speedo rebuilds speedily.
2 # Copyright (C) 2008, 2014 g10 Code GmbH
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.
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.
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/>.
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:
22 # make -f speedo.mk all pkg2rep=/dir/with/tarballs
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.
30 # make -f speedo.mk clean
32 # make -f speedo.mk clean-PACKAGE
34 # Removes all packages or the package PACKAGE from the installation
35 # and build tree. A subsequent make will rebuild these (and only
38 # make -f speedo.mk report
40 # make -f speedo.mk report-PACKAGE
42 # Lists packages and versions.
45 # We need to know our own name.
46 SPEEDO_MK := $(realpath $(lastword $(MAKEFILE_LIST)))
48 .PHONY : help native native-gui w32-installer w32-source
49 .PHONY : git-native git-native-gui git-w32-installer git-w32-source
50 .PHONY : this-native this-native-gui this-w32-installer this-w32-source
53 @echo 'usage: make -f speedo.mk TARGET'
54 @echo ' with TARGET being one of:'
55 @echo ' help This help'
56 @echo ' native Native build of the GnuPG core'
57 @echo ' native-gui Ditto but with pinentry and GPA'
58 @echo ' w32-installer Build a Windows installer'
59 @echo ' w32-source Pack a source archive'
61 @echo 'You may append INSTALL_PREFIX=<dir> for native builds.'
62 @echo 'Prepend TARGET with "git-" to build from GIT repos.'
63 @echo 'Prepend TARGET with "this-" to build from the source tarball.'
64 @echo 'Use SELFCHECK=0 for a non-released version.'
65 @echo 'Use CUSTOM_SWDB=1 for an already downloaded swdb.lst.'
67 SPEEDOMAKE := $(MAKE) -f $(SPEEDO_MK) UPD_SWDB=1
70 $(SPEEDOMAKE) TARGETOS=native WHAT=release WITH_GUI=0 all
72 git-native: check-tools
73 $(SPEEDOMAKE) TARGETOS=native WHAT=git WITH_GUI=0 all
75 this-native: check-tools
76 $(SPEEDOMAKE) TARGETOS=native WHAT=this WITH_GUI=0 all
78 native-gui: check-tools
79 $(SPEEDOMAKE) TARGETOS=native WHAT=release WITH_GUI=1 all
81 git-native-gui: check-tools
82 $(SPEEDOMAKE) TARGETOS=native WHAT=git WITH_GUI=1 all
84 this-native-gui: check-tools
85 $(SPEEDOMAKE) TARGETOS=native WHAT=this WITH_GUI=1 all
87 w32-installer: check-tools
88 $(SPEEDOMAKE) TARGETOS=w32 WHAT=release WITH_GUI=0 installer
90 git-w32-installer: check-tools
91 $(SPEEDOMAKE) TARGETOS=w32 WHAT=git WITH_GUI=0 installer
93 this-w32-installer: check-tools
94 $(SPEEDOMAKE) TARGETOS=w32 WHAT=this WITH_GUI=0 installer
96 w32-source: check-tools
97 $(SPEEDOMAKE) TARGETOS=w32 WHAT=release WITH_GUI=0 dist-source
99 git-w32-source: check-tools
100 $(SPEEDOMAKE) TARGETOS=w32 WHAT=git WITH_GUI=0 dist-source
102 this-w32-source: check-tools
103 $(SPEEDOMAKE) TARGETOS=w32 WHAT=git WITH_GUI=0 dist-source
106 # Set this to "git" to build from git,
107 # to "release" from tarballs,
108 # to "this" from the unpacked sources.
111 # Set target to "native" or "w32"
114 # Set to 1 to build the GUI tools
117 # Set to 1 to use a pre-installed swdb.lst instead of the online version.
120 # Set to 1 to really download the swdb.
123 # Set to 0 to skip the GnuPG version self-check
126 # Set to the location of the directory with tarballs of
128 TARBALLS=$(shell pwd)/../tarballs
130 # Number of parallel make jobs
133 # Name to use for the w32 installer and sources
136 # Use this to override the installaion directory for native builds.
141 # They must be absolute, as we switch directories pretty often.
142 root := $(shell pwd)/PLAY
144 bdir := $(root)/build
145 bdir6:= $(root)/build-w64
146 ifeq ($(INSTALL_PREFIX),none)
149 idir := $(abspath $(INSTALL_PREFIX))
151 idir6:= $(root)/inst-w64
152 stampdir := $(root)/stamps
153 topsrc := $(shell cd $(dir $(SPEEDO_MK)).. && pwd)
154 auxsrc := $(topsrc)/build-aux/speedo
155 patdir := $(topsrc)/build-aux/speedo/patches
156 w32src := $(topsrc)/build-aux/speedo/w32
158 # =====BEGIN LIST OF PACKAGES=====
159 # The packages that should be built. The order is also the build order.
160 # Fixme: Do we need to build pkg-config for cross-building?
163 libgpg-error npth libgcrypt
165 ifeq ($(TARGETOS),w32)
167 zlib bzip2 adns libiconv
169 speedo_spkgs += gettext
174 libassuan libksba gnupg
176 ifeq ($(TARGETOS),w32)
179 libffi glib pkg-config
186 ifeq ($(TARGETOS),w32)
190 gdk-pixbuf atk pixman cairo pango gtk+
194 ifeq ($(TARGETOS),w32)
196 speedo_spkgs += pinentry
198 speedo_spkgs += gpa gpgex
204 speedo_spkgs += pinentry gpa
210 # =====END LIST OF PACKAGES=====
213 # Packages which are additionally build for 64 bit Windows. They are
214 # only used for gpgex and thus we need to build them only if we want
218 speedo_w64_spkgs += libgpg-error libiconv gettext libassuan gpgex
221 # Packages which use the gnupg autogen.sh build style
222 speedo_gnupg_style = \
223 libgpg-error npth libgcrypt \
224 libassuan libksba gnupg gpgme \
227 # Packages which use only make and no build directory
228 speedo_make_only_style = \
231 # Get the content of the software DB.
232 ifeq ($(CUSTOM_SWDB),1)
233 getswdb_options = --skip-download --skip-verify
237 ifeq ($(SELFCHECK),0)
238 getswdb_options += --skip-selfcheck
241 SWDB := $(shell $(topsrc)/build-aux/getswdb.sh $(getswdb_options) && echo okay)
242 ifeq ($(strip $(SWDB)),)
244 $(error Error getting GnuPG software version database)
248 # Version numbers of the released packages
249 gnupg_ver_this = $(shell cat $(topsrc)/VERSION)
251 gnupg_ver := $(shell awk '$$1=="gnupg21_ver" {print $$2}' swdb.lst)
253 libgpg_error_ver := $(shell awk '$$1=="libgpg_error_ver" {print $$2}' swdb.lst)
254 libgpg_error_sha1:= $(shell awk '$$1=="libgpg_error_sha1" {print $$2}' swdb.lst)
256 npth_ver := $(shell awk '$$1=="npth_ver" {print $$2}' swdb.lst)
257 npth_sha1 := $(shell awk '$$1=="npth_sha1" {print $$2}' swdb.lst)
259 libgcrypt_ver := $(shell awk '$$1=="libgcrypt_ver" {print $$2}' swdb.lst)
260 libgcrypt_sha1 := $(shell awk '$$1=="libgcrypt_sha1" {print $$2}' swdb.lst)
262 libassuan_ver := $(shell awk '$$1=="libassuan_ver" {print $$2}' swdb.lst)
263 libassuan_sha1 := $(shell awk '$$1=="libassuan_sha1" {print $$2}' swdb.lst)
265 libksba_ver := $(shell awk '$$1=="libksba_ver" {print $$2}' swdb.lst)
266 libksba_sha1 := $(shell awk '$$1=="libksba_sha1" {print $$2}' swdb.lst)
268 gpgme_ver := $(shell awk '$$1=="gpgme_ver" {print $$2}' swdb.lst)
269 gpgme_sha1 := $(shell awk '$$1=="gpgme_sha1" {print $$2}' swdb.lst)
271 pinentry_ver := $(shell awk '$$1=="pinentry_ver" {print $$2}' swdb.lst)
272 pinentry_sha1 := $(shell awk '$$1=="pinentry_sha1" {print $$2}' swdb.lst)
274 gpa_ver := $(shell awk '$$1=="gpa_ver" {print $$2}' swdb.lst)
275 gpa_sha1 := $(shell awk '$$1=="gpa_sha1" {print $$2}' swdb.lst)
277 gpgex_ver := $(shell awk '$$1=="gpgex_ver" {print $$2}' swdb.lst)
278 gpgex_sha1 := $(shell awk '$$1=="gpgex_sha1" {print $$2}' swdb.lst)
280 zlib_ver := $(shell awk '$$1=="zlib_ver" {print $$2}' swdb.lst)
281 zlib_sha1 := $(shell awk '$$1=="zlib_sha1_gz" {print $$2}' swdb.lst)
283 bzip2_ver := $(shell awk '$$1=="bzip2_ver" {print $$2}' swdb.lst)
284 bzip2_sha1 := $(shell awk '$$1=="bzip2_sha1_gz" {print $$2}' swdb.lst)
286 adns_ver := $(shell awk '$$1=="adns_ver" {print $$2}' swdb.lst)
287 adns_sha1 := $(shell awk '$$1=="adns_sha1" {print $$2}' swdb.lst)
289 $(info Information from the version database)
290 $(info GnuPG ..........: $(gnupg_ver) (building $(gnupg_ver_this)))
291 $(info Libgpg-error ...: $(libgpg_error_ver))
292 $(info Npth ...........: $(npth_ver))
293 $(info Libgcrypt ......: $(libgcrypt_ver))
294 $(info Libassuan ......: $(libassuan_ver))
295 $(info Zlib ...........: $(zlib_ver))
296 $(info Bzip2 ..........: $(bzip2_ver))
297 $(info ADNS ...........: $(adns_ver))
298 $(info GPGME ..........: $(gpgme_ver))
299 $(info Pinentry .......: $(pinentry_ver))
300 $(info GPA ............: $(gpa_ver))
301 $(info GpgEX.... ......: $(gpgex_ver))
304 # Version number for external packages
305 pkg_config_ver = 0.23
307 gettext_ver = 0.18.2.1
311 gdk_pixbuf_ver = 2.26.5
318 # The GIT repository. Using a local repo is much faster.
319 #gitrep = git://git.gnupg.org
322 # The tarball directories
323 pkgrep = ftp://ftp.gnupg.org/gcrypt
324 pkg10rep = ftp://ftp.g10code.com/g10code
325 pkg2rep = $(TARBALLS)
327 # For each package, the following variables can be defined:
329 # speedo_pkg_PACKAGE_git: The GIT repository that should be built.
330 # speedo_pkg_PACKAGE_gitref: The GIT revision to checkout
332 # speedo_pkg_PACKAGE_tar: URL to the tar file that should be built.
334 # Exactly one of the above variables is required. Note that this
335 # version of speedo does not cache repositories or tar files, and does
336 # not test the integrity of the downloaded software. If you care
337 # about this, you can also specify filenames to locally verified files.
338 # Filenames are differentiated from URLs by starting with a slash '/'.
340 # speedo_pkg_PACKAGE_configure: Extra arguments to configure.
342 # speedo_pkg_PACKAGE_make_args: Extra arguments to make.
344 # speedo_pkg_PACKAGE_make_args_inst: Extra arguments to make install.
346 # Note that you can override the defaults in this file in a local file
350 else ifeq ($(WHAT),git)
351 speedo_pkg_libgpg_error_git = $(gitrep)/libgpg-error
352 speedo_pkg_libgpg_error_gitref = master
353 speedo_pkg_npth_git = $(gitrep)/npth
354 speedo_pkg_npth_gitref = master
355 speedo_pkg_libassuan_git = $(gitrep)/libassuan
356 speedo_pkg_libassuan_gitref = master
357 speedo_pkg_libgcrypt_git = $(gitrep)/libgcrypt
358 speedo_pkg_libgcrypt_gitref = master
359 speedo_pkg_libksba_git = $(gitrep)/libksba
360 speedo_pkg_libksba_gitref = master
361 speedo_pkg_gpgme_git = $(gitrep)/gpgme
362 speedo_pkg_gpgme_gitref = master
363 speedo_pkg_pinentry_git = $(gitrep)/pinentry
364 speedo_pkg_pinentry_gitref = master
365 speedo_pkg_gpa_git = $(gitrep)/gpa
366 speedo_pkg_gpa_gitref = master
367 speedo_pkg_gpgex_git = $(gitrep)/gpgex
368 speedo_pkg_gpgex_gitref = master
369 else ifeq ($(WHAT),release)
370 speedo_pkg_libgpg_error_tar = \
371 $(pkgrep)/libgpg-error/libgpg-error-$(libgpg_error_ver).tar.bz2
372 speedo_pkg_npth_tar = \
373 $(pkgrep)/npth/npth-$(npth_ver).tar.bz2
374 speedo_pkg_libassuan_tar = \
375 $(pkgrep)/libassuan/libassuan-$(libassuan_ver).tar.bz2
376 speedo_pkg_libgcrypt_tar = \
377 $(pkgrep)/libgcrypt/libgcrypt-$(libgcrypt_ver).tar.bz2
378 speedo_pkg_libksba_tar = \
379 $(pkgrep)/libksba/libksba-$(libksba_ver).tar.bz2
380 speedo_pkg_gpgme_tar = \
381 $(pkgrep)/gpgme/gpgme-$(gpgme_ver).tar.bz2
382 speedo_pkg_pinentry_tar = \
383 $(pkgrep)/pinentry/pinentry-$(pinentry_ver).tar.bz2
384 speedo_pkg_gpa_tar = \
385 $(pkgrep)/gpa/gpa-$(gpa_ver).tar.bz2
386 speedo_pkg_gpgex_tar = \
387 $(pkg10rep)/gpgex/gpgex-$(gpgex_ver).tar.bz2
389 $(error invalid value for WHAT (use on of: git release this))
392 speedo_pkg_pkg_config_tar = $(pkg2rep)/pkg-config-$(pkg_config_ver).tar.gz
393 speedo_pkg_zlib_tar = $(pkgrep)/zlib/zlib-$(zlib_ver).tar.gz
394 speedo_pkg_bzip2_tar = $(pkgrep)/bzip2/bzip2-$(bzip2_ver).tar.gz
395 speedo_pkg_adns_tar = $(pkg10rep)/adns/adns-$(adns_ver).tar.bz2
396 speedo_pkg_libiconv_tar = $(pkg2rep)/libiconv-$(libiconv_ver).tar.gz
397 speedo_pkg_gettext_tar = $(pkg2rep)/gettext-$(gettext_ver).tar.gz
398 speedo_pkg_libffi_tar = $(pkg2rep)/libffi-$(libffi_ver).tar.gz
399 speedo_pkg_glib_tar = $(pkg2rep)/glib-$(glib_ver).tar.xz
400 speedo_pkg_libpng_tar = $(pkg2rep)/libpng-$(libpng_ver).tar.bz2
401 speedo_pkg_gdk_pixbuf_tar = $(pkg2rep)/gdk-pixbuf-$(gdk_pixbuf_ver).tar.xz
402 speedo_pkg_atk_tar = $(pkg2rep)/atk-$(atk_ver).tar.bz2
403 speedo_pkg_pango_tar = $(pkg2rep)/pango-$(pango_ver).tar.bz2
404 speedo_pkg_pixman_tar = $(pkg2rep)/pixman-$(pixman_ver).tar.gz
405 speedo_pkg_cairo_tar = $(pkg2rep)/cairo-$(cairo_ver).tar.xz
406 speedo_pkg_gtk__tar = $(pkg2rep)/gtk+-$(gtk__ver).tar.xz
410 # Package build options
413 speedo_pkg_libgpg_error_configure = --enable-static
414 speedo_pkg_w64_libgpg_error_configure = --enable-static
416 speedo_pkg_libassuan_configure = --enable-static
417 speedo_pkg_w64_libassuan_configure = --enable-static
419 speedo_pkg_libgcrypt_configure = --disable-static
421 speedo_pkg_libksba_configure = --disable-static
423 ifeq ($(TARGETOS),w32)
424 speedo_pkg_gnupg_configure = --enable-gpg2-is-gpg --disable-g13 --disable-ntbtls
426 speedo_pkg_gnupg_configure = --disable-g13
428 speedo_pkg_gnupg_extracflags = -g
430 # Create the version info files only for W32 so that they won't get
431 # installed if for example INSTALL_PREFIX=/usr/local is used.
432 ifeq ($(TARGETOS),w32)
433 define speedo_pkg_gnupg_post_install
435 sed -n 's/.*PACKAGE_VERSION "\(.*\)"/\1/p' config.h >$(idir)/INST_VERSION; \
436 sed -n 's/.*W32INFO_VI_PRODUCTVERSION \(.*\)/\1/p' common/w32info-rc.h \
437 |sed 's/,/./g' >$(idir)/INST_PROD_VERSION )
441 # The LDFLAGS is needed for -lintl for glib.
443 speedo_pkg_gpgme_configure = \
444 --enable-static --enable-w32-glib --disable-w32-qt \
445 --with-gpg-error-prefix=$(idir) \
446 LDFLAGS=-L$(idir)/lib
448 speedo_pkg_gpgme_configure = \
449 --disable-static --disable-w32-glib --disable-w32-qt \
450 --with-gpg-error-prefix=$(idir) \
451 LDFLAGS=-L$(idir)/lib
455 ifeq ($(TARGETOS),w32)
456 speedo_pkg_pinentry_configure = --disable-pinentry-gtk2
458 speedo_pkg_pinentry_configure = --enable-pinentry-gtk2
460 speedo_pkg_pinentry_configure += \
461 --disable-pinentry-qt4 \
462 CPPFLAGS=-I$(idir)/include \
463 LDFLAGS=-L$(idir)/lib \
464 CXXFLAGS=-static-libstdc++
467 speedo_pkg_gpa_configure = \
468 --with-libiconv-prefix=$(idir) --with-libintl-prefix=$(idir) \
469 --with-gpgme-prefix=$(idir) --with-zlib=$(idir) \
470 --with-libassuan-prefix=$(idir) --with-gpg-error-prefix=$(idir)
472 speedo_pkg_gpgex_configure = \
473 --with-gpg-error-prefix=$(idir) \
474 --with-libassuan-prefix=$(idir) \
477 speedo_pkg_w64_gpgex_configure = \
478 --with-gpg-error-prefix=$(idir6) \
479 --with-libassuan-prefix=$(idir6) \
487 ifeq ($(TARGETOS),w32)
488 speedo_pkg_zlib_make_args = \
489 -fwin32/Makefile.gcc PREFIX=$(host)- IMPLIB=libz.dll.a
491 speedo_pkg_zlib_make_args_inst = \
492 -fwin32/Makefile.gcc \
493 BINARY_PATH=$(idir)/bin INCLUDE_PATH=$(idir)/include \
494 LIBRARY_PATH=$(idir)/lib SHARED_MODE=1 IMPLIB=libz.dll.a
496 # Zlib needs some special magic to generate a libtool file.
497 # We also install the pc file here.
498 define speedo_pkg_zlib_post_install
499 (set -e; mkdir $(idir)/lib/pkgconfig || true; \
500 cp $(auxsrc)/zlib.pc $(idir)/lib/pkgconfig/; \
502 echo "# Generated by libtool" > lib/libz.la \
503 echo "dlname='../bin/zlib1.dll'" >> lib/libz.la; \
504 echo "library_names='libz.dll.a'" >> lib/libz.la; \
505 echo "old_library='libz.a'" >> lib/libz.la; \
506 echo "dependency_libs=''" >> lib/libz.la; \
507 echo "current=1" >> lib/libz.la; \
508 echo "age=2" >> lib/libz.la; \
509 echo "revision=5" >> lib/libz.la; \
510 echo "installed=yes" >> lib/libz.la; \
511 echo "shouldnotlink=no" >> lib/libz.la; \
512 echo "dlopen=''" >> lib/libz.la; \
513 echo "dlpreopen=''" >> lib/libz.la; \
514 echo "libdir=\"$(idir)/lib\"" >> lib/libz.la)
519 ifeq ($(TARGETOS),w32)
520 speedo_pkg_bzip2_make_args = \
521 CC="$(host)-gcc" AR="$(host)-ar" RANLIB="$(host)-ranlib"
523 speedo_pkg_bzip2_make_args_inst = \
524 PREFIX=$(idir) CC="$(host)-gcc" AR="$(host)-ar" RANLIB="$(host)-ranlib"
527 speedo_pkg_w64_libiconv_configure = \
528 --enable-shared=no --enable-static=yes
530 speedo_pkg_gettext_configure = \
531 --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
532 CPPFLAGS=-I$(idir)/include LDFLAGS=-L$(idir)/lib
533 speedo_pkg_w64_gettext_configure = \
534 --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
535 CPPFLAGS=-I$(idir6)/include LDFLAGS=-L$(idir6)/lib
536 speedo_pkg_gettext_extracflags = -O2
537 # We only need gettext-runtime and there is sadly no top level
538 # configure option for this
539 speedo_pkg_gettext_make_dir = gettext-runtime
542 speedo_pkg_glib_configure = \
543 --disable-modular-tests \
544 --with-libiconv=gnu \
545 CPPFLAGS=-I$(idir)/include \
546 LDFLAGS=-L$(idir)/lib \
548 LIBFFI_CFLAGS=-I$(idir)/lib/libffi-$(libffi_ver)/include \
549 LIBFFI_LIBS=\"-L$(idir)/lib -lffi\"
550 ifeq ($(TARGETOS),w32)
551 speedo_pkg_glib_extracflags = -march=i486
554 ifeq ($(TARGETOS),w32)
555 speedo_pkg_libpng_configure = \
556 CPPFLAGS=\"-I$(idir)/include -DPNG_BUILD_DLL\" \
557 LDFLAGS=\"-L$(idir)/lib\" LIBPNG_DEFINES=\"-DPNG_BUILD_DLL\"
559 speedo_pkg_libpng_configure = \
560 CPPFLAGS=\"-I$(idir)/include\" \
561 LDFLAGS=\"-L$(idir)/lib\"
564 ifneq ($(TARGETOS),w32)
565 speedo_pkg_gdk_pixbuf_configure = --without-libtiff --without-libjpeg
568 speedo_pkg_pixman_configure = \
569 CPPFLAGS=-I$(idir)/include \
570 LDFLAGS=-L$(idir)/lib
572 ifeq ($(TARGETOS),w32)
573 speedo_pkg_cairo_configure = \
574 --disable-qt --disable-ft --disable-fc \
575 --enable-win32 --enable-win32-font \
576 CPPFLAGS=-I$(idir)/include \
577 LDFLAGS=-L$(idir)/lib
579 speedo_pkg_cairo_configure = \
581 CPPFLAGS=-I$(idir)/include \
582 LDFLAGS=-L$(idir)/lib
585 speedo_pkg_pango_configure = \
587 CPPFLAGS=-I$(idir)/include \
588 LDFLAGS=-L$(idir)/lib
590 speedo_pkg_gtk__configure = \
592 CPPFLAGS=-I$(idir)/include \
593 LDFLAGS=-L$(idir)/lib
600 report: report-speedo
604 ifeq ($(TARGETOS),w32)
605 STRIP = i686-w64-mingw32-strip
609 W32CC = i686-w64-mingw32-gcc
614 # The generic speedo code
619 SHA1SUM := $(shell $(topsrc)/build-aux/getswdb.sh --find-sha1sum)
620 ifeq ($(SHA1SUM),false)
621 $(error The sha1sum tool is missing)
625 BUILD_ISODATE=$(shell date -u +%Y-%m-%d)
626 BUILD_DATESTR=$(subst -,,$(BUILD_ISODATE))
628 # The next two macros will work only after gnupg has been build.
629 ifeq ($(TARGETOS),w32)
630 INST_VERSION=$(shell head -1 $(idir)/INST_VERSION)
631 INST_PROD_VERSION=$(shell head -1 $(idir)/INST_PROD_VERSION)
635 speedo_build_list = $(speedo_spkgs)
636 speedo_w64_build_list = $(speedo_w64_spkgs)
638 # To avoid running external commands during the read phase (":=" style
639 # assignments), we check that the targetos has been given
642 # Determine build and host system
643 build := $(shell $(topsrc)/autogen.sh --silent --print-build)
644 ifeq ($(TARGETOS),w32)
645 speedo_autogen_buildopt := --build-w32
646 speedo_autogen_buildopt6 := --build-w64
647 host := $(shell $(topsrc)/autogen.sh --silent --print-host --build-w32)
648 host6:= $(shell $(topsrc)/autogen.sh --silent --print-host --build-w64)
649 speedo_host_build_option := --host=$(host) --build=$(build)
650 speedo_host_build_option6 := --host=$(host6) --build=$(build)
651 speedo_w32_cflags := -mms-bitfields
653 speedo_autogen_buildopt :=
655 speedo_host_build_option :=
662 speedo_makeopt=-j$(MAKE_J)
665 # End non-empty TARGETOS
670 # The playground area is our scratch area, where we unpack, build and
671 # install the packages.
672 $(stampdir)/stamp-directories:
673 $(MKDIR) $(root) || true
674 $(MKDIR) $(stampdir) || true
675 $(MKDIR) $(sdir) || true
676 $(MKDIR) $(bdir) || true
677 $(MKDIR) $(idir) || true
678 ifeq ($(TARGETOS),w32)
679 $(MKDIR) $(bdir6) || true
680 $(MKDIR) $(idir6) || true
682 touch $(stampdir)/stamp-directories
684 # Frob the name $1 by converting all '-' and '+' characters to '_'.
686 $(subst +,_,$(subst -,_,$(1)))
689 # Get the variable $(1) (which may contain '-' and '+' characters).
691 $($(call FROB_macro,$(1)))
694 # Set a couple of common variables.
697 git="$(call GETVAR,speedo_pkg_$(1)_git)"; \
698 gitref="$(call GETVAR,speedo_pkg_$(1)_gitref)"; \
699 tar="$(call GETVAR,speedo_pkg_$(1)_tar)"; \
700 sha1="$(call GETVAR,$(1)_sha1)"; \
701 pkgsdir="$(sdir)/$(1)"; \
702 if [ "$(1)" = "gnupg" ]; then \
706 pkgsdir="$(topsrc)"; \
708 pkgbdir="$(bdir)/$(1)"; \
709 pkgcfg="$(call GETVAR,speedo_pkg_$(1)_configure)"; \
710 tmp="$(speedo_w32_cflags) \
711 $(call GETVAR,speedo_pkg_$(1)_extracflags)"; \
712 if [ x$$$$(echo "$$$$tmp" | tr -d '[:space:]')x != xx ]; then \
713 pkgextracflags="CFLAGS=\"$$$$tmp\""; \
717 pkgmkdir="$(call GETVAR,speedo_pkg_$(1)_make_dir)"; \
718 pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)"; \
719 pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \
720 pkgmkargs_uninst="$(call GETVAR,speedo_pkg_$(1)_make_args_uninst)"; \
721 export PKG_CONFIG="/usr/bin/pkg-config"; \
722 export PKG_CONFIG_PATH="$(idir)/lib/pkgconfig"; \
723 [ "$(TARGETOS)" != native ] && export PKG_CONFIG_LIBDIR=""; \
724 export SYSROOT="$(idir)"; \
725 export PATH="$(idir)/bin:$${PATH}"; \
726 export LD_LIBRARY_PATH="$(idir)/lib:$${LD_LIBRARY_PATH}"
731 git="$(call GETVAR,speedo_pkg_$(1)_git)"; \
732 gitref="$(call GETVAR,speedo_pkg_$(1)_gitref)"; \
733 tar="$(call GETVAR,speedo_pkg_$(1)_tar)"; \
734 sha1="$(call GETVAR,$(1)_sha1)"; \
735 pkgsdir="$(sdir)/$(1)"; \
736 if [ "$(1)" = "gnupg" ]; then \
740 pkgsdir="$(topsrc)"; \
742 pkgbdir="$(bdir6)/$(1)"; \
743 pkgcfg="$(call GETVAR,speedo_pkg_w64_$(1)_configure)"; \
744 tmp="$(speedo_w32_cflags) \
745 $(call GETVAR,speedo_pkg_$(1)_extracflags)"; \
746 if [ x$$$$(echo "$$$$tmp" | tr -d '[:space:]')x != xx ]; then \
747 pkgextracflags="CFLAGS=\"$$$$tmp\""; \
751 pkgmkdir="$(call GETVAR,speedo_pkg_$(1)_make_dir)"; \
752 pkgmkargs="$(call GETVAR,speedo_pkg_$(1)_make_args)"; \
753 pkgmkargs_inst="$(call GETVAR,speedo_pkg_$(1)_make_args_inst)"; \
754 pkgmkargs_uninst="$(call GETVAR,speedo_pkg_$(1)_make_args_uninst)"; \
755 export PKG_CONFIG="/usr/bin/pkg-config"; \
756 export PKG_CONFIG_PATH="$(idir6)/lib/pkgconfig"; \
757 [ "$(TARGETOS)" != native ] && export PKG_CONFIG_LIBDIR=""; \
758 export SYSROOT="$(idir6)"; \
759 export PATH="$(idir6)/bin:$${PATH}"; \
760 export LD_LIBRARY_PATH="$(idir6)/lib:$${LD_LIBRARY_PATH}"
764 # Template for source packages.
766 # Note that the gnupg package is special: The package source dir is
767 # the same as the topsrc dir and thus we need to detect the gnupg
768 # package and cd to that directory. We also test that no in-source build
769 # has been done. autogen.sh is not run for gnupg.
773 $(stampdir)/stamp-$(1)-00-unpack: $(stampdir)/stamp-directories
775 @echo "speedo: * $(1)"
777 @(set -e; cd $(sdir); \
778 $(call SETVARS,$(1)); \
779 if [ "$(WHAT)" = "this" ]; then \
780 echo "speedo: using included source"; \
781 elif [ "$(1)" = "gnupg" ]; then \
783 if [ -f config.log ]; then \
784 echo "GnuPG has already been build in-source" >&2 ;\
785 echo "Please run \"make distclean\" and retry" >&2 ;\
788 echo "speedo: unpacking gnupg not needed"; \
789 elif [ -n "$$$${git}" ]; then \
790 echo "speedo: unpacking $(1) from $$$${git}:$$$${gitref}"; \
791 git clone -b "$$$${gitref}" "$$$${git}" "$$$${pkg}"; \
793 AUTOGEN_SH_SILENT=1 ./autogen.sh; \
794 elif [ -n "$$$${tar}" ]; then \
795 echo "speedo: unpacking $(1) from $$$${tar}"; \
796 case "$$$${tar}" in \
797 *.gz) pretar=zcat ;; \
798 *.bz2) pretar=bzcat ;; \
799 *.xz) pretar=xzcat ;; \
802 [ -f tmp.tgz ] && rm tmp.tgz; \
803 case "$$$${tar}" in \
804 /*) $$$${pretar} < $$$${tar} | tar xf - ;; \
805 *) wget -q -O - $$$${tar} | tee tmp.tgz \
806 | $$$${pretar} | tar x$$$${opt}f - ;; \
808 if [ -f tmp.tgz ]; then \
809 if [ -n "$$$${sha1}" ]; then \
810 tmp=$$$$($(SHA1SUM) <tmp.tgz|cut -d' ' -f1);\
811 if [ "$$$${tmp}" != "$$$${sha1}" ]; then \
813 echo "speedo: ERROR: checksum mismatch for $(1)";\
819 echo "speedo: Warning: No checksum known for $(1)";\
824 base=`echo "$$$${tar}" | sed -e 's,^.*/,,' \
825 | sed -e 's,\.tar.*$$$$,,'`; \
826 mv $$$${base} $(1); \
827 patch="$(patdir)/$(1)-$$$${base#$(1)-}.patch";\
828 if [ -x "$$$${patch}" ]; then \
829 echo "speedo: applying patch $$$${patch}"; \
830 cd $(1); "$$$${patch}"; \
831 elif [ -f "$$$${patch}" ]; then \
832 echo "speedo: warning: $$$${patch} is not executable"; \
835 echo "speedo: unpacking $(1) from UNKNOWN"; \
837 @touch $(stampdir)/stamp-$(1)-00-unpack
839 $(stampdir)/stamp-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack
840 @echo "speedo: configuring $(1)"
841 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
842 @echo "speedo: configure run not required"
843 else ifneq ($(findstring $(1),$(speedo_gnupg_style)),)
844 @($(call SETVARS,$(1)); \
845 mkdir "$$$${pkgbdir}"; \
846 cd "$$$${pkgbdir}"; \
847 if [ -n "$(speedo_autogen_buildopt)" ]; then \
848 eval AUTOGEN_SH_SILENT=1 w32root="$(idir)" \
849 "$$$${pkgsdir}/autogen.sh" \
850 $(speedo_autogen_buildopt) \
851 $$$${pkgcfg} $$$${pkgextracflags}; \
853 eval "$$$${pkgsdir}/configure" \
855 --enable-maintainer-mode \
857 $$$${pkgcfg} $$$${pkgextracflags}; \
860 @($(call SETVARS,$(1)); \
861 mkdir "$$$${pkgbdir}"; \
862 cd "$$$${pkgbdir}"; \
863 eval "$$$${pkgsdir}/configure" \
864 --silent $(speedo_host_build_option) \
866 $$$${pkgcfg} $$$${pkgextracflags}; \
869 @touch $(stampdir)/stamp-$(1)-01-configure
871 # Note that unpack has no 64 bit version becuase it is just the source.
872 # Fixme: We should use templates to create the standard and w64
873 # version of these rules.
874 $(stampdir)/stamp-w64-$(1)-01-configure: $(stampdir)/stamp-$(1)-00-unpack
875 @echo "speedo: configuring $(1) (64 bit)"
876 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
877 @echo "speedo: configure run not required"
878 else ifneq ($(findstring $(1),$(speedo_gnupg_style)),)
879 @($(call SETVARS_W64,$(1)); \
880 mkdir "$$$${pkgbdir}"; \
881 cd "$$$${pkgbdir}"; \
882 if [ -n "$(speedo_autogen_buildopt)" ]; then \
883 eval AUTOGEN_SH_SILENT=1 w64root="$(idir6)" \
884 "$$$${pkgsdir}/autogen.sh" \
885 $(speedo_autogen_buildopt6) \
886 $$$${pkgcfg} $$$${pkgextracflags}; \
888 eval "$$$${pkgsdir}/configure" \
890 --enable-maintainer-mode \
891 --prefix="$(idir6)" \
892 $$$${pkgcfg} $$$${pkgextracflags}; \
895 @($(call SETVARS_W64,$(1)); \
896 mkdir "$$$${pkgbdir}"; \
897 cd "$$$${pkgbdir}"; \
898 eval "$$$${pkgsdir}/configure" \
899 --silent $(speedo_host_build_option6) \
900 --prefix="$(idir6)" \
901 $$$${pkgcfg} $$$${pkgextracflags}; \
904 @touch $(stampdir)/stamp-w64-$(1)-01-configure
907 $(stampdir)/stamp-$(1)-02-make: $(stampdir)/stamp-$(1)-01-configure
908 @echo "speedo: making $(1)"
909 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
910 @($(call SETVARS,$(1)); \
911 cd "$$$${pkgsdir}"; \
912 test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
913 if test "$$$${pkg}" = zlib -a "$(TARGETOS)" != w32 ; then \
914 ./configure --prefix="$(idir)" ; \
916 $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
918 @($(call SETVARS,$(1)); \
919 cd "$$$${pkgbdir}"; \
920 test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
921 $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
923 @touch $(stampdir)/stamp-$(1)-02-make
925 $(stampdir)/stamp-w64-$(1)-02-make: $(stampdir)/stamp-w64-$(1)-01-configure
926 @echo "speedo: making $(1) (64 bit)"
927 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
928 @($(call SETVARS_W64,$(1)); \
929 cd "$$$${pkgsdir}"; \
930 test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
931 $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
933 @($(call SETVARS_W64,$(1)); \
934 cd "$$$${pkgbdir}"; \
935 test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
936 $(MAKE) --no-print-directory $(speedo_makeopt) $$$${pkgmkargs} V=0)
938 @touch $(stampdir)/stamp-w64-$(1)-02-make
940 # Note that post_install must come last because it may be empty and
941 # "; ;" is a syntax error.
942 $(stampdir)/stamp-$(1)-03-install: $(stampdir)/stamp-$(1)-02-make
943 @echo "speedo: installing $(1)"
944 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
945 @($(call SETVARS,$(1)); \
946 cd "$$$${pkgsdir}"; \
947 test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
948 $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install V=0;\
949 $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
951 @($(call SETVARS,$(1)); \
952 cd "$$$${pkgbdir}"; \
953 test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
954 $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install-strip V=0;\
955 $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
957 touch $(stampdir)/stamp-$(1)-03-install
959 $(stampdir)/stamp-w64-$(1)-03-install: $(stampdir)/stamp-w64-$(1)-02-make
960 @echo "speedo: installing $(1) (64 bit)"
961 ifneq ($(findstring $(1),$(speedo_make_only_style)),)
962 @($(call SETVARS_W64,$(1)); \
963 cd "$$$${pkgsdir}"; \
964 test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
965 $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install V=0;\
966 $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
968 @($(call SETVARS_W64,$(1)); \
969 cd "$$$${pkgbdir}"; \
970 test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}"; \
971 $(MAKE) --no-print-directory $$$${pkgmkargs_inst} install-strip V=0;\
972 $(call speedo_pkg_$(call FROB_macro,$(1))_post_install))
974 touch $(stampdir)/stamp-w64-$(1)-03-install
976 $(stampdir)/stamp-final-$(1): $(stampdir)/stamp-$(1)-03-install
977 @echo "speedo: $(1) done"
978 @touch $(stampdir)/stamp-final-$(1)
980 $(stampdir)/stamp-w64-final-$(1): $(stampdir)/stamp-w64-$(1)-03-install
981 @echo "speedo: $(1) (64 bit) done"
982 @touch $(stampdir)/stamp-w64-final-$(1)
986 @echo "speedo: uninstalling $(1)"
987 @($(call SETVARS,$(1)); \
988 (cd "$$$${pkgbdir}" 2>/dev/null && \
989 $(MAKE) --no-print-directory \
990 $$$${pkgmkargs_uninst} uninstall V=0 ) || true;\
991 if [ "$(1)" = "gnupg" ]; then \
992 rm -fR "$$$${pkgbdir}" || true ;\
994 rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}" || true;\
996 -rm -f $(stampdir)/stamp-final-$(1) $(stampdir)/stamp-$(1)-*
1000 build-$(1): $(stampdir)/stamp-final-$(1)
1003 .PHONY : report-$(1)
1005 @($(call SETVARS,$(1)); \
1007 if [ -n "$$$${git}" ]; then \
1008 if [ -e "$$$${pkgsdir}/.git" ]; then \
1009 cd "$$$${pkgsdir}" && \
1014 elif [ -n "$$$${tar}" ]; then \
1015 base=`echo "$$$${tar}" | sed -e 's,^.*/,,' \
1016 | sed -e 's,\.tar.*$$$$,,'`; \
1023 # Insert the template for each source package.
1024 $(foreach spkg, $(speedo_spkgs), $(eval $(call SPKG_template,$(spkg))))
1026 $(stampdir)/stamp-final: $(stampdir)/stamp-directories
1027 ifeq ($(TARGETOS),w32)
1028 $(stampdir)/stamp-final: $(addprefix $(stampdir)/stamp-w64-final-,$(speedo_w64_build_list))
1030 $(stampdir)/stamp-final: $(addprefix $(stampdir)/stamp-final-,$(speedo_build_list))
1031 touch $(stampdir)/stamp-final
1033 all-speedo: $(stampdir)/stamp-final
1035 report-speedo: $(addprefix report-,$(speedo_build_list))
1037 # Just to check if we catched all stamps.
1039 $(RM) -fR $(stampdir)
1049 ifeq ($(TARGETOS),w32)
1052 for i in 00 01 02 03; do sleep 1;touch PLAY/stamps/stamp-*-${i}-*;done
1054 tarname="$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).tar" ;\
1055 [ -f "$$tarname" ] && rm "$$tarname" ;\
1056 tar -C $(topsrc) -cf "$$tarname" --exclude-backups --exclude-vc \
1057 --transform='s,^\./,$(INST_NAME)-$(INST_VERSION)/,' \
1058 --anchored --exclude './PLAY' . ;\
1059 tar --totals -rf "$$tarname" --exclude-backups --exclude-vc \
1060 --transform='s,^,$(INST_NAME)-$(INST_VERSION)/,' \
1061 PLAY/stamps/stamp-*-00-unpack PLAY/src ;\
1066 # Extract the two latest news entries. */
1067 $(bdir)/NEWS.tmp: $(topsrc)/NEWS
1068 awk '/^Notewo/ {if(okay>1){exit}; okay++};okay {print $0}' \
1069 <$(topsrc)/NEWS >$(bdir)/NEWS.tmp
1071 $(bdir)/README.txt: $(bdir)/NEWS.tmp $(topsrc)/README $(w32src)/README.txt \
1072 $(w32src)/pkg-copyright.txt
1074 -e '/!NEWSFILE!/{r $(bdir)/NEWS.tmp' -e 'd;}' \
1075 -e '/!GNUPGREADME!/{r $(topsrc)/README' -e 'd;}' \
1076 -e '/!PKG-COPYRIGHT!/{r $(w32src)/pkg-copyright.txt' -e 'd;}' \
1077 -e 's,!VERSION!,$(INST_VERSION),g' \
1078 < $(w32src)/README.txt \
1080 | awk '{printf "%s\r\n", $$0}' >$(bdir)/README.txt
1082 $(bdir)/g4wihelp.dll: $(w32src)/g4wihelp.c $(w32src)/exdll.h
1083 (set -e; cd $(bdir); \
1084 $(W32CC) -I. -shared -O2 -o g4wihelp.dll $(w32src)/g4wihelp.c \
1086 $(STRIP) g4wihelp.dll)
1088 w32_insthelpers: $(bdir)/g4wihelp.dll
1090 $(bdir)/inst-options.ini: $(w32src)/inst-options.ini
1091 cat $(w32src)/inst-options.ini >$(bdir)/inst-options.ini
1093 extra_installer_options =
1094 ifeq ($(WITH_GUI),1)
1095 extra_installer_options += -DWITH_GUI=1
1098 installer: all w32_insthelpers $(w32src)/inst-options.ini $(bdir)/README.txt
1100 -DINST_DIR=$(idir) \
1101 -DINST6_DIR=$(idir6) \
1102 -DBUILD_DIR=$(bdir) \
1103 -DTOP_SRCDIR=$(topsrc) \
1104 -DW32_SRCDIR=$(w32src) \
1105 -DBUILD_ISODATE=$(BUILD_ISODATE) \
1106 -DBUILD_DATESTR=$(BUILD_DATESTR) \
1107 -DNAME=$(INST_NAME) \
1108 -DVERSION=$(INST_VERSION) \
1109 -DPROD_VERSION=$(INST_PROD_VERSION) \
1110 $(extra_installer_options) $(w32src)/inst.nsi
1111 @echo "Ready: $(idir)/$(INST_NAME)-$(INST_VERSION)_$(BUILD_DATESTR).exe"
1118 # Check availibility of standard tools
1124 # Mark phony targets
1126 .PHONY: all all-speedo report-speedo clean-stamps clean-speedo installer \
1127 w32_insthelpers check-tools