Build with -e
[gpg4win.git] / src / gpg4win.mk.in
1 # gpg4win.m4.in - Installer for GnuPG 4 Windows Makefile.   -*- makefile -*-
2 # Copyright (C) 2005, 2009 g10 Code GmbH
3 #
4 # This file is part of GPG4Win.
5 #
6 # GPG4Win is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # GPG4Win is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19
20
21 # No servicable parts below this line :)
22
23
24 # These paths must be absolute, as we switch directories pretty often.
25 root := $(shell pwd)/playground
26 bdir := $(root)/build
27 idir := $(root)/install
28 ipdir := $(root)/install/pkgs
29 tsdir := $(shell pwd)/${top_srcdir}
30 pdir := $(shell pwd)/${top_srcdir}/patches
31 ex_idir := $(root)/install-ex
32 ex_ipdir := $(root)/install-ex/pkgs
33
34 # We collect the names of all pkg files used.
35 pkg_files =
36
37 # The playground area is our scratch area, where we unpack, build and
38 # install the packages.
39 stamps/stamp-directories:
40         $(MKDIR) stamps
41         $(MKDIR) playground
42         $(MKDIR) $(bdir)
43         $(MKDIR) $(idir)
44         $(MKDIR) $(ipdir)
45         $(if $GPGEX_ADD_HOST, $(MKDIR) $(ex_idir))
46         $(if $GPGEX_ADD_HOST, $(MKDIR) $(ex_ipdir))
47         touch $(bdir)/versioninfo.txt
48         touch stamps/stamp-directories
49
50
51 # Frob the name $1 by converting all '-' and '+' characters to '_'.
52 define FROB_macro
53 $(subst +,_,$(subst -,_,$(1)))
54 endef
55
56 # Get the variable $(1) (which may contain '-' and '+' characters).
57 define GETVAR
58 $($(call FROB_macro,$(1)))
59 endef
60
61 # Set a couple of common variables.
62 define SETVARS
63         set -e; \
64         pkg="$(call GETVAR,gpg4win_pkg_$(1))";                          \
65         pkg_version="$(1)-$(call GETVAR,gpg4win_pkg_$(1)_version)";     \
66         pkgsdir="$(bdir)/$$$${pkg_version}";                            \
67         pkgbdir="$(bdir)/$$$${pkg_version}-build";                      \
68         pkgpdir="$(pdir)/$$$${pkg_version}";                            \
69         pkgpbdir="$(pdir)/$(1)";                                        \
70         pkgidir="$(ipdir)/$$$${pkg_version}";                           \
71         pkg_dev="$(call GETVAR,gpg4win_pkg_$(1)_dev)";                  \
72         pkg_version_dev="$(1)-dev-$(call GETVAR,gpg4win_pkg_$(1)_version)"; \
73         pkgidir_dev="$(ipdir)/$$$${pkg_version_dev}";                   \
74         pkgcfg="$(call GETVAR,gpg4win_pkg_$(1)_configure)";             \
75         pkgextracflags="$(call GETVAR,gpg4win_pkg_$(1)_extracflags)";   \
76         pkgmkargs="$(call GETVAR,gpg4win_pkg_$(1)_make_args)";          \
77         pkgmkargs_inst="$(call GETVAR,gpg4win_pkg_$(1)_make_args_inst)";\
78         pkgmkdir="$(call GETVAR,gpg4win_pkg_$(1)_make_dir)";             \
79         pkgmkdir_inst="$(call GETVAR,gpg4win_pkg_$(1)_make_dir)";        \
80         export PKG_CONFIG="$(tsdir)/src/pkg-config";                    \
81         export PKG_CONFIG_PATH="$(idir)/lib/pkgconfig";                 \
82         export PKG_CONFIG_LIBDIR="";                                    \
83         export PATH="$(idir)/bin:$${PATH}";                             \
84         export SYSROOT="$(idir)";                                       \
85         export CONFIG_SITE="$(tsdir)/src/config.site"
86 endef
87
88 # Set variables for building in an additional architecture
89 define SETVARS_EX
90         set -e; \
91         pkg="$(call GETVAR,gpg4win_pkg_$(1))";                              \
92         pkg_version="$(1)-$(call GETVAR,gpg4win_pkg_$(1)_version)";         \
93         pkgsdir="$(bdir)/$$$${pkg_version}";                                \
94         pkgbdir="$(bdir)/$$$${pkg_version}-ex-build";                       \
95         pkgpdir="$(pdir)/$$$${pkg_version}";                                \
96         pkgpbdir="$(pdir)/$(1)";                                            \
97         pkgidir="$(ex_ipdir)/$$$${pkg_version}";                            \
98         pkgidir_dev="$(ex_ipdir)/$$$${pkg_version_dev}";                    \
99         pkgcfg="$(call GETVAR,gpg4win_pkg_$(1)_ex_configure)";              \
100         pkgextracflags="$(call GETVAR,gpg4win_pkg_$(1)_ex_extracflags)";    \
101         pkgmkargs="$(call GETVAR,gpg4win_pkg_$(1)_ex_make_args)";           \
102         pkgmkargs_inst="$(call GETVAR,gpg4win_pkg_$(1)_ex_make_args_inst)"; \
103         pkgmkdir="$(call GETVAR,gpg4win_pkg_$(1)_ex_make_dir)";             \
104         pkgmkdir_inst="$(call GETVAR,gpg4win_pkg_$(1)_ex_make_dir)";        \
105         export PKG_CONFIG="$(tsdir)/src/pkg-config";                        \
106         export PKG_CONFIG_PATH="$(ex_idir)/lib/pkgconfig";                  \
107         export PKG_CONFIG_LIBDIR="";                                        \
108         export PATH="$(ex_idir)/bin:$${PATH}";                              \
109         export SYSROOT="$(ex_idir)"
110 endef
111
112 # Support macro.  Unpack the archive $(1).
113 define DEFLATE_macro
114         rm -rf $$$${pkgsdir}; \
115         case "$(1)" in                  \
116           */qtbase*.*.tar.xz)          \
117             $(TAR) -xJ --transform='s,^qtbase-opensource-src,qtbase,' -f "$(1)" ;; \
118           */qttools*.*.tar.xz)          \
119             $(TAR) -xJ --transform='s,^qttools-opensource-src,qttools,' -f "$(1)" ;; \
120           */qtwinextras*.*.tar.xz)          \
121             $(TAR) -xJ --transform='s,^qtwinextras-opensource-src,qtwinextras,' -f "$(1)" ;; \
122           */qtsvg*.*.tar.xz)          \
123             $(TAR) -xJ --transform='s,^qtsvg-opensource-src,qtsvg,' -f "$(1)" ;; \
124           */boost*.*.tar.bz2)          \
125             $(TAR) -xj --transform='s,^boost_1_60_0,boost-1.60.0,' -f "$(1)" ;; \
126           *.tar.gz | *.tgz)             \
127             $(TAR) xzf "$(1)" ;;        \
128           *.tar.bz2 | *.tbz2 | *.tbz)   \
129             $(TAR) xjf "$(1)" ;;        \
130           *.tar.xz )                    \
131             $(TAR) xJf "$(1)" ;;        \
132           *.exe )                               \
133             cp "$(1)" .       ;;        \
134           *.zip)                        \
135             $(UNZIP) -o "$(1)" ;;               \
136         esac
137 endef
138
139 # Support macro.  Strip all exe files below $(1).
140 define STRIP_macro
141         if test -z '$(DEBUG)'; then                     \
142           (cd $(1);                                     \
143            for f in `find . -name \*.exe -o -name \*.dll`; do           \
144            echo Calling $(STRIP) "$$$${pkg_version}/$$$${f}"; \
145            $(STRIP) "$$$${f}"; done);                   \
146         fi
147 endef
148
149 # Support macro.  Strip all exe files below $(1) using STRIP_EX.
150 define STRIP_EX_macro
151         if test -z '$(DEBUG)'; then                     \
152           (cd $(1);                                     \
153            for f in `find . -name \*.exe -o -name \*.dll`; do           \
154            echo Calling $(STRIP_EX) "$$$${pkg_version}/$$$${f}"; \
155            $(STRIP_EX) "$$$${f}"; done);                        \
156         fi
157 endef
158
159 define GETDEPS
160   $(addprefix stamps/stamp-final-, $(call GETVAR,gpg4win_pkg_$(1)_deps))
161 endef
162
163 define GETDEPS_EX
164   $(addprefix stamps/stamp-final-ex-, $(call GETVAR,gpg4win_pkg_$(1)_deps))
165 endef
166
167 # Template for source packages to build for an additional host
168
169 define EXPKG_template_
170
171 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
172
173 stamps/stamp-$(1)-ex-00-unpack: stamps/stamp-$(1)-00-unpack
174         touch stamps/stamp-$(1)-ex-00-unpack
175
176 stamps/stamp-$(1)-ex-01-patch: stamps/stamp-$(1)-ex-00-unpack stamps/stamp-$(1)-01-patch
177         touch stamps/stamp-$(1)-ex-01-patch
178
179 stamps/stamp-$(1)-ex-02-configure: stamps/stamp-$(1)-ex-01-patch
180         ($(call SETVARS_EX,$(1));                               \
181          mkdir "$$$${pkgbdir}";                         \
182           cd "$$$${pkgbdir}";                           \
183          eval "../$$$${pkg_version}/configure"          \
184                 --prefix="$$$${pkgidir}"                \
185                 --host=$(GPGEX_ADD_HOST)                \
186                 --build=$(build)                        \
187                 $$$${pkgcfg} CFLAGS=\"-mms-bitfields $$$${pkgextracflags}\";\
188          shopt -s nullglob;                                     \
189          for pfile in "$$$${pkgpbdir}"/*.postcfg                \
190                        "$$$${pkgpdir}"/*.postcfg ; do           \
191            (cd "$$$${pkgsdir}"; "$$$${pfile}")                  \
192          done;                                                  \
193          for pfile in "$$$${pkgpbdir}"/*.postcfg-build          \
194                        "$$$${pkgpdir}"/*.postcfg-build ; do     \
195            (cd "$$$${pkgbdir}"; "$$$${pfile}")                  \
196          done)
197         touch stamps/stamp-$(1)-ex-02-configure
198
199 stamps/stamp-$(1)-ex-03-make: stamps/stamp-$(1)-ex-02-configure
200         ($(call SETVARS_EX,$(1));                               \
201           cd "$$$${pkgbdir}";                           \
202           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}";      \
203           $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs} || \
204           $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs} || \
205           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs})
206         touch stamps/stamp-$(1)-ex-03-make
207
208 # Note that post_install must come last because it may be empty and
209 # "; ;" is a syntax error.
210 stamps/stamp-$(1)-ex-04-install: stamps/stamp-$(1)-ex-03-make
211         ($(call SETVARS_EX,$(1));                               \
212           cd "$$$${pkgbdir}";                           \
213           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
214           $(call STRIP_EX_macro,"$$$${pkgidir}");               \
215           rm -f "$$$${pkgidir}/share/info/dir";         \
216           $(call gpg4win_pkg_$(call FROB_macro,$(1))_ex_post_install))
217         touch stamps/stamp-$(1)-ex-04-install
218
219 stamps/stamp-$(1)-ex-05-stow: stamps/stamp-$(1)-ex-04-install
220         ($(call SETVARS_EX,$(1));                               \
221          cd $(ex_ipdir);                                        \
222          $(STOW) -t $(ex_idir) "$$$${pkg_version}")
223         touch stamps/stamp-$(1)-ex-05-stow
224
225 stamps/stamp-final-ex-$(1): stamps/stamp-$(1)-ex-05-stow
226         touch stamps/stamp-final-ex-$(1)
227
228 .PHONY : clean-ex-$(1)
229 clean-ex-$(1):
230         ($(call SETVARS_EX,$(1));                               \
231          (cd $(ex_ipdir) &&                             \
232           ($(STOW) -D "$$$${pkg_version}";              \
233            rm -fR "$$$${pkg_version}"));                \
234          rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
235         rm -f stamps/stamp-final-ex-$(1) stamps/stamp-$(1)-ex-*
236
237 endef
238
239 define EXPKG_template
240 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
241   $(call EXPKG_template_,$1))
242 endef
243
244
245 # Template for source packages.
246
247 define SPKG_template_
248
249 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
250
251 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
252         (cd $(bdir);                                    \
253          $(call SETVARS,$(1));                          \
254          $(call DEFLATE_macro,$$$${pkg}))
255         touch stamps/stamp-$(1)-00-unpack
256
257 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
258         (shopt -s nullglob;                             \
259          $(call SETVARS,$(1));                          \
260          for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do  \
261            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
262          done)
263         touch stamps/stamp-$(1)-01-patch
264
265 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
266         ($(call SETVARS,$(1));                          \
267          mkdir "$$$${pkgbdir}";                         \
268           cd "$$$${pkgbdir}";                           \
269          eval "../$$$${pkg_version}/configure"          \
270                 --prefix="$$$${pkgidir}"                \
271                 --host=$(host)                          \
272                 --build=$(build)                        \
273                 $$$${pkgcfg} CFLAGS=\"-mms-bitfields $$$${pkgextracflags}\";\
274          shopt -s nullglob;                                     \
275          for pfile in "$$$${pkgpbdir}"/*.postcfg                \
276                        "$$$${pkgpdir}"/*.postcfg ; do           \
277            (cd "$$$${pkgsdir}"; "$$$${pfile}")                  \
278          done;                                                  \
279          for pfile in "$$$${pkgpbdir}"/*.postcfg-build          \
280                        "$$$${pkgpdir}"/*.postcfg-build ; do     \
281            (cd "$$$${pkgbdir}"; "$$$${pfile}")                  \
282          done)
283         touch stamps/stamp-$(1)-02-configure
284
285 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-02-configure
286         ($(call SETVARS,$(1));                          \
287           cd "$$$${pkgbdir}";                           \
288           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}";      \
289           $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs} || \
290           $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs} || \
291           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs})
292         touch stamps/stamp-$(1)-03-make
293
294 # Note that post_install must come last because it may be empty and
295 # "; ;" is a syntax error.
296 stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
297         ($(call SETVARS,$(1));                          \
298           cd "$$$${pkgbdir}";                           \
299           cd "$$$${pkgmkdir_inst}";                     \
300           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
301           $(call STRIP_macro,"$$$${pkgidir}");          \
302           rm -f "$$$${pkgidir}/share/info/dir";         \
303           $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
304         touch stamps/stamp-$(1)-04-install
305
306 stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
307         ($(call SETVARS,$(1));                          \
308          cd $(ipdir);                                   \
309          $(STOW) "$$$${pkg_version}")
310         touch stamps/stamp-$(1)-05-stow
311
312 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
313         touch stamps/stamp-final-$(1)
314
315 .PHONY : clean-$(1)
316 clean-$(1):
317         ($(call SETVARS,$(1));                          \
318          (cd $(ipdir) &&                                \
319           ($(STOW) -D "$$$${pkg_version}";              \
320            rm -fR "$$$${pkg_version}"));                \
321          rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
322         rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
323
324 endef
325
326 define SPKG_template
327 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
328   $(call SPKG_template_,$1))
329 endef
330
331
332 # Template for source packages using only make and no build
333 # directory.
334
335 define MPKG_template_
336
337 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
338
339 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
340         (cd $(bdir);                                    \
341          $(call SETVARS,$(1));                          \
342          $(call DEFLATE_macro,$$$${pkg}))
343         touch stamps/stamp-$(1)-00-unpack
344
345 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
346         (shopt -s nullglob;                             \
347          $(call SETVARS,$(1));                          \
348          for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do \
349            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
350          done)
351         touch stamps/stamp-$(1)-01-patch
352
353 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-01-patch
354         ($(call SETVARS,$(1));                          \
355           cd "$$$${pkgsdir}";                           \
356           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}";      \
357           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs})
358         touch stamps/stamp-$(1)-03-make
359
360 stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
361         ($(call SETVARS,$(1));                          \
362           cd "$$$${pkgsdir}";                           \
363           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
364           $(call STRIP_macro,"$$$${pkgidir}"); \
365           $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
366         touch stamps/stamp-$(1)-04-install
367
368 stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
369         ($(call SETVARS,$(1));                          \
370          cd $(ipdir);                                   \
371          $(STOW) "$$$${pkg_version}")
372         touch stamps/stamp-$(1)-05-stow
373
374 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
375         touch stamps/stamp-final-$(1)
376
377 .PHONY : clean-$(1)
378 clean-$(1):
379         ($(call SETVARS,$(1));                          \
380          (cd $(ipdir) &&                                \
381           ($(STOW) -D "$$$${pkg_version}";              \
382            rm -fR "$$$${pkg_version}"));                \
383          rm -fR "$$$${pkgsdir}")
384         rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
385
386 endef
387
388 define MPKG_template
389 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
390   $(call MPKG_template_,$1))
391 endef
392
393
394
395 # Template for binary packages.
396
397 define BPKG_template_
398
399 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
400 pkg_files += $(call GETVAR,gpg4win_pkg_$(1)_dev)
401
402 stamps/stamp-$(1)-00-install: stamps/stamp-directories $(call GETDEPS,$(1))
403         ($(call SETVARS,$(1));                          \
404          $(MKDIR) "$$$${pkgidir}";                      \
405          cd $$$${pkgidir};                              \
406          $(call DEFLATE_macro,$$$${pkg}))
407         touch stamps/stamp-$(1)-00-install
408
409 # Note that post_install must come last because it may be empty and
410 # "; ;" is a syntax error.
411 stamps/stamp-$(1)-01-install-dev: stamps/stamp-$(1)-00-install
412         ($(call SETVARS,$(1));                          \
413          $(MKDIR) "$$$${pkgidir_dev}";                  \
414          (cd $$$${pkgidir_dev};                         \
415           $(call DEFLATE_macro,$$$${pkg_dev}));         \
416          $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
417         touch stamps/stamp-$(1)-01-install-dev
418
419 stamps/stamp-$(1)-02-stow: stamps/stamp-$(1)-01-install-dev
420         ($(call SETVARS,$(1));                          \
421          cd $(ipdir);                                   \
422          $(STOW) "$$$${pkg_version}")
423         touch stamps/stamp-$(1)-02-stow
424
425 stamps/stamp-$(1)-03-stow-dev: stamps/stamp-$(1)-02-stow
426         ($(call SETVARS,$(1));                          \
427          cd $(ipdir);                                   \
428          $(STOW) "$$$${pkg_version_dev}")
429         touch stamps/stamp-$(1)-03-stow-dev
430
431 stamps/stamp-final-$(1): stamps/stamp-$(1)-03-stow-dev
432         touch stamps/stamp-final-$(1)
433
434 .PHONY : clean-$(1)
435 clean-$(1):
436         ($(call SETVARS,$(1));                          \
437          cd $(ipdir) &&                                 \
438          ($(STOW) -D "$$$${pkg_version}";               \
439           $(STOW) -D "$$$${pkg_version_dev}";           \
440           rm -fR "$$$${pkg_version}" "$$$${pkg_version_dev}"))
441         rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
442
443 endef
444
445 define BPKG_template
446 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
447   $(call BPKG_template_,$1))
448 endef
449
450
451 # Template for internal packages.
452
453 define IPKG_template
454
455 stamps/stamp-final-$(1): stamps/stamp-directories $(call GETDEPS,$(1))
456         touch stamps/stamp-final-$(1)
457 endef
458
459 # Template for README files
460 # (The final awk command converts the file endings).
461
462 define README_template
463 README.$(1).txt : versioninfo.txt NEWS.tmp $(top_srcdir)/doc/README.$(1).txt \
464                   COMPONENTS-list.tmp $(top_srcdir)/doc/beta-warning.txt
465         sed -e '/^;.*/d;/!VERSIONINFO!/{r versioninfo.txt' -e 'd;}' \
466         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
467         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
468         -e '/!COMPONENTS!/{r COMPONENTS-list.tmp' -e 'd;}' \
469         -e '/!PKG-COPYRIGHT!/{r $(top_srcdir)/doc/pkg-copyright.txt' -e 'd;}' \
470         -e 's,!VERSION!,$(VERSION),g' \
471         -e 's,!BUILD_ISODATE!,$(BUILD_ISODATE),g' \
472            < $(top_srcdir)/doc/README.$(1).txt \
473            | (if echo "$(VERSION)" | egrep 'svn|rc|beta|git' >/dev/null; then \
474               sed -e '/!BETA-WARNING!/{r $(top_srcdir)/doc/beta-warning.txt' \
475                -e 'd;}'; else sed -e 's,!BETA-WARNING!,,g'; fi) \
476            | awk '{printf "%s\r\n", $$$$0}' >README.$(1).txt
477 endef
478
479 define HOWTO_template
480 HOWTO-$(1).$(2).txt : $(top_srcdir)/doc/HOWTO-$(1).$(2).txt
481         sed -e '/^;.*/d' \
482         -e 's,!VERSION!,$(VERSION),g' \
483         -e 's,!BUILD_ISODATE!,$(BUILD_ISODATE),g' \
484            < $(top_srcdir)/doc/HOWTO-$(1).$(2).txt \
485         | awk '{printf "%s\r\n", $$$$0}' > HOWTO-$(1).$(2).txt
486 endef
487
488 # Template for source packages of KDE software
489 define KDEPKG_template_
490
491 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
492
493 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
494         (cd $(bdir);                                    \
495          $(call SETVARS,$(1));                          \
496          $(call DEFLATE_macro,$$$${pkg}))
497         touch stamps/stamp-$(1)-00-unpack
498
499 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
500         (shopt -s nullglob;                             \
501          $(call SETVARS,$(1));                          \
502          for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do  \
503            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
504          done)
505         touch stamps/stamp-$(1)-01-patch
506
507 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
508         ($(call SETVARS,$(1));                          \
509          mkdir "$$$${pkgbdir}";                         \
510           cd "$$$${pkgbdir}";                           \
511          cmake          \
512                 -DCMAKE_INSTALL_PREFIX="$$$${pkgidir}" \
513                 -DCMAKE_PREFIX_PATH="$$$${pkgidir}" \
514                 -DCMAKE_TOOLCHAIN_FILE=$(abs_top_srcdir)/src/toolchain.cmake \
515                 -DBUILD_TESTING=False \
516                 $$$${pkgcfg} $$$${pkgextracflags} "../$$$${pkg_version}") && \
517         touch stamps/stamp-$(1)-02-configure
518
519 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-02-configure
520         ($(call SETVARS,$(1));                          \
521           cd "$$$${pkgbdir}";                           \
522           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}";      \
523           $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs})
524         touch stamps/stamp-$(1)-03-make
525
526 # Note that post_install must come last because it may be empty and
527 # "; ;" is a syntax error.
528 stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
529         ($(call SETVARS,$(1));                          \
530           cd "$$$${pkgbdir}";                           \
531           cd "$$$${pkgmkdir_inst}";                     \
532           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
533           $(call STRIP_macro,"$$$${pkgidir}");          \
534           $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
535         touch stamps/stamp-$(1)-04-install
536
537 stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
538         ($(call SETVARS,$(1));                          \
539          cd $(ipdir);                                   \
540          $(STOW) "$$$${pkg_version}")
541         touch stamps/stamp-$(1)-05-stow
542
543 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
544         touch stamps/stamp-final-$(1)
545
546 .PHONY : clean-$(1)
547 clean-$(1):
548         ($(call SETVARS,$(1));                          \
549          (cd $(ipdir) &&                                \
550           ($(STOW) -D "$$$${pkg_version}";              \
551            rm -fR "$$$${pkg_version}"));                \
552          rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
553         rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
554
555 endef
556
557 define KDEPKG_template
558 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
559   $(call KDEPKG_template_,$1))
560 endef
561
562
563
564 # Insert the template for each source package.
565 $(foreach spkg, $(gpg4win_spkgs), $(eval $(call SPKG_template,$(spkg))))
566
567 # Insert the template for each gpgEx architecture package.
568 $(foreach expkg, $(gpg4win_expkgs), $(eval $(call EXPKG_template,$(expkg))))
569
570 # Insert the template for each make only source package.
571 $(foreach mpkg, $(gpg4win_mpkgs), $(eval $(call MPKG_template,$(mpkg))))
572
573 # Insert the template for each binary package.
574 $(foreach bpkg, $(gpg4win_bpkgs), $(eval $(call BPKG_template,$(bpkg))))
575
576 # Insert the template for each internal package.
577 $(foreach ipkg, $(gpg4win_ipkgs), $(eval $(call IPKG_template,$(ipkg))))
578
579 # Insert the template for the README and HOWTO files.
580 $(foreach rll, $(gpg4win_readme_ll), $(eval $(call README_template,$(rll))))
581
582 # Insert the template for KDE packages.
583 $(foreach kdepkg, $(gpg4win_kdepkgs), $(eval $(call KDEPKG_template,$(kdepkg))))
584
585 $(foreach rll, $(gpg4win_howto_smime_ll), \
586                $(eval $(call HOWTO_template,SMIME,$(rll))))
587
588 stamps/stamp-final: stamps/stamp-directories
589 stamps/stamp-final: $(addprefix stamps/stamp-final-,$(gpg4win_build_list)) \
590         $(addprefix stamps/stamp-final-ex-,$(gpg4win_build_ex_list))
591         touch stamps/stamp-final
592
593 $(bdir)/versioninfo.txt: stamps/stamp-final
594         touch $(bdir)/versioninfo.txt
595
596
597 all-gpg4win: stamps/stamp-final
598
599 # Just to check if we catched all stamps.
600 clean-stamps:
601         $(RM) -fR $(stamps)
602
603 clean-gpg4win:
604         $(RM) -fR playground stamps
605
606 .PHONY : all-gpg4win clean-stamps clean-gpg4win
607
608 # TODO find a better way to do this. Like a define thats checked for
609 # in the spkg template
610 define OVERRIDE_CONF_TEMPLATE
611 # Override of the configure rule. For targets that not use
612 # autotools configure to have more freedom with the options.
613 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
614         ($(call SETVARS,$(1)); \
615         mkdir "$$$${pkgbdir}"; \
616         cd "$$$${pkgbdir}"; \
617         "../$$$${pkg_version}/configure" \
618                 $$$${pkgcfg}) && \
619         touch stamps/stamp-$(1)-02-configure
620 endef
621
622 $(eval $(call OVERRIDE_CONF_TEMPLATE,qtbase))
623
624 define OVERRIDE_QTTOOLS_CONF_TEMPLATE
625 # Override of the configure rule. For targets that not use
626 # autotools configure to have more freedom with the options.
627 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
628         ($(call SETVARS,$(1)); \
629         mkdir "$$$${pkgbdir}"; \
630         cd "$$$${pkgbdir}"; \
631         "$(idir)/bin/qmake" ../$$$${pkg_version} CONFIG-="debug debug_and_release" \
632                 $$$${pkgcfg}) && \
633         touch stamps/stamp-$(1)-02-configure
634 endef
635
636 $(eval $(call OVERRIDE_QTTOOLS_CONF_TEMPLATE,qttools))
637 $(eval $(call OVERRIDE_QTTOOLS_CONF_TEMPLATE,qtwinextras))
638 $(eval $(call OVERRIDE_QTTOOLS_CONF_TEMPLATE,qtsvg))
639
640 define OVERRIDE_BOOST_CONF_TEMPLATE
641 # Override of the configure rule. For targets that not use
642 # autotools configure to have more freedom with the options.
643 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
644         ($(call SETVARS,$(1)); \
645         cd $$$${pkgsdir}/tools/build/; \
646         ./bootstrap.sh; \
647         cd $$$${pkgsdir}; \
648         echo "using gcc : mxe : $(host)-g++ : <rc>$(host)-windres <archiver>$(host)-ar <ranlib>$(host)-ranlib ;" > "user-config.jam"; \
649         ./tools/build/b2 \
650         -a \
651         -q \
652         '$(GPG4WIN_PARALLEL)' \
653         --ignore-site-config \
654         --user-config=user-config.jam \
655         abi=ms \
656         address-model=32 \
657         architecture=x86 \
658         binary-format=pe \
659         link=shared \
660         target-os=windows \
661         threadapi=win32 \
662         threading=multi \
663         variant=release \
664         toolset=gcc-mxe \
665         --layout=tagged \
666         --disable-icu \
667         --without-mpi \
668         --without-python \
669         --prefix=$$$${pkgidir} \
670         --exec-prefix=$$$${pkgidir}/bin \
671         --libdir=$$$${pkgidir}/lib \
672         --includedir=$$$${pkgidir}/include \
673         -sEXPAT_INCLUDE='$(idir)/include' \
674         -sEXPAT_LIBPATH='$(idir)/lib' \
675         -sBZIP2_INCLUDE='$(idir)/include' \
676         -sBZIP2_LIBPATH='$(idir)/lib' \
677         install) && \
678         touch stamps/stamp-$(1)-02-configure && \
679         touch stamps/stamp-$(1)-03-make && \
680         touch stamps/stamp-$(1)-04-install
681 endef
682
683 $(eval $(call OVERRIDE_BOOST_CONF_TEMPLATE,boost))
684
685 # @emacs_local_vars_begin@
686 # @emacs_local_vars_read_only@
687 # @emacs_local_vars_end@