More automagic for the README files.
[gpg4win.git] / src / Makefile.am
1 # Makefile.am - Installer for GnuPG 4 Windows Makefile.
2 # Copyright (C) 2005, 2006, 2007, 2008, 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, see <http://www.gnu.org/licenses/>.
18
19
20 EXTRA_DIST = pkg-config gpg4win.nsi gpg4win-src.nsi config.site \
21         installer-options.ini.in libiconv.def libintl.def loreley.mid \
22         gpg4win-splash.wav gpgwrap.c exdll.h g4wihelp.c g4wihelp.nsi \
23         inst-sections.nsi installer.nsi installer-finish.nsi  \
24         QtCore.pc QtGui.pc zlib.pc sha1sum.c                  \
25         qt.conf kleowrap.c potomo Memento.nsh dirmngr.conf    \
26         inst-gpg4win.nsi           uninst-gpg4win.nsi         \
27         inst-atk.nsi               uninst-atk.nsi             \
28         inst-expat.nsi             uninst-expat.nsi           \
29         inst-freetype.nsi          uninst-freetype.nsi        \
30         inst-fontconfig.nsi        uninst-fontconfig.nsi      \
31         inst-cairo.nsi             uninst-cairo.nsi           \
32         inst-libgsasl.nsi          uninst-libgsasl.nsi        \
33         inst-libtasn1.nsi          uninst-libtasn1.nsi        \
34         inst-gnutls.nsi            uninst-gnutls.nsi          \
35         inst-curl.nsi              uninst-curl.nsi            \
36         inst-libxml2.nsi           uninst-libxml2.nsi         \
37         inst-libetpan.nsi          uninst-libetpan.nsi        \
38         inst-claws-mail.nsi        uninst-claws-mail.nsi      \
39         inst-notification_plugin.nsi uninst-notification_plugin.nsi  \
40         inst-gtkhtml2_viewer.nsi   uninst-gtkhtml2_viewer.nsi \
41         inst-vcalendar.nsi         uninst-vcalendar.nsi       \
42         inst-rssyl.nsi             uninst-rssyl.nsi           \
43         inst-tnef_parse.nsi        uninst-tnef_parse.nsi      \
44         inst-attachwarner.nsi      uninst-attachwarner.nsi    \
45         inst-bsfilter_plugin.nsi   uninst-bsfilter_plugin.nsi \
46         inst-crypt.nsi             uninst-crypt.nsi           \
47         inst-dirmngr.nsi           uninst-dirmngr.nsi         \
48         inst-gettext.nsi           uninst-gettext.nsi         \
49         inst-libffi.nsi            uninst-libffi.nsi          \
50         inst-glib.nsi              uninst-glib.nsi            \
51         inst-gnupg2.nsi            uninst-gnupg2.nsi          \
52         inst-gpa.nsi               uninst-gpa.nsi             \
53         inst-gpgme.nsi             uninst-gpgme.nsi           \
54         inst-scute.nsi             uninst-scute.nsi           \
55         inst-paperkey.nsi          uninst-paperkey.nsi        \
56         inst-gpgol.nsi             uninst-gpgol.nsi           \
57         inst-gpgex.nsi             uninst-gpgex.nsi           \
58         inst-gdk-pixbuf.nsi        uninst-gdk-pixbuf.nsi      \
59         inst-gtk+.nsi              uninst-gtk+.nsi            \
60         inst-libassuan.nsi         uninst-libassuan.nsi       \
61         inst-libgcrypt.nsi         uninst-libgcrypt.nsi       \
62         inst-libgpg-error.nsi      uninst-libgpg-error.nsi    \
63         inst-libiconv.nsi          uninst-libiconv.nsi        \
64         inst-libksba.nsi           uninst-libksba.nsi         \
65         inst-adns.nsi              uninst-adns.nsi            \
66         inst-libpng.nsi            uninst-libpng.nsi          \
67         inst-enchant.nsi           uninst-enchant.nsi         \
68         inst-compendium.nsi        uninst-compendium.nsi   \
69         inst-man_advanced_de.nsi   uninst-man_advanced_de.nsi \
70         inst-man_advanced_en.nsi   uninst-man_advanced_en.nsi \
71         inst-man_novice_de.nsi     uninst-man_novice_de.nsi   \
72         inst-man_novice_en.nsi     uninst-man_novice_en.nsi   \
73         inst-pango.nsi             uninst-pango.nsi           \
74         inst-pinentry.nsi          uninst-pinentry.nsi        \
75         inst-pkgconfig.nsi         uninst-pkgconfig.nsi       \
76         inst-pthreads-w32.nsi      uninst-pthreads-w32.nsi    \
77         inst-regex.nsi             uninst-regex.nsi           \
78         inst-w32pth.nsi            uninst-w32pth.nsi          \
79         inst-zlib.nsi              uninst-zlib.nsi            \
80         inst-bsfilter.nsi          uninst-bsfilter.nsi        \
81         inst-qt.nsi                uninst-qt.nsi              \
82         inst-kdesupport.nsi        uninst-kdesupport.nsi      \
83         inst-oxygen-icons.nsi      uninst-oxygen-icons.nsi    \
84         inst-kdelibs.nsi           uninst-kdelibs.nsi         \
85         inst-kleopatra.nsi         uninst-kleopatra.nsi       \
86         inst-bzip2.nsi             uninst-bzip2.nsi           \
87         inst-final.nsi
88
89 SUBDIRS = dictionaries
90
91 gpg4win_readme_ll = en de ar es fr ru pt
92
93 README_files = $(addsuffix .txt,$(addprefix README.,$(gpg4win_readme_ll)))
94
95 gpg4win_howto_smime_ll = en de
96
97 HOWTO_files = $(addsuffix .txt, \
98                 $(addprefix HOWTO-SMIME.,$(gpg4win_howto_smime_ll)))
99
100 foosum_exe = sha1sum.exe md5sum.exe sha256sum.exe
101
102 # Need to clean the dll because we bypassed automake.
103 CLEANFILES = g4wihelp.dll versioninfo.txt $(README_files) $(HOWTO_files) \
104              installer-options.ini NEWS.tmp COMPONENTS-list.tmp \
105              versioninfo.tmp \
106              gpgwrap.exe gpgwrap-2.exe kleowrap.exe $(foosum_exe)
107
108 # Supported source packages.
109 gpg4win_spkgs = glib libffi gdk-pixbuf gtk+ \
110                 libgpg-error gpgme gpgol gpgex libpng enchant \
111                 gpa libgsasl libtasn1 opencdk gnutls curl libxml2 \
112                 libetpan claws-mail notification_plugin gtkhtml2_viewer \
113                 vcalendar rssyl gnupg2 pinentry libassuan libksba libgcrypt \
114                 adns dirmngr w32pth scute paperkey tnef_parse attachwarner \
115                 bsfilter_plugin regex
116
117 # Extra options to configure for individual packages.
118 # We can use $(idir) here for the installation prefix.
119
120 gpg4win_pkg_glib_configure = \
121   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
122   CPPFLAGS=-I$(idir)/include LDFLAGS=-L$(idir)/lib CCC=i586-mingw32msvc-g++
123 gpg4win_pkg_glib_extracflags = -march=i486
124
125 gpg4win_pkg_gdk_pixbuf_configure = \
126   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
127   --with-included-loaders=yes \
128   CPPFLAGS=-I$(idir)/include LDFLAGS=-L$(idir)/lib
129
130 gpg4win_pkg_gtk__configure = \
131   CPPFLAGS=-I$(idir)/include LDFLAGS=-L$(idir)/lib
132
133 # The GnuPG package provides man pages which we have to convert.
134 # We also create the MO files here.
135 define gpg4win_pkg_gnupg2_post_install
136 (for i in gpg2 gpgv2 gpgsm gpg-agent scdaemon gpg-connect-agent gpgconf ; \
137   do man -Tlatin1 -l $$$${pkgidir}/share/man/man1/$$$${i}.1 | \
138     sed `printf "s/_\b//g;s/\b.//g"` | \
139     sed -e 's/$$$$/\r/' > $$$${pkgidir}/share/man/man1/$$$${i}.man ; \
140  done ; \
141  for i in `$(tsdir)/src/potomo --get-linguas $$$${pkgsdir}/po` ; do \
142      $(mkdir_p) $$$${pkgidir}/share/locale/$$$${i}/LC_MESSAGES || true; \
143      rm $$$${pkgidir}/share/locale/$$$${i}/LC_MESSAGES/gnupg2.mo 2>/dev/null \
144        || true; \
145      $(tsdir)/src/potomo $$$${pkgsdir}/po/$$$${i}.po \
146               $$$${pkgidir}/share/locale/$$$${i}/LC_MESSAGES/gnupg2.mo; \
147  done)
148 endef
149
150 # Paperkey comes with a man pages which we have to convert.
151 define gpg4win_pkg_paperkey_post_install
152 (for i in paperkey ; \
153   do man -Tlatin1 -l $$$${pkgidir}/share/man/man1/$$$${i}.1 | \
154     sed `printf "s/_\b//g;s/\b.//g"` | \
155     sed -e 's/$$$$/\r/' > $$$${pkgidir}/share/man/man1/$$$${i}.man ; \
156  done)
157 endef
158
159
160
161 # Build the reference manual.
162 define gpg4win_pkg_gpgol_post_install
163 ( cd $$$${pkgndir}/doc; make pdf )
164 endef
165
166 # We would like to use --with-libiconv-prefix and
167 # --with-libintl-prefix, but these don't work with the cheesy
168 # non-"libfoo.la" versions of iconv and gettext that we are using.
169 #gpg4win_pkg_libgpg_error_configure = \
170 #  --with-libiconv-prefix=$(idir) --with-libintl-prefix=$(idir)
171 gpg4win_pkg_libgpg_error_configure = --silent \
172   CPPFLAGS=-I$(idir)/include LDFLAGS=-L$(idir)/lib \
173   --enable-static
174
175 # We convert the PO files to UTF-8.  FIXME: This should be done in
176 # libgpg-error proper.
177 define gpg4win_pkg_libgpg_error_post_install
178 (for i in `$(tsdir)/src/potomo --get-linguas $$$${pkgsdir}/po` ; do \
179    rm $$$${pkgidir}/share/locale/$$$${i}/LC_MESSAGES/libgpg-error.mo \
180        2>/dev/null|| true; \
181    $(tsdir)/src/potomo $$$${pkgsdir}/po/$$$${i}.po \
182              $$$${pkgidir}/share/locale/$$$${i}/LC_MESSAGES/libgpg-error.mo; \
183  done)
184 endef
185
186 gpg4win_pkg_libassuan_configure =  --silent \
187   --enable-static
188
189 gpg4win_pkg_libksba_configure = --silent \
190   --with-gpg-error-prefix=$(idir)
191
192 gpg4win_pkg_libgcrypt_configure = --silent \
193   --with-gpg-error-prefix=$(idir)
194
195 gpg4win_pkg_adns_configure = --silent
196
197 gpg4win_pkg_libpng_configure = CPPFLAGS=\"-I$(idir)/include -DPNG_BUILD_DLL\" LDFLAGS=\"-L$(idir)/lib\" LIBPNG_DEFINES=\"-DPNG_BUILD_DLL\"
198
199 gpg4win_pkg_enchant_configure = CPPFLAGS=\"-I$(idir)/include -UENCHANT_GLOBAL_MODULE_DIR -UENCHANT_GLOBAL_ORDERING -UENCHANT_MYSPELL_DICT_DIR -UENCHANT_USPELL_DICT_DIR\" LDFLAGS=\"-L$(idir)/lib\"
200
201 gpg4win_pkg_dirmngr_configure = \
202   --with-gpg-error-prefix=$(idir) \
203   --with-ksba-prefix=$(idir) \
204   --with-libgcrypt-prefix=$(idir) \
205   --with-libassuan-prefix=$(idir) \
206   --with-pth-prefix=$(idir)
207
208 gpg4win_pkg_gnupg2_configure = \
209   --with-gpg-error-prefix=$(idir) \
210   --with-ksba-prefix=$(idir) \
211   --with-libgcrypt-prefix=$(idir) \
212   --with-libassuan-prefix=$(idir) \
213   --with-zlib=$(idir) \
214   --with-bzip2=$(idir) \
215   --with-pth-prefix=$(idir) \
216   --with-adns=$(idir) \
217   --without-included-gettext \
218   --enable-gpgtar \
219   --disable-regex
220
221 # We would like to use --with-libiconv-prefix and
222 # --with-libintl-prefix, but these don't work with the cheesy
223 # non-"libfoo.la" versions of iconv and gettext that we are using.
224 gpg4win_pkg_pinentry_configure = \
225   --disable-pinentry-gtk \
226   --enable-pinentry-gtk2 \
227   --with-glib-prefix=$(idir) --with-gtk-prefix=$(idir) \
228   --disable-pinentry-qt \
229   CPPFLAGS=-I$(idir)/include LDFLAGS=-L$(idir)/lib
230 #  --with-libiconv-prefix=$(idir) --with-libintl-prefix=$(idir)
231
232 # The LDFLAGS is needed for -lintl for glib.  The QT4 variables work
233 # around the lack of cross compilation support in qt-dev.
234 gpg4win_pkg_gpgme_configure = --silent \
235   --with-gpg-error-prefix=$(idir) --enable-static \
236   `test -n "@HAVE_PKG_GLIB@" && echo "--enable-w32-glib"` \
237   --disable-w32-qt LDFLAGS=-L$(idir)/lib
238 #  `test -n "@HAVE_PKG_QT@" && echo "--disable-w32-qt"` \
239 #  QT4_CORE_CFLAGS=\"-DQT_LARGEFILE_SUPPORT -DQT_DLL \
240 #                   -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_THREAD_SUPPORT \
241 #                   -I$(idir)/include/QtCore -I$(idir)/include \
242 #                  -I$(idir)/mkspecs/win32-g++\" \
243 #  QT4_CORE_LIBS=\"-L$(idir)/lib -lQtCore4\"
244
245 gpg4win_pkg_gpa_configure = --silent \
246   --with-libiconv-prefix=$(idir) --with-libintl-prefix=$(idir) \
247   --with-gpgme-prefix=$(idir) --with-zlib=$(idir) \
248   --with-libassuan-prefix=$(idir) --with-gpg-error-prefix=$(idir)
249
250 gpg4win_pkg_gpgol_configure = --silent \
251   --with-gpgme-prefix=$(idir) --with-gpg-error-prefix=$(idir) \
252   --with-libassuan-prefix=$(idir)
253
254 gpg4win_pkg_gpgex_configure = --silent \
255   --with-gpg-error-prefix=$(idir) \
256   --with-libassuan-prefix=$(idir)
257
258 gpg4win_pkg_gnutls_configure = \
259   --disable-cxx \
260   --with-libtasn1-prefix=$(idir) \
261   --with-libgcrypt-prefix=$(idir)
262
263 gpg4win_pkg_curl_configure = \
264   --with-gnutls --without-ca-bundle --with-libiconv-prefix=$(idir)
265
266 gpg4win_pkg_libxml2_configure = \
267   --enable-shared --without-python --with-iconv=$(idir)
268
269 # The CFLAGS are needed to find pthread-w32.
270 gpg4win_pkg_libetpan_configure = --with-gnutls \
271   CPPFLAGS=\"-I$(idir)/include\" LIBS=\"-L$(idir)/lib\"
272
273 gpg4win_pkg_claws_mail_configure = \
274   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
275   --with-gpg-error-prefix=$(idir) --with-gpgme-prefix=$(idir) \
276   --with-config-dir="Claws-mail" --enable-pthread --enable-gnutls \
277   --enable-libetpan --disable-trayicon-plugin --disable-dbus \
278   --disable-dillo-viewer-plugin \
279   --disable-jpilot --disable-startup-notification --disable-ipv6 \
280   --disable-spamassassin-plugin --disable-bogofilter-plugin \
281   --disable-valgrind --disable-networkmanager-support
282
283 # This is not anymore needed sinces 3.8.0 already builds a PDF version.
284 # define gpg4win_pkg_claws_mail_post_install
285 # (for i in de en ; do \
286 #     (cd $$$${pkgidir}/share/doc/claws-mail/manual/$$$${i}; \
287 #     ps2pdf claws-mail-manual.ps); \
288 #  done)
289 # endef
290
291
292 gpg4win_pkg_notification_plugin_configure = \
293   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) \
294   --disable-libnotify --disable-lcdproc --disable-hotkeys
295
296 gpg4win_pkg_gtkhtml2_viewer_configure = \
297   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) LIBS=\"-L$(idir)/bin\"
298
299 gpg4win_pkg_vcalendar_configure = \
300   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) LIBS=\"-L$(idir)/bin\"
301
302 gpg4win_pkg_rssyl_configure = \
303   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) LIBS=\"-L$(idir)/bin\"
304
305 gpg4win_pkg_tnef_parse_configure = \
306   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) LIBS=\"-L$(idir)/bin\"
307
308 gpg4win_pkg_attachwarner_configure = \
309   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) LIBS=\"-L$(idir)/bin\"
310
311 gpg4win_pkg_bsfilter_plugin_configure = \
312   --with-lib-prefix=$(idir) --with-libiconv-prefix=$(idir) LIBS=\"-L$(idir)/bin\"
313
314 gpg4win_pkg_scute_configure = --silent \
315   --with-gpg-error-prefix=$(idir) --with-libassuan-prefix=$(idir)
316
317 gpg4win_pkg_paperkey_configure = --silent
318
319 # Supported make-only source packages.
320 gpg4win_mpkgs = pthreads-w32 bzip2 zlib crypt
321
322 # Extra options for the make invocations for individual packages.
323 # make_flags is used for building, make_args_inst is used for installing.
324 gpg4win_pkg_pthreads_w32_make_args = \
325   prefix=$(idir) CROSS=$(host_alias)- clean GC-inlined
326
327 gpg4win_pkg_pthreads_w32_make_args_inst = \
328   prefix=$$$${pkgidir} CROSS=$(host_alias)-
329
330 gpg4win_pkg_bzip2_make_args = \
331   CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
332
333 gpg4win_pkg_bzip2_make_args_inst = \
334   PREFIX=$$$${pkgidir} CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
335
336 gpg4win_pkg_crypt_make = \
337   CC=$(CC) AR=$(AR)
338
339 gpg4win_pkg_crypt_make_args_inst = \
340   prefix=$$$${pkgidir}
341
342 gpg4win_pkg_zlib_make_args = -fwin32/Makefile.gcc PREFIX=i586-mingw32msvc- IMPLIB=libz.dll.a
343
344 gpg4win_pkg_zlib_make_args_inst = -fwin32/Makefile.gcc install \
345         BINARY_PATH=$$$${pkgidir}/bin INCLUDE_PATH=$$$${pkgidir}/include \
346         LIBRARY_PATH=$$$${pkgidir}/lib SHARED_MODE=1 IMPLIB=libz.dll.a
347
348 # Supported binary packages.
349 gpg4win_bpkgs = libiconv gettext pkgconfig pango expat freetype fontconfig cairo \
350                 atk qt kdesupport oxygen-icons kdelibs kleopatra bsfilter
351
352 # libiconv needs some special magic to generate a usable import
353 # library.
354 define gpg4win_pkg_libiconv_post_install
355 (cp $(srcdir)/libiconv.def $$$${pkgidir}/lib;           \
356 cd $$$${pkgidir}/lib;                                   \
357 $(DLLTOOL) --output-lib libiconv.dll.a --def libiconv.def)
358 endef
359
360 # libiconv needs some special magic to generate a usable import
361 # library.  Note that we include some internal symbols that are not
362 # actually part of the DLL.  They are needed by the AM_GNU_GETTEXT
363 # configure test, but not used otherwise.
364 define gpg4win_pkg_gettext_post_install
365 (cp $(srcdir)/libintl.def $$$${pkgidir}/lib;            \
366 cd $$$${pkgidir}/lib;                                   \
367 $(DLLTOOL) --output-lib libintl.dll.a --def libintl.def)
368 endef
369
370
371 # Zlib needs some special magic to generate a libtool file.
372 # We also install the pc file here.
373 define gpg4win_pkg_zlib_post_install
374 (mkdir $$$${pkgidir}/lib/pkgconfig || true;             \
375 cp $(abs_srcdir)/zlib.pc $$$${pkgidir}/lib/pkgconfig/;  \
376 cd $$$${pkgidir};                                       \
377 echo "# Generated by libtool" > lib/libz.la             \
378 echo "dlname='../bin/zlib1.dll'" >> lib/libz.la;        \
379 echo "library_names='libz.dll.a'" >> lib/libz.la;       \
380 echo "old_library='libz.a'" >> lib/libz.la;             \
381 echo "dependency_libs=''" >> lib/libz.la;               \
382 echo "current=1" >> lib/libz.la;                        \
383 echo "age=2" >> lib/libz.la;                            \
384 echo "revision=5" >> lib/libz.la;                       \
385 echo "installed=yes" >> lib/libz.la;                    \
386 echo "shouldnotlink=no" >> lib/libz.la;                 \
387 echo "dlopen=''" >> lib/libz.la;                        \
388 echo "dlpreopen=''" >> lib/libz.la;                     \
389 echo "libdir=\"$$$${pkgidir}/lib\"" >> lib/libz.la)
390 endef
391
392 # To make sure that we link against the static versions we need
393 # remove the import libs from crypt
394 #define gpg4win_pkg_crypt_post_install
395 #(cd $$$${pkgidir}/lib && rm libcrypt.dll.a libcrypt.lib)
396 #endef
397
398 # We need to fix the prefix in the various packages using pkgconfig,
399 # or we can't substitute it properly in our pkg-config wrapper.
400 define gpg4win_pkg_glib_post_install
401  (cd $$$${pkgidir};                                                     \
402  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
403 endef
404
405 define gpg4win_pkg_libffi_post_install
406  (cd $$$${pkgidir};                                                     \
407  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
408 endef
409
410 define gpg4win_pkg_gdk_pixbuf_post_install
411  (cd $$$${pkgidir};                                                     \
412  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
413 endef
414
415 define gpg4win_pkg_atk_post_install
416  (cd $$$${pkgidir_dev};                                                 \
417  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
418 endef
419
420 define gpg4win_pkg_freetype_post_install
421  (cd $$$${pkgidir_dev};                                                 \
422  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
423 endef
424
425 define gpg4win_pkg_fontconfig_post_install
426  (cd $$$${pkgidir_dev};                                                 \
427  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
428 endef
429
430 define gpg4win_pkg_cairo_post_install
431  (cd $$$${pkgidir_dev};                                                 \
432  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
433 endef
434
435 define gpg4win_pkg_pango_post_install
436  (cd $$$${pkgidir_dev};                                                 \
437  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
438 endef
439
440 define gpg4win_pkg_gtk__post_install
441  (cd $$$${pkgidir_dev};                                                 \
442  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
443 endef
444
445 define gpg4win_pkg_libpng_post_install
446  (cd $$$${pkgidir};                                                     \
447  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
448 endef
449
450 define gpg4win_pkg_enchant_post_install
451  (cd $$$${pkgidir};                                                     \
452  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
453 endef
454
455
456 define gpg4win_pkg_libiconv_post_install
457 (cp $(srcdir)/libiconv.def $$$${pkgidir}/lib;           \
458 cd $$$${pkgidir}/lib;                                   \
459 $(DLLTOOL) --output-lib libiconv.dll.a --def libiconv.def)
460 endef
461
462 # Qt is missing the pkgconfig files.
463 define gpg4win_pkg_qt_post_install
464 (mkdir $$$${pkgidir_dev}/lib/pkgconfig; \
465  cp $(srcdir)/QtCore.pc $(srcdir)/QtGui.pc $$$${pkgidir_dev}/lib/pkgconfig/)
466 endef
467
468
469 # kdesupport ships gettext, which we already have.  Remove a stow
470 # conflict about that.  Also remove a stow conflict with kdelibs-lib.
471 define gpg4win_pkg_kdesupport_post_install
472 (rm -fR "$$$${pkgidir_dev}/share/locale"; \
473  rm -fR "$$$${pkgidir_dev}/share/apps/cmake/modules")
474 endef
475
476 # libxml2 ships some binaries, which we already have from kdesupport.  Remove a stow
477 # conflict about that.
478 define gpg4win_pkg_libxml2_post_install
479 (rm -f "$$$${pkgidir}/bin/xmllint.exe"; \
480  rm -f "$$$${pkgidir}/bin/xmlcatalog.exe")
481 endef
482
483 # Supported internal packages.  Internal packages do not require any
484 # special support.  Thus, this variable is actually unused, and no
485 # rules are added in gpg4win.mk.
486 gpg4win_ipkgs = man_novice_de man_advanced_de man_novice_en man_advanced_en \
487                 compendium
488
489
490 # Now do the bunch of the work.  This is a bunch of dirty magic to
491 # integrate our special makefile into automake, while not actually
492 # including it (make should include it).  This is in turn necessary
493 # because automake can't deal with the elegant magic in the actual
494 # Makefile.
495
496 define INCLUDE_BY_MAKE
497 include $(1)
498 endef
499
500 $(eval $(call INCLUDE_BY_MAKE,gpg4win.mk))
501
502 clean-local: clean-gpg4win
503
504 common_nsi = inst-sections.nsi installer.nsi installer-finish.nsi       \
505   $(addsuffix .nsi,$(addprefix inst-,$(gpg4win_build_list)))            \
506   $(addsuffix .nsi,$(addprefix uninst-,$(gpg4win_build_list)))
507
508
509 # Prepare the versioninfo file.  The pipeline extracts the last
510 # occurrence of a package with the same name, sorts the entries and
511 # writes the file with DOS line endings.  This helps to avoid
512 # duplicate entries in case one package has been rebuild (which is
513 # common when developing a new version).
514 versioninfo.txt:
515         $(SHA1SUM) $(pkg_files) </dev/null > versioninfo.tmp
516         set -e; \
517         ( while read a b; do echo "$$a $$(basename $$b)"; \
518             done < versioninfo.tmp \
519           | sort -k2 -sf | tac | uniq -f1 ; \
520           echo '=========== SHA-1 checksum ============= == package ==' \
521          ) | tac | awk '{printf "%s\r\n", $$0}' > versioninfo.txt
522         -rm versioninfo.tmp
523
524 NEWS.tmp : $(top_srcdir)/NEWS
525          awk '/^#/ {next} /^\(de\)/ {skip=1;next} /^[^[:space:]]/ {skip=0} \
526              !skip { sub(/^\(en\)/,"   *"); print }' \
527              <$(top_srcdir)/NEWS >NEWS.tmp
528
529 COMPONENTS-list.tmp : $(top_srcdir)/NEWS
530         awk '/^~~~~~~~~~~~/ { ok++; next} ok==1 {print "    "$$0}' \
531             < $(top_srcdir)/NEWS > COMPONENTS-list.tmp
532
533 installer-options.ini : $(top_srcdir)/src/installer-options.ini.in
534         cat $(top_srcdir)/src/installer-options.ini.in >installer-options.ini
535
536
537 # For some nut-crazy reason someone thought it would be a great idea
538 # if makensis changed to the directory of the source file at startup.
539 # So we have to pull a couple of strings to correct this.
540 gpg4win-$(VERSION).exe: gpg4win.nsi $(common_nsi) stamps/stamp-final \
541                         g4wihelp.dll gpgwrap.exe gpgwrap-2.exe kleowrap.exe \
542                         $(foosum_exe) \
543                         $(README_files) $(HOWTO_files) \
544                         installer-options.ini versioninfo.txt
545         $(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
546            -DSRCDIR=$(srcdir) $(EXTRA_MAKENSIS_FLAGS) $(srcdir)/gpg4win.nsi
547
548 gpg4win-light-$(VERSION).exe: gpg4win.nsi $(common_nsi) stamps/stamp-final \
549                         g4wihelp.dll gpgwrap.exe gpgwrap-2.exe kleowrap.exe \
550                         $(foosum_exe) \
551                         $(README_files) $(HOWTO_files) \
552                         installer-options.ini versioninfo.txt
553         $(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
554            -DSRCDIR=$(srcdir) $(EXTRA_MAKENSIS_FLAGS) \
555            -DGPG4WIN_LIGHT=1 $(srcdir)/gpg4win.nsi
556
557 gpg4win-vanilla-$(VERSION).exe: gpg4win.nsi $(common_nsi) stamps/stamp-final \
558                         g4wihelp.dll gpgwrap.exe gpgwrap-2.exe \
559                         $(foosum_exe) \
560                         $(README_files) $(HOWTO_files) \
561                         installer-options.ini versioninfo.txt
562         $(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
563            -DSRCDIR=$(srcdir) $(EXTRA_MAKENSIS_FLAGS) \
564            -DGPG4WIN_VANILLA=1 $(srcdir)/gpg4win.nsi
565
566 gpg4win-$(VERSION).wix: gpg4win.nsi $(common_nsi) stamps/stamp-final \
567                         gpgwrap.exe gpgwrap-2.exe kleowrap.exe \
568                         $(foosum_exe) \
569                         $(README_files) $(HOWTO_files) \
570                         versioninfo.txt
571         perl make-msi.pl --guids $(srcdir)/make-msi.guids \
572                 --manifest gpg4win-$(VERSION).files \
573                 -DBUILD_DIR=. -DTOP_SRCDIR=$(top_srcdir) \
574                 -DSRCDIR=$(srcdir) $(srcdir)/gpg4win.nsi > $@
575
576 gpg4win-light-$(VERSION).wix: gpg4win.nsi $(common_nsi) stamps/stamp-final \
577                         gpgwrap.exe gpgwrap-2.exe kleowrap.exe \
578                         $(foosum_exe) \
579                         $(README_files) $(HOWTO_files) \
580                         versioninfo.txt
581         perl make-msi.pl --guids $(srcdir)/make-msi.guids \
582                 --manifest gpg4win-light-$(VERSION).files \
583                 -DBUILD_DIR=. -DTOP_SRCDIR=$(top_srcdir) \
584                 -DSRCDIR=$(srcdir) -DGPG4WIN_LIGHT=1 $(srcdir)/gpg4win.nsi > $@
585
586 gpg4win-vanilla-$(VERSION).wix: gpg4win.nsi $(common_nsi) stamps/stamp-final \
587                         gpgwrap.exe gpgwrap-2.exe kleowrap.exe \
588                         $(foosum_exe) \
589                         $(README_files) $(HOWTO_files) \
590                         versioninfo.txt
591         perl make-msi.pl --guids $(srcdir)/make-msi.guids \
592                 --manifest gpg4win-vanilla-$(VERSION).files \
593                 -DBUILD_DIR=. -DTOP_SRCDIR=$(top_srcdir) \
594                 -DSRCDIR=$(srcdir) -DGPG4WIN_VANILLA=1 $(srcdir)/gpg4win.nsi > $@
595
596 .PHONY: msi
597 msi: gpg4win-$(VERSION).wix gpg4win-light-$(VERSION).wix \
598      gpg4win-vanilla-$(VERSION).wix
599
600
601 stamps/stamp-dist-self: versioninfo.txt
602         (set -e; cd ..; make dist-bzip2)
603         touch stamps/stamp-dist-self
604
605 gpg4win-src-$(VERSION).exe: gpg4win-src.nsi $(common_nsi) stamps/stamp-final \
606                             stamps/stamp-dist-self installer-options.ini
607         $(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
608           -DSRCDIR=$(srcdir) $(EXTRA_MAKENSIS_FLAGS) $(srcdir)/gpg4win-src.nsi
609
610 g4wihelp.dll: g4wihelp.c exdll.h
611         $(CC) -I. -shared -O2 -o g4wihelp.dll $(srcdir)/g4wihelp.c \
612            -lwinmm -lgdi32
613         $(STRIP) g4wihelp.dll
614
615 gpgwrap.exe: gpgwrap.c
616         $(CC) -I. -I.. -DHAVE_CONFIG_H -O2 -o $@ $^
617         $(STRIP) $@
618
619 gpgwrap-2.exe: gpgwrap.c
620         $(CC) -I. -I.. -DHAVE_CONFIG_H -DGPGWRAP_VARIANT=2 -O2 -o $@ $^
621         $(STRIP) $@
622
623 kleowrap.exe: kleowrap.c
624         $(CC) -I. -I.. -DHAVE_CONFIG_H -O2 -mwindows -o $@ $^
625         $(STRIP) $@
626
627 sha1sum.exe: sha1sum.c
628         $(CC) -O2 -o $@ $^
629         $(STRIP) $@
630
631 md5sum.exe: sha1sum.c
632         $(CC) -DBUILD_MD5SUM -O2 -o $@ $^
633         $(STRIP) $@
634
635 sha256sum.exe: sha1sum.c
636         $(CC) -DBUILD_SHA256SUM -O2 -o $@ $^
637         $(STRIP) $@
638
639
640 if BUILD_SOURCE_INSTALLER
641 all_src = gpg4win-src-$(VERSION).exe
642 else
643 all_src =
644 endif
645
646 if BUILD_LIGHT_INSTALLER
647 all_light = gpg4win-light-$(VERSION).exe
648 else
649 all_light =
650 endif
651
652 if BUILD_VANILLA_INSTALLER
653 all_vanilla = gpg4win-vanilla-$(VERSION).exe
654 else
655 all_vanilla =
656 endif
657
658 if BUILD_FULL_INSTALLER
659 all_full = gpg4win-$(VERSION).exe
660 else
661 all_full =
662 endif
663
664 all-local: $(all_full) $(all_light) $(all_vanilla) $(all_src)
665
666 clean-local:
667         rm -f gpg4win-$(VERSION).exe gpg4win-light-$(VERSION).exe \
668             gpg4win-vanilla-$(VERSION).exe gpg4win-src-$(VERSION).exe