Do not call make three times
[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           )
205         touch stamps/stamp-$(1)-ex-03-make
206
207 # Note that post_install must come last because it may be empty and
208 # "; ;" is a syntax error.
209 stamps/stamp-$(1)-ex-04-install: stamps/stamp-$(1)-ex-03-make
210         ($(call SETVARS_EX,$(1));                               \
211           cd "$$$${pkgbdir}";                           \
212           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
213           $(call STRIP_EX_macro,"$$$${pkgidir}");               \
214           rm -f "$$$${pkgidir}/share/info/dir";         \
215           $(call gpg4win_pkg_$(call FROB_macro,$(1))_ex_post_install))
216         touch stamps/stamp-$(1)-ex-04-install
217
218 stamps/stamp-$(1)-ex-05-stow: stamps/stamp-$(1)-ex-04-install
219         ($(call SETVARS_EX,$(1));                               \
220          cd $(ex_ipdir);                                        \
221          $(STOW) -t $(ex_idir) "$$$${pkg_version}")
222         touch stamps/stamp-$(1)-ex-05-stow
223
224 stamps/stamp-final-ex-$(1): stamps/stamp-$(1)-ex-05-stow
225         touch stamps/stamp-final-ex-$(1)
226
227 .PHONY : clean-ex-$(1)
228 clean-ex-$(1):
229         ($(call SETVARS_EX,$(1));                               \
230          (cd $(ex_ipdir) &&                             \
231           ($(STOW) -D "$$$${pkg_version}";              \
232            rm -fR "$$$${pkg_version}"));                \
233          rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
234         rm -f stamps/stamp-final-ex-$(1) stamps/stamp-$(1)-ex-*
235
236 endef
237
238 define EXPKG_template
239 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
240   $(call EXPKG_template_,$1))
241 endef
242
243
244 # Template for source packages.
245
246 define SPKG_template_
247
248 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
249
250 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
251         (cd $(bdir);                                    \
252          $(call SETVARS,$(1));                          \
253          $(call DEFLATE_macro,$$$${pkg}))
254         touch stamps/stamp-$(1)-00-unpack
255
256 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
257         (shopt -s nullglob;                             \
258          $(call SETVARS,$(1));                          \
259          for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do  \
260            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
261          done)
262         touch stamps/stamp-$(1)-01-patch
263
264 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
265         ($(call SETVARS,$(1)); \
266         mkdir "$$$${pkgbdir}"; \
267         cd "$$$${pkgbdir}"; \
268         eval "../$$$${pkg_version}/configure" \
269                 --prefix="$$$${pkgidir}" \
270                 --host=$(host) \
271                 --build=$(build) \
272         $$$${pkgcfg} CFLAGS=\"-mms-bitfields $$$${pkgextracflags}\";\
273         shopt -s nullglob; \
274         for pfile in "$$$${pkgpbdir}"/*.postcfg \
275                                 "$$$${pkgpdir}"/*.postcfg ; do \
276                         (cd "$$$${pkgsdir}"; "$$$${pfile}") \
277                 done; \
278         for pfile in "$$$${pkgpbdir}"/*.postcfg-build \
279                                  "$$$${pkgpdir}"/*.postcfg-build ; do \
280                                 (cd "$$$${pkgbdir}"; "$$$${pfile}") \
281         done;) && \
282         touch stamps/stamp-$(1)-02-configure
283
284 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-02-configure
285         ($(call SETVARS,$(1));                          \
286           cd "$$$${pkgbdir}";                           \
287           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}";      \
288           $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs})
289         touch stamps/stamp-$(1)-03-make
290
291 # Note that post_install must come last because it may be empty and
292 # "; ;" is a syntax error.
293 stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
294         ($(call SETVARS,$(1));                          \
295           cd "$$$${pkgbdir}";                           \
296           cd "$$$${pkgmkdir_inst}";                     \
297           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
298           $(call STRIP_macro,"$$$${pkgidir}");          \
299           rm -f "$$$${pkgidir}/share/info/dir";         \
300           $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
301         touch stamps/stamp-$(1)-04-install
302
303 stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
304         ($(call SETVARS,$(1));                          \
305          cd $(ipdir);                                   \
306          $(STOW) "$$$${pkg_version}")
307         touch stamps/stamp-$(1)-05-stow
308
309 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
310         touch stamps/stamp-final-$(1)
311
312 .PHONY : clean-$(1)
313 clean-$(1):
314         ($(call SETVARS,$(1));                          \
315          (cd $(ipdir) &&                                \
316           ($(STOW) -D "$$$${pkg_version}";              \
317            rm -fR "$$$${pkg_version}"));                \
318          rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
319         rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
320
321 endef
322
323 define SPKG_template
324 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
325   $(call SPKG_template_,$1))
326 endef
327
328
329 # Template for source packages using only make and no build
330 # directory.
331
332 define MPKG_template_
333
334 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
335
336 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
337         (cd $(bdir);                                    \
338          $(call SETVARS,$(1));                          \
339          $(call DEFLATE_macro,$$$${pkg}))
340         touch stamps/stamp-$(1)-00-unpack
341
342 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
343         (shopt -s nullglob;                             \
344          $(call SETVARS,$(1));                          \
345          for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do \
346            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
347          done)
348         touch stamps/stamp-$(1)-01-patch
349
350 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-01-patch
351         ($(call SETVARS,$(1));                          \
352           cd "$$$${pkgsdir}";                           \
353           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}";      \
354           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs})
355         touch stamps/stamp-$(1)-03-make
356
357 stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
358         ($(call SETVARS,$(1));                          \
359           cd "$$$${pkgsdir}";                           \
360           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
361           $(call STRIP_macro,"$$$${pkgidir}"); \
362           $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
363         touch stamps/stamp-$(1)-04-install
364
365 stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
366         ($(call SETVARS,$(1));                          \
367          cd $(ipdir);                                   \
368          $(STOW) "$$$${pkg_version}")
369         touch stamps/stamp-$(1)-05-stow
370
371 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
372         touch stamps/stamp-final-$(1)
373
374 .PHONY : clean-$(1)
375 clean-$(1):
376         ($(call SETVARS,$(1));                          \
377          (cd $(ipdir) &&                                \
378           ($(STOW) -D "$$$${pkg_version}";              \
379            rm -fR "$$$${pkg_version}"));                \
380          rm -fR "$$$${pkgsdir}")
381         rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
382
383 endef
384
385 define MPKG_template
386 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
387   $(call MPKG_template_,$1))
388 endef
389
390
391
392 # Template for binary packages.
393
394 define BPKG_template_
395
396 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
397 pkg_files += $(call GETVAR,gpg4win_pkg_$(1)_dev)
398
399 stamps/stamp-$(1)-00-install: stamps/stamp-directories $(call GETDEPS,$(1))
400         ($(call SETVARS,$(1));                          \
401          $(MKDIR) "$$$${pkgidir}";                      \
402          cd $$$${pkgidir};                              \
403          $(call DEFLATE_macro,$$$${pkg}))
404         touch stamps/stamp-$(1)-00-install
405
406 # Note that post_install must come last because it may be empty and
407 # "; ;" is a syntax error.
408 stamps/stamp-$(1)-01-install-dev: stamps/stamp-$(1)-00-install
409         ($(call SETVARS,$(1));                          \
410          $(MKDIR) "$$$${pkgidir_dev}";                  \
411          (cd $$$${pkgidir_dev};                         \
412           $(call DEFLATE_macro,$$$${pkg_dev}));         \
413          $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
414         touch stamps/stamp-$(1)-01-install-dev
415
416 stamps/stamp-$(1)-02-stow: stamps/stamp-$(1)-01-install-dev
417         ($(call SETVARS,$(1));                          \
418          cd $(ipdir);                                   \
419          $(STOW) "$$$${pkg_version}")
420         touch stamps/stamp-$(1)-02-stow
421
422 stamps/stamp-$(1)-03-stow-dev: stamps/stamp-$(1)-02-stow
423         ($(call SETVARS,$(1));                          \
424          cd $(ipdir);                                   \
425          $(STOW) "$$$${pkg_version_dev}")
426         touch stamps/stamp-$(1)-03-stow-dev
427
428 stamps/stamp-final-$(1): stamps/stamp-$(1)-03-stow-dev
429         touch stamps/stamp-final-$(1)
430
431 .PHONY : clean-$(1)
432 clean-$(1):
433         ($(call SETVARS,$(1));                          \
434          cd $(ipdir) &&                                 \
435          ($(STOW) -D "$$$${pkg_version}";               \
436           $(STOW) -D "$$$${pkg_version_dev}";           \
437           rm -fR "$$$${pkg_version}" "$$$${pkg_version_dev}"))
438         rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
439
440 endef
441
442 define BPKG_template
443 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
444   $(call BPKG_template_,$1))
445 endef
446
447
448 # Template for internal packages.
449
450 define IPKG_template
451
452 stamps/stamp-final-$(1): stamps/stamp-directories $(call GETDEPS,$(1))
453         touch stamps/stamp-final-$(1)
454 endef
455
456 # Template for README files
457 # (The final awk command converts the file endings).
458
459 define README_template
460 README.$(1).txt : versioninfo.txt NEWS.tmp $(top_srcdir)/doc/README.$(1).txt \
461                   COMPONENTS-list.tmp $(top_srcdir)/doc/beta-warning.txt
462         sed -e '/^;.*/d;/!VERSIONINFO!/{r versioninfo.txt' -e 'd;}' \
463         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
464         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
465         -e '/!COMPONENTS!/{r COMPONENTS-list.tmp' -e 'd;}' \
466         -e '/!PKG-COPYRIGHT!/{r $(top_srcdir)/doc/pkg-copyright.txt' -e 'd;}' \
467         -e 's,!VERSION!,$(VERSION),g' \
468         -e 's,!BUILD_ISODATE!,$(BUILD_ISODATE),g' \
469            < $(top_srcdir)/doc/README.$(1).txt \
470            | (if echo "$(VERSION)" | egrep 'svn|rc|beta|git' >/dev/null; then \
471               sed -e '/!BETA-WARNING!/{r $(top_srcdir)/doc/beta-warning.txt' \
472                -e 'd;}'; else sed -e 's,!BETA-WARNING!,,g'; fi) \
473            | awk '{printf "%s\r\n", $$$$0}' >README.$(1).txt
474 endef
475
476 define HOWTO_template
477 HOWTO-$(1).$(2).txt : $(top_srcdir)/doc/HOWTO-$(1).$(2).txt
478         sed -e '/^;.*/d' \
479         -e 's,!VERSION!,$(VERSION),g' \
480         -e 's,!BUILD_ISODATE!,$(BUILD_ISODATE),g' \
481            < $(top_srcdir)/doc/HOWTO-$(1).$(2).txt \
482         | awk '{printf "%s\r\n", $$$$0}' > HOWTO-$(1).$(2).txt
483 endef
484
485 # Template for source packages of KDE software
486 define KDEPKG_template_
487
488 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
489
490 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
491         (cd $(bdir);                                    \
492          $(call SETVARS,$(1));                          \
493          $(call DEFLATE_macro,$$$${pkg}))
494         touch stamps/stamp-$(1)-00-unpack
495
496 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
497         (shopt -s nullglob;                             \
498          $(call SETVARS,$(1));                          \
499          for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do  \
500            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
501          done)
502         touch stamps/stamp-$(1)-01-patch
503
504 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
505         ($(call SETVARS,$(1));                          \
506          mkdir "$$$${pkgbdir}";                         \
507           cd "$$$${pkgbdir}";                           \
508          cmake          \
509                 -DCMAKE_INSTALL_PREFIX="$$$${pkgidir}" \
510                 -DCMAKE_PREFIX_PATH="$$$${pkgidir}" \
511                 -DCMAKE_TOOLCHAIN_FILE=$(abs_top_srcdir)/src/toolchain.cmake \
512                 -DBUILD_TESTING=False \
513                 $$$${pkgcfg} $$$${pkgextracflags} "../$$$${pkg_version}") && \
514         touch stamps/stamp-$(1)-02-configure
515
516 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-02-configure
517         ($(call SETVARS,$(1));                          \
518           cd "$$$${pkgbdir}";                           \
519           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}";      \
520           $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs})
521         touch stamps/stamp-$(1)-03-make
522
523 # Note that post_install must come last because it may be empty and
524 # "; ;" is a syntax error.
525 stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
526         ($(call SETVARS,$(1));                          \
527           cd "$$$${pkgbdir}";                           \
528           cd "$$$${pkgmkdir_inst}";                     \
529           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
530           $(call STRIP_macro,"$$$${pkgidir}");          \
531           $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
532         touch stamps/stamp-$(1)-04-install
533
534 stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
535         ($(call SETVARS,$(1));                          \
536          cd $(ipdir);                                   \
537          $(STOW) "$$$${pkg_version}")
538         touch stamps/stamp-$(1)-05-stow
539
540 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
541         touch stamps/stamp-final-$(1)
542
543 .PHONY : clean-$(1)
544 clean-$(1):
545         ($(call SETVARS,$(1));                          \
546          (cd $(ipdir) &&                                \
547           ($(STOW) -D "$$$${pkg_version}";              \
548            rm -fR "$$$${pkg_version}"));                \
549          rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
550         rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
551
552 endef
553
554 define KDEPKG_template
555 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
556   $(call KDEPKG_template_,$1))
557 endef
558
559
560
561 # Insert the template for each source package.
562 $(foreach spkg, $(gpg4win_spkgs), $(eval $(call SPKG_template,$(spkg))))
563
564 # Insert the template for each gpgEx architecture package.
565 $(foreach expkg, $(gpg4win_expkgs), $(eval $(call EXPKG_template,$(expkg))))
566
567 # Insert the template for each make only source package.
568 $(foreach mpkg, $(gpg4win_mpkgs), $(eval $(call MPKG_template,$(mpkg))))
569
570 # Insert the template for each binary package.
571 $(foreach bpkg, $(gpg4win_bpkgs), $(eval $(call BPKG_template,$(bpkg))))
572
573 # Insert the template for each internal package.
574 $(foreach ipkg, $(gpg4win_ipkgs), $(eval $(call IPKG_template,$(ipkg))))
575
576 # Insert the template for the README and HOWTO files.
577 $(foreach rll, $(gpg4win_readme_ll), $(eval $(call README_template,$(rll))))
578
579 # Insert the template for KDE packages.
580 $(foreach kdepkg, $(gpg4win_kdepkgs), $(eval $(call KDEPKG_template,$(kdepkg))))
581
582 $(foreach rll, $(gpg4win_howto_smime_ll), \
583                $(eval $(call HOWTO_template,SMIME,$(rll))))
584
585 stamps/stamp-final: stamps/stamp-directories
586 stamps/stamp-final: $(addprefix stamps/stamp-final-,$(gpg4win_build_list)) \
587         $(addprefix stamps/stamp-final-ex-,$(gpg4win_build_ex_list))
588         touch stamps/stamp-final
589
590 $(bdir)/versioninfo.txt: stamps/stamp-final
591         touch $(bdir)/versioninfo.txt
592
593
594 all-gpg4win: stamps/stamp-final
595
596 # Just to check if we catched all stamps.
597 clean-stamps:
598         $(RM) -fR $(stamps)
599
600 clean-gpg4win:
601         $(RM) -fR playground stamps
602
603 .PHONY : all-gpg4win clean-stamps clean-gpg4win
604
605 # TODO find a better way to do this. Like a define thats checked for
606 # in the spkg template
607 define OVERRIDE_CONF_TEMPLATE
608 # Override of the configure rule. For targets that not use
609 # autotools configure to have more freedom with the options.
610 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
611         ($(call SETVARS,$(1)); \
612         mkdir "$$$${pkgbdir}"; \
613         cd "$$$${pkgbdir}"; \
614         "../$$$${pkg_version}/configure" \
615                 $$$${pkgcfg}) && \
616         touch stamps/stamp-$(1)-02-configure
617 endef
618
619 $(eval $(call OVERRIDE_CONF_TEMPLATE,qtbase))
620
621 define OVERRIDE_QTTOOLS_CONF_TEMPLATE
622 # Override of the configure rule. For targets that not use
623 # autotools configure to have more freedom with the options.
624 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
625         ($(call SETVARS,$(1)); \
626         mkdir "$$$${pkgbdir}"; \
627         cd "$$$${pkgbdir}"; \
628         "$(idir)/bin/qmake" ../$$$${pkg_version} CONFIG-="debug debug_and_release" \
629                 $$$${pkgcfg}) && \
630         touch stamps/stamp-$(1)-02-configure
631 endef
632
633 $(eval $(call OVERRIDE_QTTOOLS_CONF_TEMPLATE,qttools))
634 $(eval $(call OVERRIDE_QTTOOLS_CONF_TEMPLATE,qtwinextras))
635 $(eval $(call OVERRIDE_QTTOOLS_CONF_TEMPLATE,qtsvg))
636
637 define OVERRIDE_BOOST_CONF_TEMPLATE
638 # Override of the configure rule. For targets that not use
639 # autotools configure to have more freedom with the options.
640 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
641         ($(call SETVARS,$(1)); \
642         cd $$$${pkgsdir}/tools/build/; \
643         ./bootstrap.sh; \
644         cd $$$${pkgsdir}; \
645         echo "using gcc : mxe : $(host)-g++ : <rc>$(host)-windres <archiver>$(host)-ar <ranlib>$(host)-ranlib ;" > "user-config.jam"; \
646         ./tools/build/b2 \
647         -a \
648         -q \
649         '$(GPG4WIN_PARALLEL)' \
650         --ignore-site-config \
651         --user-config=user-config.jam \
652         abi=ms \
653         address-model=32 \
654         architecture=x86 \
655         binary-format=pe \
656         link=shared \
657         target-os=windows \
658         threadapi=win32 \
659         threading=multi \
660         variant=release \
661         toolset=gcc-mxe \
662         --layout=tagged \
663         --disable-icu \
664         --without-mpi \
665         --without-python \
666         --prefix=$$$${pkgidir} \
667         --exec-prefix=$$$${pkgidir}/bin \
668         --libdir=$$$${pkgidir}/lib \
669         --includedir=$$$${pkgidir}/include \
670         -sEXPAT_INCLUDE='$(idir)/include' \
671         -sEXPAT_LIBPATH='$(idir)/lib' \
672         -sBZIP2_INCLUDE='$(idir)/include' \
673         -sBZIP2_LIBPATH='$(idir)/lib' \
674         install) && \
675         touch stamps/stamp-$(1)-02-configure && \
676         touch stamps/stamp-$(1)-03-make && \
677         touch stamps/stamp-$(1)-04-install
678 endef
679
680 $(eval $(call OVERRIDE_BOOST_CONF_TEMPLATE,boost))
681
682 # @emacs_local_vars_begin@
683 # @emacs_local_vars_read_only@
684 # @emacs_local_vars_end@