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