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