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