MSI: Fix possible use of unintialized variable
[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) -p installers
43         $(MKDIR) $(bdir)
44         $(MKDIR) $(idir)
45         $(MKDIR) $(ipdir)
46         $(if $GPGEX_ADD_HOST, $(MKDIR) $(ex_idir))
47         $(if $GPGEX_ADD_HOST, $(MKDIR) $(ex_ipdir))
48         touch $(bdir)/versioninfo.txt
49         touch stamps/stamp-directories
50
51
52 # Frob the name $1 by converting all '-' and '+' characters to '_'.
53 define FROB_macro
54 $(subst +,_,$(subst -,_,$(1)))
55 endef
56
57 # Get the variable $(1) (which may contain '-' and '+' characters).
58 define GETVAR
59 $($(call FROB_macro,$(1)))
60 endef
61
62 # Set a couple of common variables.
63 define SETVARS
64         set -e; \
65         pkg="$(call GETVAR,gpg4win_pkg_$(1))";                          \
66         pkg_version="$(1)-$(call GETVAR,gpg4win_pkg_$(1)_version)";     \
67         pkgsdir="$(bdir)/$$$${pkg_version}";                            \
68         pkgbdir="$(bdir)/$$$${pkg_version}-build";                      \
69         pkgpdir="$(pdir)/$$$${pkg_version}";                            \
70         pkgpbdir="$(pdir)/$(1)";                                        \
71         pkgidir="$(ipdir)/$$$${pkg_version}";                           \
72         pkg_dev="$(call GETVAR,gpg4win_pkg_$(1)_dev)";                  \
73         pkg_version_dev="$(1)-dev-$(call GETVAR,gpg4win_pkg_$(1)_version)"; \
74         pkgidir_dev="$(ipdir)/$$$${pkg_version_dev}";                   \
75         pkgcfg="$(call GETVAR,gpg4win_pkg_$(1)_configure)";             \
76         pkgextracflags="$(call GETVAR,gpg4win_pkg_$(1)_extracflags)";   \
77         pkgmkargs="$(call GETVAR,gpg4win_pkg_$(1)_make_args)";          \
78         pkgmkargs_inst="$(call GETVAR,gpg4win_pkg_$(1)_make_args_inst)";\
79         pkgmkdir="$(call GETVAR,gpg4win_pkg_$(1)_make_dir)";             \
80         pkgmkdir_inst="$(call GETVAR,gpg4win_pkg_$(1)_make_dir)";        \
81         export PKG_CONFIG="$(tsdir)/src/pkg-config";                    \
82         export PKG_CONFIG_PATH="$(idir)/lib/pkgconfig";                 \
83         export PKG_CONFIG_LIBDIR="";                                    \
84         export PATH="$(idir)/bin:$${PATH}";                             \
85         export SYSROOT="$(idir)";                                       \
86         export CONFIG_SITE="$(tsdir)/src/config.site"
87 endef
88
89 # Set variables for building in an additional architecture
90 define SETVARS_EX
91         set -e; \
92         pkg="$(call GETVAR,gpg4win_pkg_$(1))";                              \
93         pkg_version="$(1)-$(call GETVAR,gpg4win_pkg_$(1)_version)";         \
94         pkgsdir="$(bdir)/$$$${pkg_version}";                                \
95         pkgbdir="$(bdir)/$$$${pkg_version}-ex-build";                       \
96         pkgpdir="$(pdir)/$$$${pkg_version}";                                \
97         pkgpbdir="$(pdir)/$(1)";                                            \
98         pkgidir="$(ex_ipdir)/$$$${pkg_version}";                            \
99         pkgidir_dev="$(ex_ipdir)/$$$${pkg_version_dev}";                    \
100         pkgcfg="$(call GETVAR,gpg4win_pkg_$(1)_ex_configure)";              \
101         pkgextracflags="$(call GETVAR,gpg4win_pkg_$(1)_ex_extracflags)";    \
102         pkgmkargs="$(call GETVAR,gpg4win_pkg_$(1)_ex_make_args)";           \
103         pkgmkargs_inst="$(call GETVAR,gpg4win_pkg_$(1)_ex_make_args_inst)"; \
104         pkgmkdir="$(call GETVAR,gpg4win_pkg_$(1)_ex_make_dir)";             \
105         pkgmkdir_inst="$(call GETVAR,gpg4win_pkg_$(1)_ex_make_dir)";        \
106         export PKG_CONFIG="$(tsdir)/src/pkg-config";                        \
107         export PKG_CONFIG_PATH="$(ex_idir)/lib/pkgconfig";                  \
108         export PKG_CONFIG_LIBDIR="";                                        \
109         export PATH="$(ex_idir)/bin:$${PATH}";                              \
110         export SYSROOT="$(ex_idir)"
111 endef
112
113 # Support macro.  Unpack the archive $(1).
114 define DEFLATE_macro
115         rm -rf $$$${pkgsdir}; \
116         case "$(1)" in                  \
117           */qtbase*.*.tar.xz)          \
118             $(TAR) -xJ --transform='s,^qtbase-everywhere-src,qtbase,' -f "$(1)" ;; \
119           */qttools*.*.tar.xz)          \
120             $(TAR) -xJ --transform='s,^qttools-everywhere-src,qttools,' -f "$(1)" ;; \
121           */qtwinextras*.*.tar.xz)          \
122             $(TAR) -xJ --transform='s,^qtwinextras-everywhere-src,qtwinextras,' -f "$(1)" ;; \
123           */qtsvg*.*.tar.xz)          \
124             $(TAR) -xJ --transform='s,^qtsvg-everywhere-src,qtsvg,' -f "$(1)" ;; \
125           */qttranslations*.*.tar.xz)          \
126             $(TAR) -xJ --transform='s,^qttranslations-everywhere-src,qttranslations,' -f "$(1)" ;; \
127           */boost*.*.tar.bz2)          \
128             $(TAR) -xj --transform='s,^boost_1_60_0,boost-1.60.0,' -f "$(1)" ;; \
129           *.tar.gz | *.tgz)             \
130             $(TAR) xzf "$(1)" ;;        \
131           *.tar.bz2 | *.tbz2 | *.tbz)   \
132             $(TAR) xjf "$(1)" ;;        \
133           *.tar.xz )                    \
134             $(TAR) xJf "$(1)" ;;        \
135           *.exe )                               \
136             cp "$(1)" .       ;;        \
137           *.zip)                        \
138             $(UNZIP) -o "$(1)" ;;               \
139         esac
140 endef
141
142 # Support macro.  Strip all exe files below $(1).
143 define STRIP_macro
144         if test -z '$(DEBUG)'; then                     \
145           (cd $(1);                                     \
146            for f in `find . -name \*.exe -o -name \*.dll`; do           \
147            echo Calling $(STRIP) "$$$${pkg_version}/$$$${f}"; \
148            $(STRIP) "$$$${f}"; done);                   \
149         fi
150 endef
151
152 # Support macro.  Strip all exe files below $(1) using STRIP_EX.
153 define STRIP_EX_macro
154         if test -z '$(DEBUG)'; then                     \
155           (cd $(1);                                     \
156            for f in `find . -name \*.exe -o -name \*.dll`; do           \
157            echo Calling $(STRIP_EX) "$$$${pkg_version}/$$$${f}"; \
158            $(STRIP_EX) "$$$${f}"; done);                        \
159         fi
160 endef
161
162 define GETDEPS
163   $(addprefix stamps/stamp-final-, $(call GETVAR,gpg4win_pkg_$(1)_deps))
164 endef
165
166 define GETDEPS_EX
167   $(addprefix stamps/stamp-final-ex-, $(call GETVAR,gpg4win_pkg_$(1)_ex_deps))
168 endef
169
170 # Template for source packages to build for an additional host
171
172 define EXPKG_template_
173
174 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
175
176 stamps/stamp-$(1)-ex-00-unpack: stamps/stamp-$(1)-00-unpack $(call GETDEPS_EX,$(1))
177         touch stamps/stamp-$(1)-ex-00-unpack
178
179 stamps/stamp-$(1)-ex-01-patch: stamps/stamp-$(1)-ex-00-unpack stamps/stamp-$(1)-01-patch
180         touch stamps/stamp-$(1)-ex-01-patch
181
182 stamps/stamp-$(1)-ex-02-configure: stamps/stamp-$(1)-ex-01-patch
183         ($(call SETVARS_EX,$(1));                               \
184          mkdir "$$$${pkgbdir}";                         \
185           cd "$$$${pkgbdir}";                           \
186          eval "../$$$${pkg_version}/configure"          \
187                 --prefix="$$$${pkgidir}"                \
188                 --host=$(GPGEX_ADD_HOST)                \
189                 --build=$(build)                        \
190                 $$$${pkgcfg} CFLAGS=\"-mms-bitfields $$$${pkgextracflags}\";\
191          shopt -s nullglob;                                     \
192          for pfile in "$$$${pkgpbdir}"/*.postcfg                \
193                        "$$$${pkgpdir}"/*.postcfg ; do           \
194            (cd "$$$${pkgsdir}"; "$$$${pfile}")                  \
195          done;                                                  \
196          for pfile in "$$$${pkgpbdir}"/*.postcfg-build          \
197                        "$$$${pkgpdir}"/*.postcfg-build ; do     \
198            (cd "$$$${pkgbdir}"; "$$$${pfile}")                  \
199          done)
200         touch stamps/stamp-$(1)-ex-02-configure
201
202 stamps/stamp-$(1)-ex-03-make: stamps/stamp-$(1)-ex-02-configure
203         ($(call SETVARS_EX,$(1));                               \
204           cd "$$$${pkgbdir}";                           \
205           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}";      \
206           $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs} \
207           )
208         touch stamps/stamp-$(1)-ex-03-make
209
210 # Note that post_install must come last because it may be empty and
211 # "; ;" is a syntax error.
212 stamps/stamp-$(1)-ex-04-install: stamps/stamp-$(1)-ex-03-make
213         ($(call SETVARS_EX,$(1));                               \
214           cd "$$$${pkgbdir}";                           \
215           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
216           $(call STRIP_EX_macro,"$$$${pkgidir}");               \
217           rm -f "$$$${pkgidir}/share/info/dir";         \
218           $(call gpg4win_pkg_$(call FROB_macro,$(1))_ex_post_install))
219         touch stamps/stamp-$(1)-ex-04-install
220
221 stamps/stamp-$(1)-ex-05-stow: stamps/stamp-$(1)-ex-04-install
222         ($(call SETVARS_EX,$(1));                               \
223          cd $(ex_ipdir);                                        \
224          $(STOW) -t `readlink -f $(ex_idir)` "$$$${pkg_version}")
225         touch stamps/stamp-$(1)-ex-05-stow
226
227 stamps/stamp-final-ex-$(1): stamps/stamp-$(1)-ex-05-stow
228         touch stamps/stamp-final-ex-$(1)
229
230 .PHONY : clean-ex-$(1)
231 clean-ex-$(1):
232         ($(call SETVARS_EX,$(1));                               \
233          (cd $(ex_ipdir) &&                             \
234           ($(STOW) -D "$$$${pkg_version}";              \
235            rm -fR "$$$${pkg_version}"));                \
236          rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
237         rm -f stamps/stamp-final-ex-$(1) stamps/stamp-$(1)-ex-*
238
239 endef
240
241 define EXPKG_template
242 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
243   $(call EXPKG_template_,$1))
244 endef
245
246
247 # Template for source packages.
248
249 define SPKG_template_
250
251 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
252
253 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
254         (cd $(bdir);                                    \
255          $(call SETVARS,$(1));                          \
256          $(call DEFLATE_macro,$$$${pkg}))
257         touch stamps/stamp-$(1)-00-unpack
258
259 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
260         (shopt -s nullglob;                             \
261          $(call SETVARS,$(1));                          \
262          for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do  \
263            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
264          done)
265         touch stamps/stamp-$(1)-01-patch
266
267 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
268         ($(call SETVARS,$(1)); \
269         mkdir "$$$${pkgbdir}"; \
270         cd "$$$${pkgbdir}"; \
271         eval "../$$$${pkg_version}/configure" \
272                 --prefix="$$$${pkgidir}" \
273                 --host=$(host) \
274                 --build=$(build) \
275         $$$${pkgcfg} CFLAGS=\"-mms-bitfields $$$${pkgextracflags}\";\
276         shopt -s nullglob; \
277         for pfile in "$$$${pkgpbdir}"/*.postcfg \
278                                 "$$$${pkgpdir}"/*.postcfg ; do \
279                         (cd "$$$${pkgsdir}"; "$$$${pfile}") \
280                 done; \
281         for pfile in "$$$${pkgpbdir}"/*.postcfg-build \
282                                  "$$$${pkgpdir}"/*.postcfg-build ; do \
283                                 (cd "$$$${pkgbdir}"; "$$$${pfile}") \
284         done;) && \
285         touch stamps/stamp-$(1)-02-configure
286
287 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-02-configure
288         ($(call SETVARS,$(1));                          \
289           cd "$$$${pkgbdir}";                           \
290           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}";      \
291           $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${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 # Template for qt packages.
451
452 define QTPKG_template_
453
454 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
455
456 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
457         (cd $(bdir);                                    \
458          $(call SETVARS,$(1));                          \
459          $(call DEFLATE_macro,$$$${pkg}))
460         touch stamps/stamp-$(1)-00-unpack
461
462 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
463         (shopt -s nullglob;                             \
464          $(call SETVARS,$(1));                          \
465          for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do  \
466            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
467          done)
468         touch stamps/stamp-$(1)-01-patch
469
470 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
471         ($(call SETVARS,$(1)); \
472         mkdir "$$$${pkgbdir}"; \
473         cd "$$$${pkgbdir}"; \
474         $$$${pkgcfg}) && \
475         touch stamps/stamp-$(1)-02-configure
476
477 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-02-configure
478         ($(call SETVARS,$(1));                          \
479           cd "$$$${pkgbdir}";                           \
480           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}";      \
481           $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs})
482         touch stamps/stamp-$(1)-03-make
483
484 # Note that post_install must come last because it may be empty and
485 # "; ;" is a syntax error.
486 stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
487         ($(call SETVARS,$(1)); \
488         $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
489         touch stamps/stamp-$(1)-04-install
490
491 stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
492         ($(call SETVARS,$(1));                          \
493          cd $(ipdir);                                   \
494          $(STOW) "$$$${pkg_version}")
495         touch stamps/stamp-$(1)-05-stow
496
497 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
498         touch stamps/stamp-final-$(1)
499
500 .PHONY : clean-$(1)
501 clean-$(1):
502         ($(call SETVARS,$(1));                          \
503          (cd $(ipdir) &&                                \
504           ($(STOW) -D "$$$${pkg_version}";              \
505            rm -fR "$$$${pkg_version}"));                \
506          rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
507         rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
508
509 endef
510
511 define QTPKG_template
512 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
513   $(call QTPKG_template_,$1))
514 endef
515
516 # Template for internal packages.
517
518 define IPKG_template
519
520 stamps/stamp-final-$(1): stamps/stamp-directories $(call GETDEPS,$(1))
521         touch stamps/stamp-final-$(1)
522 endef
523
524 # Template for README files
525 # (The final awk command converts the file endings).
526
527 define README_template
528 README.$(1).txt : versioninfo.txt NEWS.tmp $(top_srcdir)/doc/README.$(1).txt \
529                   COMPONENTS-list.tmp $(top_srcdir)/doc/beta-warning.txt
530         sed -e '/^;.*/d;/!VERSIONINFO!/{r versioninfo.txt' -e 'd;}' \
531         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
532         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
533         -e '/!COMPONENTS!/{r COMPONENTS-list.tmp' -e 'd;}' \
534         -e '/!PKG-COPYRIGHT!/{r $(top_srcdir)/doc/pkg-copyright.txt' -e 'd;}' \
535         -e 's,!VERSION!,$(VERSION),g' \
536         -e 's,!BUILD_ISODATE!,$(BUILD_ISODATE),g' \
537            < $(top_srcdir)/doc/README.$(1).txt \
538            | (if echo "$(VERSION)" | egrep 'svn|rc|beta|git' >/dev/null; then \
539               sed -e '/!BETA-WARNING!/{r $(top_srcdir)/doc/beta-warning.txt' \
540                -e 'd;}'; else sed -e 's,!BETA-WARNING!,,g'; fi) \
541            | awk '{printf "%s\r\n", $$$$0}' >README.$(1).txt
542 endef
543
544 define HOWTO_template
545 HOWTO-$(1).$(2).txt : $(top_srcdir)/doc/HOWTO-$(1).$(2).txt
546         sed -e '/^;.*/d' \
547         -e 's,!VERSION!,$(VERSION),g' \
548         -e 's,!BUILD_ISODATE!,$(BUILD_ISODATE),g' \
549            < $(top_srcdir)/doc/HOWTO-$(1).$(2).txt \
550         | awk '{printf "%s\r\n", $$$$0}' > HOWTO-$(1).$(2).txt
551 endef
552
553 # Special Template for boost.
554 define BOOST_template_
555 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
556
557 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
558         (cd $(bdir);                                    \
559          $(call SETVARS,$(1));                          \
560          $(call DEFLATE_macro,$$$${pkg}))
561         touch stamps/stamp-$(1)-00-unpack
562
563 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
564         (shopt -s nullglob;                             \
565          $(call SETVARS,$(1));                          \
566          for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do  \
567            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
568          done)
569         touch stamps/stamp-$(1)-01-patch
570
571 stamps/stamp-$(1)-02-build: stamps/stamp-$(1)-01-patch
572         ($(call SETVARS,$(1)); \
573         cd $$$${pkgsdir}/tools/build/; \
574         ./bootstrap.sh; \
575         cd $$$${pkgsdir}; \
576         echo "using gcc : mxe : $(host)-g++ : <rc>$(host)-windres <archiver>$(host)-ar <ranlib>$(host)-ranlib ;" > "user-config.jam"; \
577         ./tools/build/b2 \
578         -a \
579         -q \
580         '$(GPG4WIN_PARALLEL)' \
581         --ignore-site-config \
582         --user-config=user-config.jam \
583         abi=ms \
584         address-model=32 \
585         architecture=x86 \
586         binary-format=pe \
587         link=shared \
588         target-os=windows \
589         threadapi=win32 \
590         threading=multi \
591         variant=release \
592         toolset=gcc-mxe \
593         cxxflags=-std=gnu++98 \
594         --layout=tagged \
595         --disable-icu \
596         --without-mpi \
597         --without-python \
598         --prefix=$$$${pkgidir} \
599         --exec-prefix=$$$${pkgidir}/bin \
600         --libdir=$$$${pkgidir}/lib \
601         --includedir=$$$${pkgidir}/include \
602         -sEXPAT_INCLUDE='$(idir)/include' \
603         -sEXPAT_LIBPATH='$(idir)/lib' \
604         -sBZIP2_INCLUDE='$(idir)/include' \
605         -sBZIP2_LIBPATH='$(idir)/lib' \
606         install) && \
607         touch stamps/stamp-$(1)-02-build
608
609 stamps/stamp-$(1)-03-stow: stamps/stamp-$(1)-02-build
610         ($(call SETVARS,$(1));                          \
611          cd $(ipdir);                                   \
612          $(STOW) "$$$${pkg_version}")
613         touch stamps/stamp-$(1)-03-stow
614
615 stamps/stamp-final-$(1): stamps/stamp-$(1)-03-stow
616         touch stamps/stamp-final-$(1)
617
618 .PHONY : clean-$(1)
619 clean-$(1):
620         ($(call SETVARS,$(1));                          \
621          (cd $(ipdir) &&                                \
622           ($(STOW) -D "$$$${pkg_version}";              \
623            rm -fR "$$$${pkg_version}"));                \
624          rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
625         rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
626 endef
627
628 # Template for source packages of KDE software
629 define KDEPKG_template_
630
631 pkg_files += $(call GETVAR,gpg4win_pkg_$(1))
632
633 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories $(call GETDEPS,$(1))
634         (cd $(bdir);                                    \
635          $(call SETVARS,$(1));                          \
636          $(call DEFLATE_macro,$$$${pkg}))
637         touch stamps/stamp-$(1)-00-unpack
638
639 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
640         (shopt -s nullglob;                             \
641          $(call SETVARS,$(1));                          \
642          cd "$$$${pkgsdir}";                            \
643          sed -i 's/set(KF5_MIN_VERSION.*)/set(KF5_MIN_VERSION "5.55.0")/' CMakeLists.txt; \
644          sed -i 's/set(KF5_VERSION.*)/set(KF5_VERSION "5.55.0")/' CMakeLists.txt; \
645          sed -i 's/set(KMIME_VERSION.*)/set(KMIME_VERSION "5.2.40")/' CMakeLists.txt; \
646          sed -i 's/set(LIBKLEO_VERSION.*)/set(LIBKLEO_VERSION "5.4.40")/' CMakeLists.txt; \
647          sed -i 's/set(QT_REQUIRED_VERSION.*)/set(QT_REQUIRED_VERSION "5.10.0")/' CMakeLists.txt; \
648          sed -i 's/set(GPGME_REQUIRED_VERSION.*)/set(GPGME_REQUIRED_VERSION "1.10.0")/' CMakeLists.txt; \
649          for pfile in "$$$${pkgpbdir}"/*.patch "$$$${pkgpdir}"/*.patch ; do  \
650            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
651          done)
652         touch stamps/stamp-$(1)-01-patch
653
654 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
655         ($(call SETVARS,$(1));                          \
656          mkdir "$$$${pkgbdir}";                         \
657           cd "$$$${pkgbdir}";                           \
658          cmake          \
659                 -DCMAKE_INSTALL_PREFIX="$$$${pkgidir}" \
660                 -DCMAKE_PREFIX_PATH="$$$${pkgidir}" \
661                 -DCMAKE_TOOLCHAIN_FILE=$(abs_top_srcdir)/src/toolchain.cmake \
662                 -DKDE_INSTALL_DATADIR="$$$${pkgidir}/share" \
663                 -DBUILD_TESTING=False \
664                 $$$${pkgcfg} $$$${pkgextracflags} "../$$$${pkg_version}") && \
665         touch stamps/stamp-$(1)-02-configure
666
667 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-02-configure
668         ($(call SETVARS,$(1));                          \
669           cd "$$$${pkgbdir}";                           \
670           test -n "$$$${pkgmkdir}" && cd "$$$${pkgmkdir}";      \
671           $(MAKE) $(AM_MAKEFLAGS) $(GPG4WIN_PARALLEL) $$$${pkgmkargs})
672         touch stamps/stamp-$(1)-03-make
673
674 # Note that post_install must come last because it may be empty and
675 # "; ;" is a syntax error.
676 stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
677         ($(call SETVARS,$(1));                          \
678           cd "$$$${pkgbdir}";                           \
679           cd "$$$${pkgmkdir_inst}";                     \
680           $(MAKE) $(AM_MAKEFLAGS) $$$${pkgmkargs_inst} install; \
681           $(call STRIP_macro,"$$$${pkgidir}");          \
682           $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
683         touch stamps/stamp-$(1)-04-install
684
685 stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
686         ($(call SETVARS,$(1));                          \
687          cd $(ipdir);                                   \
688          $(STOW) "$$$${pkg_version}")
689         touch stamps/stamp-$(1)-05-stow
690
691 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
692         touch stamps/stamp-final-$(1)
693
694 .PHONY : clean-$(1)
695 clean-$(1):
696         ($(call SETVARS,$(1));                          \
697          (cd $(ipdir) &&                                \
698           ($(STOW) -D "$$$${pkg_version}";              \
699            rm -fR "$$$${pkg_version}"));                \
700          rm -fR "$$$${pkgsdir}" "$$$${pkgbdir}")
701         rm -f stamps/stamp-final-$(1) stamps/stamp-$(1)-*
702
703 endef
704
705 define KDEPKG_template
706 $(if $(filter-out no, $(call GETVAR,gpg4win_pkg_$(1))),
707   $(call KDEPKG_template_,$1))
708 endef
709
710
711
712 # Insert the template for each source package.
713 $(foreach spkg, $(gpg4win_spkgs), $(eval $(call SPKG_template,$(spkg))))
714
715 # Insert the template for each gpgEx architecture package.
716 $(foreach expkg, $(gpg4win_expkgs), $(eval $(call EXPKG_template,$(expkg))))
717
718 # Insert the template for each make only source package.
719 $(foreach mpkg, $(gpg4win_mpkgs), $(eval $(call MPKG_template,$(mpkg))))
720
721 # Insert the template for each binary package.
722 $(foreach bpkg, $(gpg4win_bpkgs), $(eval $(call BPKG_template,$(bpkg))))
723
724 # Insert the template for each internal package.
725 $(foreach ipkg, $(gpg4win_ipkgs), $(eval $(call IPKG_template,$(ipkg))))
726
727 # Insert the template for the README and HOWTO files.
728 $(foreach rll, $(gpg4win_readme_ll), $(eval $(call README_template,$(rll))))
729
730 # Insert the template for KDE packages.
731 $(foreach kdepkg, $(gpg4win_kdepkgs), $(eval $(call KDEPKG_template,$(kdepkg))))
732
733 # Insert the template for qt packages.
734 $(foreach qtpkg, $(gpg4win_qtpkgs), $(eval $(call QTPKG_template,$(qtpkg))))
735
736
737 $(foreach rll, $(gpg4win_howto_smime_ll), \
738                $(eval $(call HOWTO_template,SMIME,$(rll))))
739
740 $(eval $(call BOOST_template_,boost))
741
742 stamps/stamp-final: stamps/stamp-directories
743 stamps/stamp-final: $(addprefix stamps/stamp-final-,$(gpg4win_build_list)) \
744         $(addprefix stamps/stamp-final-ex-,$(gpg4win_build_ex_list))
745         touch stamps/stamp-final
746
747 $(bdir)/versioninfo.txt: stamps/stamp-final
748         touch $(bdir)/versioninfo.txt
749
750
751 all-gpg4win: stamps/stamp-final
752
753 # Just to check if we catched all stamps.
754 clean-stamps:
755         $(RM) -fR $(stamps)
756
757 clean-gpg4win:
758         $(RM) -fR playground stamps
759
760 .PHONY : all-gpg4win clean-stamps clean-gpg4win
761
762 # @emacs_local_vars_begin@
763 # @emacs_local_vars_read_only@
764 # @emacs_local_vars_end@