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