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