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