Fox typi.
[gpg4win.git] / src / gpg4win.mk.in
1 # gpg4win.m4 - Installer for GnuPG 4 Windows Makefile.
2 # Copyright (C) 2005 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 pdir := $(shell pwd)/${top_srcdir}/patches
30
31
32 # The playground area is our scratch area, where we unpack, build and
33 # install the packages.
34 stamps/stamp-directories:
35         $(MKDIR) stamps
36         $(MKDIR) playground
37         $(MKDIR) $(bdir)
38         $(MKDIR) $(idir)
39         $(MKDIR) $(ipdir)
40         touch stamps/stamp-directories
41
42
43 # Frob the name $1 by converting all '-' and '+' characters to '_'.
44 define FROB_macro
45 $(subst +,_,$(subst -,_,$(1)))
46 endef
47
48 # Get the variable $(1) (which may contain '-' and '+' characters).
49 define GETVAR
50 $$($(call FROB_macro,$(1)))
51 endef
52
53 # Set a couple of common variables.
54 define SETVARS
55         pkg="$(call GETVAR,gpg4win_pkg_$(1))";                          \
56         pkg_version="$(1)-$(call GETVAR,gpg4win_pkg_$(1)_version)";     \
57         pkgsdir="$(bdir)/$$$${pkg_version}";                            \
58         pkgbdir="$(bdir)/$$$${pkg_version}-build";                      \
59         pkgpdir="$(pdir)/$$$${pkg_version}";                            \
60         pkgidir="$(ipdir)/$$$${pkg_version}";                           \
61         pkg_dev="$(call GETVAR,gpg4win_pkg_$(1)_dev)";                  \
62         pkg_version_dev="$(1)-dev-$(call GETVAR,gpg4win_pkg_$(1)_version)"; \
63         pkgidir_dev="$(ipdir)/$$$${pkg_version_dev}";                   \
64         pkgcfg="$(call GETVAR,gpg4win_pkg_$(1)_configure)";             \
65         export PKG_CONFIG="$(shell pwd)/$(top_srcdir)/src/pkg-config";  \
66         export PKG_CONFIG_PATH="${idir}/lib/pkgconfig";                 \
67         export SYSROOT="${idir}"
68 endef
69
70 # Support macro.  Unpack the archive $(1).
71 define DEFLATE_macro
72         case "$(1)" in                  \
73           *.tar.gz | *.tgz)             \
74             $(TAR) xzf "$(1)" ;;        \
75           *.tar.bz2 | *.tbz2 | *.tbz)   \
76             $(TAR) xjf "$(1)" ;;        \
77           *.zip)                        \
78             $(UNZIP) "$(1)" ;;  \
79         esac
80 endef
81
82
83 # Template for source packages.
84
85 define SPKG_template
86
87 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories 
88         (cd $(bdir);                                    \
89          $(call SETVARS,$(1));                          \
90          $(call DEFLATE_macro,$$$${pkg}))
91         touch stamps/stamp-$(1)-00-unpack
92
93 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
94         (shopt -s nullglob;                             \
95          $(call SETVARS,$(1));                          \
96          for pfile in "$$$${pkgpdir}"/*.patch ; do      \
97            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
98          done)
99         touch stamps/stamp-$(1)-01-patch
100
101 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
102         ($(call SETVARS,$(1));                          \
103          mkdir "$$$${pkgbdir}";                         \
104           cd "$$$${pkgbdir}";                           \
105          "$$$${pkgsdir}/configure"                      \
106                 --prefix="$$$${pkgidir}"                \
107                 --host=$(host_cpu)-$(host_os)           \
108                 --build=$(build_cpu)-$(build_os)        \
109                 $$$${pkgcfg} CFLAGS=-mms-bitfields)
110         touch stamps/stamp-$(1)-02-configure
111
112 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-02-configure
113         ($(call SETVARS,$(1));                          \
114           cd "$$$${pkgbdir}";                           \
115           $(MAKE) $(AM_MAKEFLAGS))
116         touch stamps/stamp-$(1)-03-make
117
118 stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
119         ($(call SETVARS,$(1));                          \
120           cd "$$$${pkgbdir}";                           \
121           $(MAKE) $(AM_MAKEFLAGS) install)
122         touch stamps/stamp-$(1)-04-install
123
124 stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
125         ($(call SETVARS,$(1));                          \
126          cd $(ipdir);                                   \
127          $(STOW) "$$$${pkg_version}")
128         touch stamps/stamp-$(1)-05-stow
129
130 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
131         touch stamps/stamp-final-$(1)
132 endef
133
134
135 # Template for binary packages.
136
137 define BPKG_template
138
139 stamps/stamp-$(1)-00-install: stamps/stamp-directories 
140         ($(call SETVARS,$(1));                          \
141          $(MKDIR) "$$$${pkgidir}";                      \
142          cd $$$${pkgidir};                              \
143          $(call DEFLATE_macro,$$$${pkg}))
144         touch stamps/stamp-$(1)-00-install
145
146 stamps/stamp-$(1)-01-install-dev: stamps/stamp-$(1)-00-install
147         ($(call SETVARS,$(1));                          \
148          $(MKDIR) "$$$${pkgidir_dev}";                  \
149          cd $$$${pkgidir_dev};                          \
150          $(call DEFLATE_macro,$$$${pkg_dev});           \
151          $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
152         touch stamps/stamp-$(1)-01-install-dev
153
154 stamps/stamp-$(1)-02-stow: stamps/stamp-$(1)-01-install-dev
155         ($(call SETVARS,$(1));                          \
156          cd $(ipdir);                                   \
157          $(STOW) "$$$${pkg_version}")
158         touch stamps/stamp-$(1)-02-stow
159
160 stamps/stamp-$(1)-03-stow-dev: stamps/stamp-$(1)-02-stow
161         ($(call SETVARS,$(1));                          \
162          cd $(ipdir);                                   \
163          $(STOW) "$$$${pkg_version_dev}")
164         touch stamps/stamp-$(1)-03-stow-dev
165
166 stamps/stamp-final-$(1): stamps/stamp-$(1)-03-stow-dev
167         touch stamps/stamp-final-$(1)
168 endef
169
170
171 # Insert the template for each source package.
172 $(foreach spkg, $(gpg4win_spkgs), $(eval $(call SPKG_template,$(spkg))))
173
174 # Insert the template for each binary package.
175 $(foreach bpkg, $(gpg4win_bpkgs), $(eval $(call BPKG_template,$(bpkg))))
176
177 stamps/stamp-final: $(addprefix stamps/stamp-final-,$(gpg4win_build_list))
178         touch stamps/stamp-final
179
180 all-gpg4win: stamps/stamp-final
181
182 # Just to check if we catched all stamps.
183 clean-stamps:
184         $(RM) -fR $(stamps)
185
186 clean-gpg4win:
187         $(RM) -fR playground stamps
188
189 .PHONY : all-gpg4win clean-stamps clean-gpg4win