]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/extras/Makefile.install
Build a threadsafe libjs so that JavaScript::SpiderMonkey can be threadsafe
[working/Evergreen.git] / Open-ILS / src / extras / Makefile.install
1 # ---------------------------------------------------------------------
2 # Author: Bill Erickson <erickson@esilibrary.com>
3 #
4 # Makefile to install prerequisites for OpenSRF and Evergreen
5 #
6 # Currently supports Debian (etch/lenny), Ubuntu (hardy/lucid), and Fedora (13).
7 # Working towards support of CentOS 5 / RHEL 5.
8 # Installs Perl prereqs, libjs with Perl wrapper, libdbi, libdbi-drivers, and libyaz
9 #
10 # usage:
11 #       make -f Makefile.install debian-etch
12 #       - or -
13 #       make -f Makefile.install debian-lenny
14 #       - or -
15 #       make -f Makefile.install ubuntu-hardy
16 #       - or -
17 #       make -f Makefile.install ubuntu-lucid
18 #       - or -
19 #       make -f Makefile.install fedora-13
20 #       - or -
21 #       make -f Makefile.install centos
22 #       - or -
23 #       make -f Makefile.install rhel
24 #
25 # Notes:
26 #
27 #       This makefile has been tested much more with Debian and Ubuntu than
28 #       Fedora, CentOS, or RHEL.
29 #
30 # ---------------------------------------------------------------------
31  
32 # Make any assumptions about the shell being used explicit
33 SHELL=/bin/bash 
34
35 LIBJS=js-1.7.0
36 LIBJS_PERL=JavaScript-SpiderMonkey-0.20
37 LIBJS_URL=ftp://ftp.mozilla.org/pub/mozilla.org/js/$(LIBJS).tar.gz
38 LIBJS_PERL_URL=ftp://mirror.datapipe.net/pub/CPAN/authors/id/T/TB/TBUSCH/$(LIBJS_PERL).tar.gz
39 # used for installing libjs lib and header files
40 JS_INSTALL_PREFIX=/usr/
41
42 # The libdbi sources can be fetched from sourceforge.net.  They are stored on
43 # the open-ils.org site now for ease of direct linking
44 LIBDBI=libdbi-0.8.3
45 LIBDBI_DRIVERS=libdbi-drivers-0.8.3
46 LIBDBI_HOST=http://open-ils.org/~denials/evergreen
47
48 # We need a recent version of Yaz
49 # Debian Lenny and Ubuntu 8.10 come with 3.0.34
50 YAZ=yaz-3.0.47
51 YAZ_HOST=http://ftp.indexdata.dk/pub/yaz
52
53 # Business::OnlinePayment is not packaged on CentOS/RHEL
54 PAY_ONLINE=Business-OnlinePayment-3.00_08.tar.gz
55 PAY_ONLINE_HOST=http://ftp.perl.org/pub/CPAN/authors/id/I/IV/IVAN/
56
57 APT_TOOL=aptitude -yq
58
59 # 64 or 32 bit os?
60 LBITS=$(shell getconf LONG_BIT)
61
62 # Fedora 64-bit?
63 FEDORA_64=$(shell uname -r | grep "fc[0-9][0-9].x86_64")
64
65 #RHEL/Centos PGSQL 
66 PGSQL_HOST=http://yum.pgsqlrpms.org/reporpms/8.4
67 PGSQL_CENTOS=pgdg-centos-8.4-2.noarch.rpm
68 PGSQL_REDHAT=pgdg-redhat-8.4-2.noarch.rpm       
69
70 # Debian dependencies
71 DEBS =  \
72         apache2-prefork-dev\
73         aspell\
74         aspell-en\
75         libbusiness-creditcard-perl\
76         libbusiness-onlinepayment-authorizenet-perl\
77         libbusiness-onlinepayment-perl\
78         libdatetime-format-builder-perl\
79         libdatetime-format-iso8601-perl\
80         libdatetime-format-mail-perl\
81         libdatetime-perl\
82         libdatetime-timezone-perl\
83         libdatetime-set-perl\
84         libdbd-pg-perl\
85         libemail-send-perl\
86         libgd-graph3d-perl\
87         liblog-log4perl-perl\
88         libmarc-record-perl\
89         libncurses5-dev\
90         libnet-server-perl\
91         libnspr4-dev\
92         libole-storage-lite-perl\
93         libpq-dev\
94         libreadline5-dev\
95         libspreadsheet-writeexcel-perl\
96         libssh2-1-dev\
97         libtext-aspell-perl\
98         libtext-csv-perl\
99         libuniversal-require-perl\
100         libunix-syslog-perl
101
102 # Debian Lenny and Ubuntu Intrepid bundle recent versions of yaz
103 EXTRA_DEBS = \
104         libmarc-charset-perl \
105         libmarc-xml-perl \
106         libnet-z3950-zoom-perl \
107         libyaz-dev \
108         yaz
109
110 # Ubuntu Hardy and Debian Etch require libencode-perl 
111 # to get a version of Encode > 2.12 - see bug 525069.
112 # Note that the Debian version of libencode-perl comes
113 # from etch-backports.
114 EXTRA_ENCODE = \
115         libencode-perl
116
117 CENTOS = \
118         aspell \
119         aspell-devel \
120         aspell-en \
121         gd-devel \
122         libssh2-devel \
123         openssl-devel \
124         perl-Business-CreditCard \
125         perl-Business-OnlinePayment \
126         perl-Class-Data-Inheritable \
127         perl-DateTime-Format-Builder \
128         perl-DateTime-Format-Strptime \
129         perl-Ima-DBI \
130         perl-DBD-Pg \
131         perl-GD-Graph3d \
132         perl-IO-stringy \
133         perl-Spreadsheet-WriteExcel \
134         perl-Text-Aspell \
135         perl-Text-CSV
136
137 CENTOS_PERL = \
138         Class::DBI::Frozen::301 \
139         Encode \
140         DBIx::ContextualFetch \
141         Getopt::Long \
142         Net::SSH2 \
143         Net::uFTP \
144         Net::XMPP \
145         Net::Z3950::ZOOM
146
147 FEDORA_13_RPMS = \
148         aspell \
149         aspell-en \
150         js-devel \
151         libdbi \
152         libdbi-dbd-pgsql \
153         libdbi-devel \
154         libssh2-devel \
155         libyaz \
156         libyaz-devel \
157         mod_ssl \
158         ncurses-devel \
159         ncurses-libs \
160         perl-Business-CreditCard \
161         perl-Email-Send \
162         perl-GDGraph3d \
163         perl-MARC-Record \
164         perl-Net-SSH2 \
165         perl-OLE-Storage_Lite \
166         perl-Spreadsheet-WriteExcel \
167         perl-Text-Aspell \
168         perl-Text-CSV \
169         perl-Text-CSV_XS \
170         perl-XML-Writer \
171         postgresql-devel \
172         readline-devel \
173         tcp_wrappers-devel \
174         yaz
175
176 # Note: B:O:AuthorizeNet 3.21 fails with https://rt.cpan.org/Public/Bug/Display.html?id=55172
177 # Should be fixed in 3.22
178 FEDORA_13_CPAN = \
179         Business::OnlinePayment \
180         Business::OnlinePayment::AuthorizeNet \
181         Class::DBI::Frozen::301
182
183 PGSQL_84_RPMS = \
184         postgresql-8.4* \
185         postgresql-contrib-8.4* \
186         postgresql-devel-8.4* \
187         postgresql-plpe*-8.4* \
188         postgresql-server-8.4*
189
190 PGSQL_CLIENT_DEBS_81 = \
191         postgresql-client-8.1
192
193 PGSQL_SERVER_DEBS_81 = \
194         postgresql-8.1 \
195         postgresql-contrib-8.1 \
196         postgresql-plperl-8.1 \
197         postgresql-server-dev-8.1
198
199 PGSQL_CLIENT_DEBS_82 = \
200         postgresql-client
201
202 PGSQL_SERVER_DEBS_82 = \
203         postgresql \
204         postgresql-contrib-8.2 \
205         postgresql-plperl-8.2 \
206         postgresql-server-dev-8.2
207
208 PGSQL_CLIENT_DEBS_83 = \
209         postgresql-client
210
211 PGSQL_SERVER_DEBS_83 = \
212         postgresql \
213         postgresql-contrib-8.3 \
214         postgresql-plperl-8.3 \
215         postgresql-server-dev-8.3
216
217 PGSQL_CLIENT_DEBS_84 = \
218         postgresql-client
219
220 PGSQL_SERVER_DEBS_84 = \
221         postgresql \
222         postgresql-contrib-8.4 \
223         postgresql-plperl-8.4 \
224         postgresql-server-dev-8.4
225
226 DEB_APACHE_MODS = \
227     expires\
228     include\
229     proxy\
230     proxy_http\
231     rewrite
232
233 DEB_APACHE_DISMODS = \
234     deflate
235
236 # Chronically unpackaged CPAN modules
237 CPAN_MODULES = \
238     Business::CreditCard::Object \
239     Business::EDI \
240     Net::uFTP \
241     Net::Z3950::Simple2ZOOM \
242     UUID::Tiny \
243     SRU
244
245 # Are we sure most distros don't come with an acceptable version of Safe.pm?
246 CPAN_MODULES_SAFE = \
247         Safe
248
249 # Recent Debian/Ubuntus have libmarc-charset-perl, libmarc-xml-perl, libnet-z3950-zoom-perl
250 CPAN_MODULES_MARC = \
251     MARC::Charset \
252     MARC::File::XML \
253     Net::Z3950::ZOOM
254
255 # ----------------------------------------------------------------------------
256
257 all: 
258         @echo "please specify an OS" && exit 0
259
260 # these should be the same for any distro
261 install: install_cpan install_js_sm install_libdbi 
262
263 centos: install_centos_pgsql install_centos_rpms install_yaz install_cpan_marc install install_centos_perl create_ld_local install_cpan_safe
264 rhel: install_redhat_pgsql install_centos_rpms install_yaz install_cpan_marc install install_centos_perl create_ld_local install_cpan_safe
265
266 fedora-13: install_fedora_13_rpms install_cpan install_cpan_marc install_cpan_fedora install_spidermonkey
267
268 debian-etch: etch generic_debian
269 debian-lenny: lenny generic_debian
270 etch: install_pgsql_client_debs_81 install_yaz install_cpan_marc install_extra_encode
271 lenny: install_pgsql_client_debs_83 install_extra_debs
272 generic_debian:  install_debs install debian_sys_config install_cpan_safe
273
274 ubuntu-hardy: hardy generic_ubuntu
275 ubuntu-lucid: lucid generic_ubuntu
276 hardy: install_pgsql_client_debs_82 install_yaz install_cpan_marc install_extra_encode
277 lucid: install_pgsql_client_debs_84 install_extra_debs
278 generic_ubuntu: install_debs install debian_sys_config install_cpan_safe
279
280 # - COMMON TARGETS ---------------------------------------------------------
281
282 # Install the CPAN modules
283 install_cpan: 
284         for m in $(CPAN_MODULES); do perl -MCPAN -e "install \"$$m\";"; done
285
286 # Install the CPAN modules for MARC functionality
287 install_cpan_marc: 
288         for m in $(CPAN_MODULES_MARC); do perl -MCPAN -e "install \"$$m\";"; done
289
290 # Install the Safe Perl module
291 # Is this really unpackaged everywhere except for Fedora?
292 install_cpan_safe: 
293         for m in $(CPAN_MODULES_SAFE); do perl -MCPAN -e "install \"$$m\";"; done
294
295 # Install the CPAN modules for Fedora 13
296 install_cpan_fedora: 
297         for m in $(FEDORA_13_CPAN); do perl -MCPAN -e "install \"$$m\";"; done
298
299 # Install a known working version of YAZ
300 install_yaz:    
301         if [ ! -d $(YAZ) ]; then wget $(YAZ_HOST)/$(YAZ).tar.gz; fi;
302         tar xzf $(YAZ).tar.gz
303         cd $(YAZ) && ./configure && make && make install && ldconfig
304
305 # Install the custom spidermonkey libs and JavaScript-SpiderMonkey Perl modules
306 install_js_sm: install_libjs install_spidermonkey
307
308 install_libjs: 
309         if [ ! -f $(LIBJS).tar.gz ]; then wget $(LIBJS_URL); fi;
310         tar -zxf $(LIBJS).tar.gz
311         cd js/src/ && JS_THREADSAFE=true JS_DIST=/usr make -f Makefile.ref
312         mkdir -p $(JS_INSTALL_PREFIX)/include/js/
313         cp js/src/*.h $(JS_INSTALL_PREFIX)/include/js/
314         cp js/src/*.tbl $(JS_INSTALL_PREFIX)/include/js/
315         cp js/src/Linux_All_DBG.OBJ/*.so $(JS_INSTALL_PREFIX)/lib/
316         cp js/src/Linux_All_DBG.OBJ/*.a $(JS_INSTALL_PREFIX)/lib/
317
318 install_spidermonkey:
319         if [ ! -f $(LIBJS_PERL).tar.gz ]; then wget $(LIBJS_PERL_URL); fi;
320         tar -zxf $(LIBJS_PERL).tar.gz
321         if [ ! -z $(FEDORA_64) ]; then \
322                 sed -i -e 's/"\/usr\/lib"/"\/usr\/lib64"/' $(LIBJS_PERL)/Makefile.PL ; \
323                 sed -i -e 's/js32.dll/libjs.so/' $(LIBJS_PERL)/Makefile.PL ; \
324         fi;
325         cd $(LIBJS_PERL) && perl Makefile.PL -E4X -JS_THREADSAFE && make && make test && make install
326
327
328 # Install libdbi and the postgres drivers
329 install_libdbi:
330         if [ ! -d $(LIBDBI) ]; then wget $(LIBDBI_HOST)/$(LIBDBI).tar.gz; fi;
331         if [ ! -d $(LIBDBI_DRIVERS) ]; then wget $(LIBDBI_HOST)/$(LIBDBI_DRIVERS).tar.gz; fi;
332         tar -zxf $(LIBDBI).tar.gz
333         tar -zxf $(LIBDBI_DRIVERS).tar.gz
334         cd $(LIBDBI) && ./configure --disable-docs && make all install
335         cd $(LIBDBI_DRIVERS) && ./configure  \
336                 --disable-docs --with-pgsql --enable-libdbi && make all install  
337
338
339 clean:
340         make -C $(LIBDBI) clean
341         make -C $(LIBDBI_DRIVERS) clean
342         make -C $(LIBJS_PERL) clean
343         make -f Makefile.ref -C js/src/ clean
344
345
346 # ------------------------------------------------------------------
347 # - DEBIAN ---------------------------------------------------------
348
349 debian_sys_config: 
350         # link the apache modules in
351         for m in $(DEB_APACHE_MODS); do a2enmod $$m; done;
352         # keep the bad apache modules away
353         for m in $(DEB_APACHE_DISMODS); do a2dismod $$m; done;
354         # refresh the dynamic library cache
355         ldconfig
356
357 # Install the debian-specific dependencies
358 install_debs:
359         $(APT_TOOL) install $(DEBS)
360
361 install_pgsql_client_debs_84:
362         $(APT_TOOL) install $(PGSQL_CLIENT_DEBS_84)
363
364 install_pgsql_server_debs_84:
365         LANG=C $(APT_TOOL) install $(PGSQL_SERVER_DEBS_84)
366
367 install_pgsql_client_debs_83:
368         $(APT_TOOL) install $(PGSQL_CLIENT_DEBS_83)
369
370 install_pgsql_server_debs_83:
371         LANG=C $(APT_TOOL) install $(PGSQL_SERVER_DEBS_83)
372
373 install_pgsql_client_debs_82:
374         $(APT_TOOL) install $(PGSQL_CLIENT_DEBS_82)
375
376 install_pgsql_server_debs_82:
377         LANG=C $(APT_TOOL) install $(PGSQL_SERVER_DEBS_82)
378
379 # Etch requires an explicit version to avoid PostgreSQL 7.4
380 install_pgsql_client_debs_81:
381         $(APT_TOOL) install $(PGSQL_CLIENT_DEBS_81)
382
383 # Etch requires an explicit version to avoid PostgreSQL 7.4
384 install_pgsql_server_debs_81:
385         LANG=C $(APT_TOOL) install $(PGSQL_SERVER_DEBS_81)
386
387 # Install the debian-specific dependencies for more modern distros
388 install_extra_debs:
389         $(APT_TOOL) install $(EXTRA_DEBS)
390
391 # Install specific modules required by Ubuntu Hardy and
392 # Debian Etch - see bug 525069
393 install_extra_encode:
394         $(APT_TOOL) install $(EXTRA_ENCODE)
395
396 # ------------------------------------------------------------------
397
398 # FEDORA 13
399 install_fedora_13_rpms:
400         yum -y update
401         yum -y install $(FEDORA_13_RPMS)
402
403 install_fedora_13_pgsql_server:
404         yum -y install $(PGSQL_84_RPMS)
405
406 # CENTOS
407 install_centos_rpms:
408         yum -y install $(CENTOS)
409         yum -y update
410         if [ $(LBITS) -eq 64 ]; then \
411                 ln -sf /usr/lib64/libpq.* /usr/lib/ && \
412                 ln -sf /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so /usr/lib/ && \
413                 ldconfig ; \
414         fi;
415         if [ $(LBITS) -eq 32 ]; then \
416                 ln -sf /usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/libperl.so /usr/lib && \
417                 ldconfig ; \
418         fi;
419
420 install_centos_pgsql:
421         if [ $(LBITS) -eq 64 ]; then yum remove -y postgresql-libs-8.1*i386 apr-util-devel-*i386 ; fi;
422         wget $(PGSQL_HOST)/$(PGSQL_CENTOS)
423         rpm -Uvh --force ./$(PGSQL_CENTOS)
424         yum update -y
425         yum -y install $(PGSQL_84_RPMS)
426
427 install_redhat_pgsql:
428         if [ $(LBITS) -eq 64 ]; then yum remove -y postgresql-libs-8.1*i386 apr-util-devel-*i386 ; fi;
429         wget $(PGSQL_HOST)/$(PGSQL_REDHAT)
430         rpm -Uvh --force ./$(PGSQL_REDHAT)
431         yum update -y
432         yum -y install $(PGSQL_84_RPMS)
433
434 install_centos_perl:
435         for m in $(CENTOS_PERL); do perl -MCPAN -e "install \"$$m\";"; done
436         echo "force install Business::OnlinePayment::AuthorizeNet" | perl -MCPAN -e shell
437         echo "force install Scalar::Util" | perl -MCPAN -e shell        
438
439 # We need to add /usr/local/lib to the ldconfig list of directories on CentOS,
440 # if it is not already there
441 create_ld_local:
442         if [ "$$(ldconfig -v 2> /dev/null | grep '^/usr/local/lib' | wc -l)" -eq 0 ]; then \
443                 echo '/usr/local/lib' >> /etc/ld.so.conf.d/local.conf; \
444                 ldconfig; \
445         fi;
446
447 # vim:noet:sw=4:ts=4: