2007-05-19 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
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 cairo \
107                   atk gtk+ 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_cairo_post_install
170  (cd $$$${pkgidir_dev};                                                 \
171  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
172 endef
173
174 define gpg4win_pkg_pango_post_install
175  (cd $$$${pkgidir_dev};                                                 \
176  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
177 endef
178
179 define gpg4win_pkg_gtk__post_install
180  (cd $$$${pkgidir_dev};                                                 \
181  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
182 endef
183
184 # In libpng, the pkg-config files are surprisingly found in the
185 # runtime package.
186 define gpg4win_pkg_libpng_post_install
187  (cd $$$${pkgidir};                                                     \
188  perl -pi -e 's/^prefix=.*$$$$/prefix=\/usr/' `find . -name \*.pc`)
189 endef
190
191
192 # Supported internal packages.  Internal packages do not require any
193 # special support.  Thus, this variable is actually unused, and no
194 # rules are added in gpg4win.mk.
195 gpg4win_ipkgs = man_novice_de man_advanced_de man_novice_en man_advanced_en
196
197
198 # Now do the bunch of the work.  This is a bunch of dirty magic to
199 # integrate our special makefile into automake, while not actually
200 # including it (make should include it).  This is in turn necessary
201 # because automake can't deal with the elegant magic in the actual
202 # Makefile.
203
204 define INCLUDE_BY_MAKE
205 include $(1)
206 endef
207
208 $(eval $(call INCLUDE_BY_MAKE,gpg4win.mk))
209
210 clean-local: clean-gpg4win
211
212 common_nsi = inst-sections.nsi installer.nsi installer-finish.nsi       \
213   $(addsuffix .nsi,$(addprefix inst-,$(gpg4win_build_list)))            \
214   $(addsuffix .nsi,$(addprefix uninst-,$(gpg4win_build_list)))
215
216
217 # Prepare the versioninfo file.  The pipeline extracts the last
218 # occurrence of a package with the same name, sorts the entries and
219 # writes the file with DOS line endings.  This helps to avoid
220 # duplicate entries in case one package has been rebuild (which is
221 # common when developing a new version).
222 versioninfo.txt : playground/build/versioninfo.txt
223         set -e; \
224         ( while read a b; do echo "$$a $$(basename $$b)"; \
225             done < playground/build/versioninfo.txt \
226           | sort -k2 -sf | tac | uniq -f1 ; \
227           echo '=========== SHA-1 checksum ============= == package ==' \
228          ) | tac | awk '{printf "%s\r\n", $$0}' > versioninfo.txt
229
230 NEWS.tmp : $(top_srcdir)/NEWS
231         sed -e '/^#/d' <$(top_srcdir)/NEWS >NEWS.tmp
232
233 README.en.txt : versioninfo.txt NEWS.tmp $(top_srcdir)/doc/README.en.txt
234         sed -e '/^;.*/d;/!VERSIONINFO!/{r versioninfo.txt' -e 'd;}' \
235         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
236         -e '/!PKG-COPYRIGHT!/{r $(top_srcdir)/doc/pkg-copyright.txt' -e 'd;}' \
237         -e 's,!VERSION!,$(VERSION),g' \
238            < $(top_srcdir)/doc/README.en.txt \
239            | awk '{printf "%s\r\n", $$0}' >README.en.txt
240
241 installer-options.ini : $(top_srcdir)/src/installer-options.ini.in
242         cat $(top_srcdir)/src/installer-options.ini.in >installer-options.ini
243
244 README.de.txt : versioninfo.txt NEWS.tmp $(top_srcdir)/doc/README.de.txt
245         sed -e '/^;.*/d;/!VERSIONINFO!/{r versioninfo.txt' -e 'd;}' \
246         -e '/!NEWSFILE!/{r NEWS.tmp' -e 'd;}' \
247         -e '/!PKG-COPYRIGHT!/{r $(top_srcdir)/doc/pkg-copyright.txt' -e 'd;}' \
248         -e 's,!VERSION!,$(VERSION),g' \
249            < $(top_srcdir)/doc/README.de.txt \
250            | awk '{printf "%s\r\n", $$0}' >README.de.txt
251
252 # For some nut-crazy reason someone thought it would be a great idea
253 # if makensis changed to the directory of the source file at startup.
254 # So we have to pull a couple of strings to correct this.
255 gpg4win-$(VERSION).exe: gpg4win.nsi $(common_nsi) stamps/stamp-final \
256                         g4wihelp.dll gpgwrap.exe README.en.txt README.de.txt \
257                         installer-options.ini
258         $(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
259                 -DSRCDIR=$(srcdir) $(srcdir)/gpg4win.nsi
260
261 gpg4win-light-$(VERSION).exe: gpg4win.nsi $(common_nsi) stamps/stamp-final \
262                         g4wihelp.dll gpgwrap.exe README.en.txt README.de.txt \
263                         installer-options.ini
264         $(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
265                 -DSRCDIR=$(srcdir) -DGPG4WIN_LIGHT=1 $(srcdir)/gpg4win.nsi
266
267 stamps/stamp-dist-self: versioninfo.txt
268         (set -e; cd ..; make dist-bzip2)
269         touch stamps/stamp-dist-self
270
271 gpg4win-src-$(VERSION).exe: gpg4win-src.nsi $(common_nsi) stamps/stamp-final \
272                             stamps/stamp-dist-self installer-options.ini
273         $(MAKENSIS) -V3 -DBUILD_DIR=`pwd` -DTOP_SRCDIR=$(top_srcdir) \
274                 -DSRCDIR=$(srcdir) $(srcdir)/gpg4win-src.nsi
275
276 g4wihelp.dll: g4wihelp.c exdll.h
277         $(CC) -I. -shared -O2 -o g4wihelp.dll $(srcdir)/g4wihelp.c \
278            -lwinmm -lgdi32
279         $(STRIP) g4wihelp.dll
280
281 gpgwrap.exe: gpgwrap.c
282         $(CC) -I. -I.. -DHAVE_CONFIG_H -O2 -o gpgwrap.exe $(srcdir)/gpgwrap.c 
283         $(STRIP) gpgwrap.exe
284
285 if BUILD_SOURCE_INSTALLER
286 all_src = gpg4win-src-$(VERSION).exe
287 else
288 all_src =
289 endif
290
291 if BUILD_LIGHT_INSTALLER
292 all_light = gpg4win-light-$(VERSION).exe
293 else
294 all_light =
295 endif
296
297 all-local: gpg4win-$(VERSION).exe $(all_light) $(all_src)
298
299 clean-local:
300         rm -f gpg4win-$(VERSION).exe gpg4win-light-$(VERSION).exe \
301             gpg4win-src-$(VERSION).exe