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