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