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