strip dlls
[gpg4win.git] / src / gpg4win.mk.in
1 # gpg4win.m4.in - Installer for GnuPG 4 Windows Makefile.   -*- 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 # Support macro.  Strip all exe files below $(1).
83 define STRIP_macro
84         if test -z '$(DEBUG)'; then                     \
85           (cd $(1);                                     \
86            for f in `find . -name \*.exe -o -name \*.dll`; do           \
87            echo Calling $(STRIP) "$$$${pkg_version}/$$$${f}"; \
88            $(STRIP) "$$$${f}"; done);                   \
89         fi
90 endef
91
92
93 # Template for source packages.
94
95 define SPKG_template
96
97 stamps/stamp-$(1)-00-unpack: stamps/stamp-directories 
98         (cd $(bdir);                                    \
99          $(call SETVARS,$(1));                          \
100          $(call DEFLATE_macro,$$$${pkg}))
101         touch stamps/stamp-$(1)-00-unpack
102
103 stamps/stamp-$(1)-01-patch: stamps/stamp-$(1)-00-unpack
104         (shopt -s nullglob;                             \
105          $(call SETVARS,$(1));                          \
106          for pfile in "$$$${pkgpdir}"/*.patch ; do      \
107            (cd "$$$${pkgsdir}"; "$$$${pfile}")          \
108          done)
109         touch stamps/stamp-$(1)-01-patch
110
111 stamps/stamp-$(1)-02-configure: stamps/stamp-$(1)-01-patch
112         ($(call SETVARS,$(1));                          \
113          mkdir "$$$${pkgbdir}";                         \
114           cd "$$$${pkgbdir}";                           \
115          "$$$${pkgsdir}/configure"                      \
116                 --prefix="$$$${pkgidir}"                \
117                 --host=$(host_cpu)-$(host_os)           \
118                 --build=$(build_cpu)-$(build_os)        \
119                 $$$${pkgcfg} CFLAGS=-mms-bitfields)
120         touch stamps/stamp-$(1)-02-configure
121
122 stamps/stamp-$(1)-03-make: stamps/stamp-$(1)-02-configure
123         ($(call SETVARS,$(1));                          \
124           cd "$$$${pkgbdir}";                           \
125           $(MAKE) $(AM_MAKEFLAGS))
126         touch stamps/stamp-$(1)-03-make
127
128 stamps/stamp-$(1)-04-install: stamps/stamp-$(1)-03-make
129         ($(call SETVARS,$(1));                          \
130           cd "$$$${pkgbdir}";                           \
131           $(MAKE) $(AM_MAKEFLAGS) install;              \
132           $(call STRIP_macro,"$$$${pkgidir}"))
133         touch stamps/stamp-$(1)-04-install
134
135 stamps/stamp-$(1)-05-stow: stamps/stamp-$(1)-04-install
136         ($(call SETVARS,$(1));                          \
137          cd $(ipdir);                                   \
138          $(STOW) "$$$${pkg_version}")
139         touch stamps/stamp-$(1)-05-stow
140
141 stamps/stamp-final-$(1): stamps/stamp-$(1)-05-stow
142         touch stamps/stamp-final-$(1)
143 endef
144
145
146 # Template for binary packages.
147
148 define BPKG_template
149
150 stamps/stamp-$(1)-00-install: stamps/stamp-directories 
151         ($(call SETVARS,$(1));                          \
152          $(MKDIR) "$$$${pkgidir}";                      \
153          cd $$$${pkgidir};                              \
154          $(call DEFLATE_macro,$$$${pkg});               \
155          $(call STRIP_macro,"$$$${pkgidir}"))
156         touch stamps/stamp-$(1)-00-install
157
158 # Note that post_install must come last because it may be empty and
159 # "; ;" is a syntax error.
160 stamps/stamp-$(1)-01-install-dev: stamps/stamp-$(1)-00-install
161         ($(call SETVARS,$(1));                          \
162          $(MKDIR) "$$$${pkgidir_dev}";                  \
163          (cd $$$${pkgidir_dev};                         \
164           $(call DEFLATE_macro,$$$${pkg_dev});          \
165           $(call STRIP_macro,"$$$${pkgidir_dev}"));     \
166          $(call gpg4win_pkg_$(call FROB_macro,$(1))_post_install))
167         touch stamps/stamp-$(1)-01-install-dev
168
169 stamps/stamp-$(1)-02-stow: stamps/stamp-$(1)-01-install-dev
170         ($(call SETVARS,$(1));                          \
171          cd $(ipdir);                                   \
172          $(STOW) "$$$${pkg_version}")
173         touch stamps/stamp-$(1)-02-stow
174
175 stamps/stamp-$(1)-03-stow-dev: stamps/stamp-$(1)-02-stow
176         ($(call SETVARS,$(1));                          \
177          cd $(ipdir);                                   \
178          $(STOW) "$$$${pkg_version_dev}")
179         touch stamps/stamp-$(1)-03-stow-dev
180
181 stamps/stamp-final-$(1): stamps/stamp-$(1)-03-stow-dev
182         touch stamps/stamp-final-$(1)
183 endef
184
185
186 # Insert the template for each source package.
187 $(foreach spkg, $(gpg4win_spkgs), $(eval $(call SPKG_template,$(spkg))))
188
189 # Insert the template for each binary package.
190 $(foreach bpkg, $(gpg4win_bpkgs), $(eval $(call BPKG_template,$(bpkg))))
191
192 stamps/stamp-final: stamps/stamp-directories
193 stamps/stamp-final: $(addprefix stamps/stamp-final-,$(gpg4win_build_list))
194         touch stamps/stamp-final
195
196 all-gpg4win: stamps/stamp-final
197
198 # Just to check if we catched all stamps.
199 clean-stamps:
200         $(RM) -fR $(stamps)
201
202 clean-gpg4win:
203         $(RM) -fR playground stamps
204
205 .PHONY : all-gpg4win clean-stamps clean-gpg4win