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