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