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