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