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