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