e7859c236b438e25229918bbb67acb04686d2f9c
[gpg4win.git] / src / Makefile.am
1 # Makefile.am - Installer for GnuPG 4 Windows Makefile.
2 # Copyright (C) 2005, 2006, 2007 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 EXTRA_DIST = pkg-config $(common_nsi) gpg4win.nsi gpg4win-src.nsi \
22         inst-gpg4win.nsi uninst-gpg4win.nsi installer-options.ini.in \
23         libiconv.def libintl.def  gpg4win-splash.wav gpgwrap.c \
24         exdll.h g4wihelp.c g4wihelp.nsi config.site loreley.mid \
25         inst-man_novice_en.nsi inst-man_advanced_en.nsi \
26         uninst-man_novice_en.nsi uninst-man_advanced_en.nsi
27
28 # Need to clean the dll because we bypassed automake.
29 CLEANFILES = g4wihelp.dll versioninfo.txt README.en.txt README.de.txt \
30              installer-options.ini NEWS.tmp gpgwrap.exe
31
32 # Supported source packages.
33 gpg4win_spkgs = glib gnupg libgpg-error gpgme gpgol gpa winpt sylpheed-claws \
34                 claws-mail gnupg2 pinentry libassuan libksba \
35                 libgcrypt dirmngr w32pth
36
37 # Extra options to configure for individual packages.
38 # We can use $(idir) here for the installation prefix.
39
40 gpg4win_pkg_glib_configure = \
41   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
42   CPPFLAGS=-I$(idir)/include LDFLAGS=-L$(idir)/lib
43
44 # The GnuPG package provides man pages which we have to convert.
45 # We also create the MO files here.
46 define gpg4win_pkg_gnupg_post_install   
47 (man -Tlatin1 -l $$$${pkgidir}/share/man/man1/gpg.1 | \
48  sed `printf "s/_\b//g;s/\b.//g"` | \
49  sed -e 's/$$$$/\r/' > $$$${pkgidir}/share/man/man1/gpg.man; \
50 man -Tlatin1 -l $$$${pkgidir}/share/man/man1/gpgv.1 | \
51  sed `printf "s/_\b//g;s/\b.//g"` | \
52  sed -e 's/$$$$/\r/' > $$$${pkgidir}/share/man/man1/gpgv.man; \
53 man -Tlatin1 -l $$$${pkgidir}/share/man/man7/gnupg.7 | \
54  sed `printf "s/_\b//g;s/\b.//g"` | \
55  sed -e 's/$$$$/\r/' > $$$${pkgidir}/share/man/man7/gnupg.man; \
56 for i in de; do \
57  msgfmt --output-file=$$$${pkgidir}/share/gnupg/$$$${i}.mo \
58                                $$$${pkgsdir}/po/$$$${i}.po; \
59  done)
60 endef
61
62
63 # The fields FAQ and faq.html conflict with those in GnuPG1.
64 # For now removes them.
65 define gpg4win_pkg_gnupg2_post_install  
66 ( rm $$$${pkgidir}/share/gnupg/FAQ; \
67   rm $$$${pkgidir}/share/gnupg/faq.html )
68 endef
69
70 # We would like to use --with-libiconv-prefix and
71 # --with-libintl-prefix, but these don't work with the cheesy
72 # non-"libfoo.la" versions of iconv and gettext that we are using.
73 #gpg4win_pkg_libgpg_error_configure = \
74 #  --with-libiconv-prefix=$(idir) --with-libintl-prefix=$(idir)
75 gpg4win_pkg_libgpg_error_configure = --silent \
76   CPPFLAGS=-I$(idir)/include LDFLAGS=-L$(idir)/lib
77
78 gpg4win_pkg_libassuan_configure =  --silent \
79   --disable-shared \
80   --with-pth-prefix=$(idir)
81
82 gpg4win_pkg_libksba_configure = --silent \
83   --with-gpg-error-prefix=$(idir)
84
85 gpg4win_pkg_libgcrypt_configure = --silent \
86   --with-gpg-error-prefix=$(idir)
87
88 gpg4win_pkg_dirmngr_configure = \
89   --with-gpg-error-prefix=$(idir) \
90   --with-ksba-prefix=$(idir) \
91   --with-libgcrypt-prefix=$(idir) \
92   --with-libassuan-prefix=$(idir)
93
94 gpg4win_pkg_gnupg2_configure = \
95   --with-gpg-error-prefix=$(idir) \
96   --with-ksba-prefix=$(idir) \
97   --with-libgcrypt-prefix=$(idir) \
98   --with-libassuan-prefix=$(idir) \
99   --with-zlib=$(idir) \
100   --with-pth-prefix=$(idir) \
101   --without-included-gettext \
102   --disable-regex
103
104 gpg4win_pkg_pinentry_configure = \
105   --disable-pinentry-gtk \
106   --disable-pinentry-gtk2 \
107   --disable-pinentry-qt 
108
109 # Glib doesn't add the LDFLAGS automatically.
110 gpg4win_pkg_gpgme_configure = --silent \
111   --with-gpg-error-prefix=$(idir) --enable-static \
112   --enable-w32-glib LDFLAGS=-L$(idir)/lib
113
114 gpg4win_pkg_gpa_configure = --silent \
115   --with-libiconv-prefix=$(idir) --with-libintl-prefix=$(idir) \
116   --with-gpgme-prefix=$(idir) --with-zlib=$(idir)
117
118 gpg4win_pkg_gpgol_configure = --silent \
119   --with-gpgme-prefix=$(idir) --with-gpg-error-prefix=$(idir)
120
121 gpg4win_pkg_winpt_configure = --silent \
122   --with-gpgme-prefix=$(idir) --with-gpg-error-prefix=$(idir)
123
124 gpg4win_pkg_sylpheed_claws_configure = --silent \
125   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
126   --with-gpg-error-prefix=$(idir) --with-gpgme-prefix=$(idir) \
127   --with-config-dir="Sylpheed-claws" --disable-pthread \
128   --disable-libetpan --disable-aspell --disable-trayicon-plugin \
129   --disable-openssl --disable-dillo-viewer-plugin --disable-gnomeprint \
130   --disable-jpilot --disable-startup-notification --disable-ipv6 \
131   --disable-mathml-viewer-plugin --disable-clamav-plugin \
132   --disable-spamassassin-plugin
133
134 gpg4win_pkg_claws_mail_configure = --silent \
135   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
136   --with-gpg-error-prefix=$(idir) --with-gpgme-prefix=$(idir) \
137   --with-config-dir="Claws-mail" --disable-pthread \
138   --disable-libetpan --disable-aspell --disable-trayicon-plugin \
139   --disable-openssl --disable-dillo-viewer-plugin --disable-gnomeprint \
140   --disable-jpilot --disable-startup-notification --disable-ipv6 \
141   --disable-mathml-viewer-plugin --disable-clamav-plugin \
142   --disable-spamassassin-plugin --disable-bogofilter-plugin \
143   --disable-valgrind
144
145 # Supported make-only source packages.
146 gpg4win_mpkgs =  pthreads-w32
147
148 # Extra options for the make infocations for individual packages.
149 # make_flags is used fur building make_args_inst is used for installing.
150 gpg4win_pkg_pthreads_w32_make_args = \
151   prefix=$(idir) CROSS=$(host_alias)- clean GC-inlined
152
153 gpg4win_pkg_pthreads_w32_make_args_inst = \
154   prefix=$$$${pkgidir} CROSS=$(host_alias)- 
155
156
157 # Supported binary packages.
158 gpg4win_bpkgs =  libiconv gettext pkgconfig zlib libpng jpeg pango cairo \
159                   atk gtk+ gpgee crypt regex 
160
161 # libiconv needs some special magic to generate a usable import
162 # library.
163 define gpg4win_pkg_libiconv_post_install
164 (cp $(srcdir)/libiconv.def $$$${pkgidir}/lib;           \
165 cd $$$${pkgidir}/lib;                                   \
166 $(DLLTOOL) --output-lib libiconv.dll.a --def libiconv.def)
167 endef
168
169 # libiconv needs some special magic to generate a usable import
170 # library.  Note that we include some internal symbols that are not
171 # actually part of the DLL.  They are needed by the AM_GNU_GETTEXT
172 # configure test, but not used otherwise.
173 define gpg4win_pkg_gettext_post_install
174 (cp $(srcdir)/libintl.def $$$${pkgidir}/lib;            \
175 cd $$$${pkgidir}/lib;                                   \
176 $(DLLTOOL) --output-lib libintl.dll.a --def libintl.def)
177 endef
178
179
180 # Zlib needs some special magic to generate a libtool file.
181 define gpg4win_pkg_zlib_post_install
182 (cd $$$${pkgidir_dev};                                  \
183 echo "dlname='../bin/zlib1.dll'" > lib/libz.la; \
184 echo "library_names='libz.dll.a'" >> lib/libz.la;       \
185 echo "old_library='libz.a'" >> lib/libz.la;             \
186 echo "dependency_libs=''" >> lib/libz.la;               \
187 echo "current=1" >> lib/libz.la;                        \
188 echo "age=2" >> lib/libz.la;                            \
189 echo "revision=3" >> lib/libz.la;                       \
190 echo "installed=yes" >> lib/libz.la;                    \
191 echo "shouldnotlink=no" >> lib/libz.la;                 \
192 echo "dlopen=''" >> lib/libz.la;                        \
193 echo "dlpreopen=''" >> lib/libz.la;                     \
194 echo "libdir=\"$$$${pkgidir}/lib\"" >> lib/libz.la;)
195 endef
196
197 # To make shure that we link against the static versions we need
198 # remove the import libs from crypt
199 define gpg4win_pkg_crypt_post_install
200 (cd $$$${pkgidir}/lib && rm libcrypt.dll.a libcrypt.lib)
201 endef
202
203 # To make shure that we link against the static versions we need
204 # remove the import libs from regex
205 define gpg4win_pkg_regex_post_install
206 (cd $$$${pkgidir}/lib && rm libregex.dll.a libregex.lib)
207 endef
208
209 # We need to fix the prefix in the various packages using pkgconfig,
210 # or we can't substitute it properly in our pkg-config wrapper.
211 define gpg4win_pkg_glib_post_install
212  (cd $$$${pkgidir_dev};                                                 \
213  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
214 endef
215
216 define gpg4win_pkg_atk_post_install
217  (cd $$$${pkgidir_dev};                                                 \
218  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
219 endef
220
221 define gpg4win_pkg_cairo_post_install
222  (cd $$$${pkgidir_dev};                                                 \
223  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
224 endef
225
226 define gpg4win_pkg_pango_post_install
227  (cd $$$${pkgidir_dev};                                                 \
228  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
229 endef
230
231 define gpg4win_pkg_gtk__post_install
232  (cd $$$${pkgidir_dev};                                                 \
233  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
234 endef
235
236 # In libpng, the pkg-config files are surprisingly found in the
237 # runtime package.
238 define gpg4win_pkg_libpng_post_install
239  (cd $$$${pkgidir};                                                     \
240  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
241 endef
242
243
244 # Supported internal packages.  Internal packages do not require any
245 # special support.  Thus, this variable is actually unused, and no
246 # rules are added in gpg4win.mk.
247 gpg4win_ipkgs = man_novice_de man_advanced_de man_novice_en man_advanced_en
248
249
250 # Now do the bunch of the work.  This is a bunch of dirty magic to
251 # integrate our special makefile into automake, while not actually
252 # including it (make should include it).  This is in turn necessary
253 # because automake can't deal with the elegant magic in the actual
254 # Makefile.
255
256 define INCLUDE_BY_MAKE
257 include $(1)
258 endef
259
260 $(eval $(call INCLUDE_BY_MAKE,gpg4win.mk))
261
262 clean-local: clean-gpg4win
263
264 common_nsi = inst-sections.nsi installer.nsi installer-finish.nsi       \
265   $(addsuffix .nsi,$(addprefix inst-,$(gpg4win_build_list)))            \
266   $(addsuffix .nsi,$(addprefix uninst-,$(gpg4win_build_list)))
267
268
269 # Prepare the versioninfo file.  The pipeline extracts the last
270 # occurrence of a package with the same name, sorts the entries and
271 # writes the file with DOS line endings.  This helps to avoid
272 # duplicate entries in case one package has been rebuild (which is
273 # common when developing a new version).
274 versioninfo.txt : playground/build/versioninfo.txt
275         set -e; \
276         ( while read a b; do echo "$$a $$(basename $$b)"; \
277             done < playground/build/versioninfo.txt \
278           | sort -k2 -sf | tac | uniq -f1 ; \
279           echo '=========== SHA-1 checksum ============= == package ==' \
280          ) | tac | awk '{printf "%s\r\n", $$0}' > versioninfo.txt
281
282 NEWS.tmp : $(top_srcdir)/NEWS
283         sed -e '/^#/d' <$(top_srcdir)/NEWS >NEWS.tmp
284
285 README.en.txt : versioninfo.txt NEWS.tmp $(top_srcdir)/doc/README.en.txt
286         sed -e '/^;.*/d;/!VERSIONINFO!/{r versioninfo.txt' -e 'd;}' \
287         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
288         -e '/!PKG-COPYRIGHT!/{r $(top_srcdir)/doc/pkg-copyright.txt' -e 'd;}' \
289         -e 's,!VERSION!,$(VERSION),g' \
290            < $(top_srcdir)/doc/README.en.txt \
291            | awk '{printf "%s\r\n", $$0}' >README.en.txt
292
293 installer-options.ini : $(top_srcdir)/src/installer-options.ini.in
294         cat $(top_srcdir)/src/installer-options.ini.in >installer-options.ini
295
296 README.de.txt : versioninfo.txt NEWS.tmp $(top_srcdir)/doc/README.de.txt
297         sed -e '/^;.*/d;/!VERSIONINFO!/{r versioninfo.txt' -e 'd;}' \
298         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
299         -e '/!PKG-COPYRIGHT!/{r $(top_srcdir)/doc/pkg-copyright.txt' -e 'd;}' \
300         -e 's,!VERSION!,$(VERSION),g' \
301            < $(top_srcdir)/doc/README.de.txt \
302            | awk '{printf "%s\r\n", $$0}' >README.de.txt
303
304 # For some nut-crazy reason someone thought it would be a great idea
305 # if makensis changed to the directory of the source file at startup.
306 # So we have to pull a couple of strings to correct this.
307 gpg4win-$(VERSION).exe: gpg4win.nsi $(common_nsi) stamps/stamp-final \
308                         g4wihelp.dll gpgwrap.exe README.en.txt README.de.txt \
309                         installer-options.ini versioninfo.txt
310         $(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
311                 -DSRCDIR=$(srcdir) $(srcdir)/gpg4win.nsi
312
313 gpg4win-light-$(VERSION).exe: gpg4win.nsi $(common_nsi) stamps/stamp-final \
314                         g4wihelp.dll gpgwrap.exe README.en.txt README.de.txt \
315                         installer-options.ini versioninfo.txt
316         $(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
317                 -DSRCDIR=$(srcdir) -DGPG4WIN_LIGHT=1 $(srcdir)/gpg4win.nsi
318
319 stamps/stamp-dist-self: versioninfo.txt
320         (set -e; cd ..; make dist-bzip2)
321         touch stamps/stamp-dist-self
322
323 gpg4win-src-$(VERSION).exe: gpg4win-src.nsi $(common_nsi) stamps/stamp-final \
324                             stamps/stamp-dist-self installer-options.ini
325         $(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
326                 -DSRCDIR=$(srcdir) $(srcdir)/gpg4win-src.nsi
327
328 g4wihelp.dll: g4wihelp.c exdll.h
329         $(CC) -I. -shared -O2 -o g4wihelp.dll $(srcdir)/g4wihelp.c \
330            -lwinmm -lgdi32
331         $(STRIP) g4wihelp.dll
332
333 gpgwrap.exe: gpgwrap.c
334         $(CC) -I. -I.. -DHAVE_CONFIG_H -O2 -o gpgwrap.exe $(srcdir)/gpgwrap.c 
335         $(STRIP) gpgwrap.exe
336
337 if BUILD_SOURCE_INSTALLER
338 all_src = gpg4win-src-$(VERSION).exe
339 else
340 all_src =
341 endif
342
343 if BUILD_LIGHT_INSTALLER
344 all_light = gpg4win-light-$(VERSION).exe
345 else
346 all_light =
347 endif
348
349 all-local: gpg4win-$(VERSION).exe $(all_light) $(all_src)
350
351 clean-local:
352         rm -f gpg4win-$(VERSION).exe gpg4win-light-$(VERSION).exe \
353             gpg4win-src-$(VERSION).exe