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