]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/extras/Makefile.install
Merge branch 'master' of git.evergreen-ils.org:Evergreen into dbs/tpac-non-fixed...
[Evergreen.git] / Open-ILS / src / extras / Makefile.install
1 # ---------------------------------------------------------------------
2 # Author: Bill Erickson <erickson@esilibrary.com>
3 # Author: Dan Scott <dscott@laurentian.ca>
4 #
5 # Makefile to install prerequisites for OpenSRF and Evergreen
6 #
7 # Currently supports Debian (squeeze), Ubuntu (lucid), and Fedora (16).
8 # Working towards support of CentOS 5 / RHEL 5.
9 # Installs Perl prereqs, libjs with Perl wrapper, libdbi, libdbi-drivers, and libyaz
10 #
11 # usage:
12 #       make -f Makefile.install debian-squeeze
13 #       - or -
14 #       make -f Makefile.install ubuntu-lucid
15 #       - or -
16 #       make -f Makefile.install fedora16
17 #       - or -
18 #       make -f Makefile.install centos
19 #       - or -
20 #       make -f Makefile.install rhel
21 #
22 # Notes:
23 #
24 #       This makefile has been tested much more with Debian, Ubuntu, and
25 #       Fedora than CentOS, or RHEL.
26 #
27 # ---------------------------------------------------------------------
28  
29 # Make any assumptions about the shell being used explicit
30 SHELL=/bin/bash 
31
32 LIBJS=js-1.7.0
33 LIBJS_PERL=JavaScript-SpiderMonkey-0.20
34 LIBJS_URL=http://ftp.mozilla.org/pub/mozilla.org/js/$(LIBJS).tar.gz
35 LIBJS_PERL_URL=http://mirror.datapipe.net/pub/CPAN/authors/id/T/TB/TBUSCH/$(LIBJS_PERL).tar.gz
36 # used for installing libjs lib and header files
37 JS_INSTALL_PREFIX=/usr/
38
39 LIBNET_Z3950_SIMPLESERVER=Net-Z3950-SimpleServer-1.15
40 LIBNET_Z3950_SIMPLESERVER_URL=http://ftp.indexdata.dk/pub/simpleserver/$(LIBNET_Z3950_SIMPLESERVER)
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-4.2.17
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 APT_SAFE_TOOL=aptitude -P
59 APT_BACKPORT_TOOL=aptitude -t squeeze-backports -yq
60
61 # 64 or 32 bit os?
62 LBITS=$(shell getconf LONG_BIT)
63
64 # Fedora?
65 FEDORA=$(shell uname -r | grep "\.fc[0-9][0-9]\.")
66
67 # Fedora 64-bit?
68 FEDORA_64=$(shell uname -r | grep "\.fc[0-9][0-9]\.x86_64")
69
70 #RHEL/Centos PGSQL 
71 PGSQL_HOST=http://yum.pgsqlrpms.org/reporpms/9.0
72 PGSQL_CENTOS=pgdg-centos-9.0-2.noarch.rpm
73 PGSQL_REDHAT=pgdg-redhat-9.0-2.noarch.rpm       
74
75 # Debian dependencies
76 DEBS =  \
77         apache2-prefork-dev\
78         aspell\
79         aspell-en\
80         libbusiness-creditcard-perl\
81         libbusiness-onlinepayment-authorizenet-perl\
82         libbusiness-onlinepayment-perl\
83         libdatetime-format-builder-perl\
84         libdatetime-format-iso8601-perl\
85         libdatetime-format-mail-perl\
86         libdatetime-perl\
87         libdatetime-timezone-perl\
88         libdatetime-set-perl\
89         libdbd-pg-perl\
90         libemail-send-perl\
91         libemail-simple-perl\
92         libgd-graph3d-perl\
93         liblog-log4perl-perl\
94         libmarc-record-perl\
95         libncurses5-dev\
96         libnet-server-perl\
97         libnet-ssh2-perl\
98         libnspr4-dev\
99         libole-storage-lite-perl\
100         libparent-perl \
101         libpq-dev\
102         libreadline5-dev\
103         libspreadsheet-writeexcel-perl\
104         libssh2-1-dev\
105         libtext-aspell-perl\
106         libtext-csv-perl\
107         libuniversal-require-perl\
108         libnet-ip-perl\
109         liblocale-maketext-lexicon-perl\
110         libunix-syslog-perl
111
112 # Debian Lenny and Ubuntu Intrepid bundle recent versions of yaz
113 EXTRA_DEBS = \
114         libbusiness-isbn-perl\
115         libbusiness-isbn-data-perl\
116         libmarc-charset-perl \
117         libmarc-xml-perl \
118         libnet-z3950-zoom-perl \
119         libyaz-dev \
120         yaz
121
122 EXTRA_DEBS_SQUEEZE = \
123     libuuid-tiny-perl
124
125 # Ubuntu Hardy requires libencode-perl # to get a version of Encode
126 # > 2.12 - see bug 525069.
127 EXTRA_ENCODE = \
128         libencode-perl
129
130 CENTOS = \
131         aspell \
132         aspell-devel \
133         aspell-en \
134         gd-devel \
135         libssh2-devel \
136         openssl-devel \
137         perl-parent \
138         perl-Business-CreditCard \
139         perl-Business-ISBN \
140         perl-Business-ISBN-Data \
141         perl-Business-OnlinePayment \
142         perl-Class-Data-Inheritable \
143         perl-DateTime-Format-Builder \
144         perl-DateTime-Format-Strptime \
145         perl-Ima-DBI \
146         perl-DBD-Pg \
147         perl-GD-Graph3d \
148         perl-IO-stringy \
149         perl-Spreadsheet-WriteExcel \
150         perl-Text-Aspell \
151         perl-Text-CSV
152
153 CENTOS_PERL = \
154         Encode \
155         DBIx::ContextualFetch \
156         Getopt::Long \
157         Net::SSH2 \
158         Net::XMPP \
159         Net::Z3950::ZOOM
160
161 FEDORA_RPMS = \
162         aspell \
163         aspell-en \
164         libdbi \
165         libdbi-dbd-pgsql \
166         libdbi-devel \
167         libssh2-devel \
168         libyaz \
169         libyaz-devel \
170         mod_ssl \
171         ncurses-devel \
172         ncurses-libs \
173         perl-parent \
174         perl-Business-CreditCard \
175         perl-Business-ISBN \
176         perl-Business-ISBN-Data \
177         perl-DBD-Pg \
178         perl-Email-Send \
179         perl-Email-Simple \
180         perl-GDGraph3d \
181         perl-JSON-XS \
182         perl-Net-IP \
183         perl-Net-SSH2 \
184         perl-OLE-Storage_Lite \
185         perl-Spreadsheet-WriteExcel \
186         perl-Text-Aspell \
187         perl-Text-CSV \
188         perl-Text-CSV_XS \
189         perl-XML-Writer \
190         postgresql-devel \
191         readline-devel \
192         tcp_wrappers-devel \
193         wget \
194         yaz
195
196 # Note: B:O:AuthorizeNet 3.21 fails with https://rt.cpan.org/Public/Bug/Display.html?id=55172
197 # Should be fixed in 3.22
198 # MARC::Record 2.0.1 is required but only 2.0.0 is packaged
199 FEDORA_CPAN = \
200         Business::OnlinePayment \
201         Business::OnlinePayment::AuthorizeNet \
202         MARC::Record \
203         UUID::Tiny
204
205 PGSQL_90_RPMS = \
206         postgresql90 \
207         postgresql90-contrib \
208         postgresql90-devel \
209         postgresql90-libs \
210         postgresql90-plperl \
211         postgresql90-server
212
213 PGSQL_FEDORA_RPMS = \
214         postgresql \
215         postgresql-contrib \
216         postgresql-libs \
217         postgresql-plperl \
218         postgresql-server
219
220 PGSQL_CLIENT_DEBS_90 = \
221         libpq5 \
222         libpq-dev \
223         postgresql-client-9.0
224
225 PGSQL_SERVER_DEBS_90 = \
226         postgresql-9.0 \
227         postgresql-contrib-9.0 \
228         postgresql-plperl-9.0 \
229         postgresql-server-dev-9.0
230
231 PGSQL_SERVER_DEBS_91 = \
232         postgresql-9.1 \
233         postgresql-contrib-9.1 \
234         postgresql-plperl-9.1 \
235         postgresql-server-dev-9.1
236
237 DEB_APACHE_MODS = \
238     expires\
239     include\
240     proxy\
241     proxy_http\
242     rewrite
243
244 DEB_APACHE_DISMODS = \
245     deflate
246
247 # Chronically unpackaged CPAN modules
248 CPAN_MODULES = \
249         Business::EDI \
250         Library::CallNumber::LC \
251         Net::Z3950::Simple2ZOOM \
252         Template::Plugin::POSIX \
253         SRU
254
255 # More chronically unpackaged CPAN modules (available in Squeeze though)
256 CPAN_MODULES_MORE = \
257     Business::CreditCard::Object \
258     MARC::Record \
259     Net::SSH2 \
260     UUID::Tiny
261
262 # Are we sure most distros don't come with an acceptable version of Safe.pm?
263 CPAN_MODULES_SAFE = \
264         Safe
265
266 # Recent Debian/Ubuntus have libmarc-charset-perl, libmarc-xml-perl, libnet-z3950-zoom-perl
267 CPAN_MODULES_MARC = \
268         Business::ISBN \
269         Business::ISBN::Data \
270         MARC::Charset \
271         MARC::File::XML \
272         Net::Z3950::ZOOM
273
274 CPAN_MODULES_MARC_RECORD = \
275         MARC::Record
276
277 CPAN_MODULES_FORCE = \
278         Class::DBI::Frozen::301
279
280 # Lucid needs this because the XML::RPC that comes by default is broken with Evergreen
281 LUCID_CPAN = \
282         XML::RPC
283
284 # ----------------------------------------------------------------------------
285
286 all: 
287         @echo "please specify an OS" && exit 0
288
289 # these should be the same for any distro
290 install: install_cpan install_js_sm install_cpan_force
291
292 centos: install_centos_pgsql centos_like
293 rhel: install_redhat_pgsql centos_like
294 centos_like: install_centos_rpms install_yaz install_cpan_marc install install_centos_perl create_ld_local install_cpan_safe install_libdbi
295
296 fedora16: install_fedora_rpms install_cpan_fedora install_cpan_marc install
297
298 debian-squeeze: squeeze generic_debian
299 squeeze: install_pgsql_client_debs_90  install_extra_debs_squeeze
300 generic_debian: install_debs install_yaz test_for_libdbi_pkg install debian_sys_config install_libdbi
301
302 ubuntu-lucid: lucid generic_ubuntu
303 lucid: install_pgsql_client_debs_90 install_extra_debs install_cpan_marc_record install_yaz install_cpan_lucid
304 generic_ubuntu: install_debs install_yaz test_for_libdbi_pkg install debian_sys_config install_cpan_more install_cpan_safe install_libdbi
305
306 # - COMMON TARGETS ---------------------------------------------------------
307
308 # Install the CPAN modules
309 install_cpan: install_net_z3950_simpleserver
310         for m in $(CPAN_MODULES); do perl -MCPAN -e "install \"$$m\";"; done
311
312 install_cpan_more: 
313         for m in $(CPAN_MODULES_MORE); do perl -MCPAN -e "install \"$$m\";"; done
314
315 # Install the CPAN modules for MARC functionality
316 install_cpan_marc: install_cpan_marc_record
317         for m in $(CPAN_MODULES_MARC); do perl -MCPAN -e "install \"$$m\";"; done
318
319 install_cpan_marc_record:
320         for m in $(CPAN_MODULES_MARC_RECORD); do perl -MCPAN -e "install \"$$m\";"; done
321
322 install_cpan_force:
323         for m in $(CPAN_MODULES_FORCE); do \
324                 echo "force install $$m" | perl -MCPAN -e shell ;\
325         done
326
327 # Install the Safe Perl module
328 # Is this really unpackaged everywhere except for Fedora?
329 install_cpan_safe: 
330         for m in $(CPAN_MODULES_SAFE); do perl -MCPAN -e "install \"$$m\";"; done
331
332 # Install the CPAN modules for Fedora
333 install_cpan_fedora: 
334         for m in $(FEDORA_CPAN); do \
335                 echo "force install $$m" | perl -MCPAN -e shell;\
336         done
337
338 # Install the CPAN modules needed for Lucid
339 install_cpan_lucid:
340         for m in $(LUCID_CPAN); do perl -MCPAN -e "install \"$$m\";"; done
341
342 # Install a known working version of YAZ
343 install_yaz:    
344         if [ ! -d $(YAZ) ]; then wget $(YAZ_HOST)/$(YAZ).tar.gz; fi;
345         tar xzf $(YAZ).tar.gz
346         cd $(YAZ) && ./configure && make && make install && ldconfig
347
348 # Install the custom spidermonkey libs and JavaScript-SpiderMonkey Perl modules
349 install_js_sm: install_libjs install_spidermonkey
350
351 install_libjs: 
352         if [ ! -f $(LIBJS).tar.gz ]; then wget $(LIBJS_URL); fi;
353         tar -zxf $(LIBJS).tar.gz
354         cd js/src/ && JS_DIST=/usr make -f Makefile.ref
355         mkdir -p $(JS_INSTALL_PREFIX)/include/js/
356         cp js/src/*.h $(JS_INSTALL_PREFIX)/include/js/
357         cp js/src/*.tbl $(JS_INSTALL_PREFIX)/include/js/
358         if [ ! -z $(FEDORA_64) ]; then \
359                 cp js/src/Linux_All_DBG.OBJ/*.so $(JS_INSTALL_PREFIX)/lib64/ && \
360                 cp js/src/Linux_All_DBG.OBJ/*.a $(JS_INSTALL_PREFIX)/lib64/; \
361         else \
362                 cp js/src/Linux_All_DBG.OBJ/*.so $(JS_INSTALL_PREFIX)/lib/ && \
363                 cp js/src/Linux_All_DBG.OBJ/*.a $(JS_INSTALL_PREFIX)/lib/; \
364         fi;
365         ldconfig
366
367 install_spidermonkey:
368         if [ ! -f $(LIBJS_PERL).tar.gz ]; then wget $(LIBJS_PERL_URL); fi;
369         tar -zxf $(LIBJS_PERL).tar.gz
370         if [ ! -z $(FEDORA_64) ]; then \
371                 sed -i -e 's/"\/usr\/lib"/"\/usr\/lib64"/' $(LIBJS_PERL)/Makefile.PL ; \
372         fi;
373         if [ ! -z $(FEDORA) ]; then \
374                 sed -i -e 's/js32.dll/libjs.so/' $(LIBJS_PERL)/Makefile.PL ; \
375         fi;
376         cd $(LIBJS_PERL) && perl Makefile.PL -E4X && make && make test && make install
377
378 install_net_z3950_simpleserver:
379         if [ ! -f $(LIBNET_Z3950_SIMPLESERVER).tar.gz ]; then wget $(LIBNET_Z3950_SIMPLESERVER_URL).tar.gz; fi;
380         tar -zxf $(LIBNET_Z3950_SIMPLESERVER).tar.gz
381         cd $(LIBNET_Z3950_SIMPLESERVER) && perl Makefile.PL && make && make test && make install
382
383 # On Ubuntu and possibly Debian, the libdbi0 package prevents the 
384 # compiled-from-source version from being used and breaks the install.
385 # This package might get installed depending on the install-time choices
386 # for the distro. Test for its existence; if it's there, throw an error
387 # message and exit.
388 test_for_libdbi_pkg:
389                 @if [ "$$(apt-cache policy libdbi0 | grep Installed | grep none | wc -l)" -eq 0 ]; then \
390                                 echo "*** Detected locally installed libdbi0 package; you must remove this"; \
391                                 echo "*** with a command like 'aptitude remove libdbi0' before proceeding"; \
392                                 echo "*** to successfully install Evergreen."; \
393                                 echo; \
394                                 echo "*** Note: this may break other applications on your system."; \
395                                 exit 0; \
396                 fi;
397
398 # Install libdbi and the postgres drivers
399 install_libdbi:
400         if [ ! -d $(LIBDBI) ]; then wget $(LIBDBI_HOST)/$(LIBDBI).tar.gz; fi;
401         if [ ! -d $(LIBDBI_DRIVERS) ]; then wget $(LIBDBI_HOST)/$(LIBDBI_DRIVERS).tar.gz; fi;
402         tar -zxf $(LIBDBI).tar.gz
403         tar -zxf $(LIBDBI_DRIVERS).tar.gz
404         cd $(LIBDBI) && ./configure --disable-docs && make all install
405         cd $(LIBDBI_DRIVERS) && ./configure  \
406                 --disable-docs --with-pgsql --enable-libdbi && make all install  
407
408 clean:
409         make -C $(LIBDBI) clean
410         make -C $(LIBDBI_DRIVERS) clean
411         make -C $(LIBJS_PERL) clean
412         make -f Makefile.ref -C js/src/ clean
413
414
415 # ------------------------------------------------------------------
416 # - DEBIAN ---------------------------------------------------------
417
418 debian_sys_config: 
419         # link the apache modules in
420         for m in $(DEB_APACHE_MODS); do a2enmod $$m; done;
421         # keep the bad apache modules away
422         for m in $(DEB_APACHE_DISMODS); do a2dismod $$m; done;
423         # refresh the dynamic library cache
424         ldconfig
425
426 # Install the debian-specific dependencies
427 install_debs:
428         $(APT_TOOL) install $(DEBS)
429
430 install_pgsql_client_debs_90:
431         @if [ `$(APT_TOOL) versions libpq-dev | grep ^i|sed 's/^i[ \t]*//'|cut -d. -f1` -eq 8 ]; \
432                 then \
433                 echo -e "libpq5 / libpq-dev are installed as part of OpenSRF (a dependency" \
434                 "of apache2-prefork-dev), but these are the 8.4 versions and they" \
435                 "conflict with the 9.0 versions - so remove them, install the pinned" \
436                 "backports of 9.0, then reinstall the apache2-prefork-dev package.\n\n" \
437                 "**WARNING**: Saying 'Yes' to this step will _remove_ any PostgreSQL" \
438                 "databases that might currently exist on this machine." && \
439                 $(APT_SAFE_TOOL) remove libpq5 libpq-dev ; \
440         fi
441         $(APT_BACKPORT_TOOL) install $(PGSQL_CLIENT_DEBS_90)
442         $(APT_TOOL) install apache2-prefork-dev
443
444 install_pgsql_server_debs_90:
445         $(APT_BACKPORT_TOOL) install $(PGSQL_SERVER_DEBS_90)
446
447 install_pgsql_server_debs_91:
448         $(APT_BACKPORT_TOOL) install $(PGSQL_SERVER_DEBS_91)
449
450 # Install the debian-specific dependencies for more modern distros
451 install_extra_debs_squeeze: install_extra_debs
452         $(APT_TOOL) install $(EXTRA_DEBS_SQUEEZE)
453
454 install_extra_debs:
455         $(APT_TOOL) install $(EXTRA_DEBS)
456
457 # Install specific modules required by Ubuntu Hardy - see bug 525069
458 install_extra_encode:
459         $(APT_TOOL) install $(EXTRA_ENCODE)
460
461 # ------------------------------------------------------------------
462
463 # FEDORA
464 install_fedora_rpms:
465         yum -y update
466         yum -y install $(FEDORA_RPMS)
467
468 install_fedora_pgsql_server:
469         yum -y install $(PGSQL_FEDORA_RPMS)
470
471 # CENTOS
472 install_centos_rpms:
473         yum -y install $(CENTOS)
474         yum -y update
475         if [ $(LBITS) -eq 64 ]; then \
476                 ln -sf /usr/lib64/libpq.* /usr/lib/ && \
477                 ln -sf /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so /usr/lib/ && \
478                 ldconfig ; \
479         fi;
480         if [ $(LBITS) -eq 32 ]; then \
481                 ln -sf /usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/libperl.so /usr/lib && \
482                 ldconfig ; \
483         fi;
484
485 install_centos_pgsql:
486         if [ $(LBITS) -eq 64 ]; then yum remove -y postgresql-libs-8.1*i386 apr-util-devel-*i386 ; fi;
487         wget $(PGSQL_HOST)/$(PGSQL_CENTOS)
488         rpm -Uvh --force ./$(PGSQL_CENTOS)
489         yum update -y
490         yum -y install $(PGSQL_90_RPMS)
491
492 install_redhat_pgsql:
493         if [ $(LBITS) -eq 64 ]; then yum remove -y postgresql-libs-8.1*i386 apr-util-devel-*i386 ; fi;
494         wget $(PGSQL_HOST)/$(PGSQL_REDHAT)
495         rpm -Uvh --force ./$(PGSQL_REDHAT)
496         yum update -y
497         yum -y install $(PGSQL_90_RPMS)
498
499 install_centos_perl:
500         for m in $(CENTOS_PERL); do perl -MCPAN -e "install \"$$m\";"; done
501         echo "force install Business::OnlinePayment::AuthorizeNet" | perl -MCPAN -e shell
502         echo "force install Scalar::Util" | perl -MCPAN -e shell        
503
504 # We need to add /usr/local/lib to the ldconfig list of directories on CentOS,
505 # if it is not already there
506 create_ld_local:
507         if [ "$$(ldconfig -v 2> /dev/null | grep '^/usr/local/lib' | wc -l)" -eq 0 ]; then \
508                 echo '/usr/local/lib' >> /etc/ld.so.conf.d/local.conf; \
509                 ldconfig; \
510         fi;
511
512 # vim:noet:sw=4:ts=4: