Continuing work on the installer
[koha.git] / Makefile.PL
1 # Copyright 2007 MJ Ray
2 #
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA  02111-1307 USA
17 #
18 # Current maintainer MJR http://mjr.towers.org.uk/
19 # See http://www.koha.org/wiki/?page=KohaInstaller
20 #
21 # 2007-11-05 Corrected CGI copy to include entire 'installer' subdir structure. -fbcit
22 use ExtUtils::MakeMaker;
23 use POSIX;
24
25 die "perl 5.6.1 or later required" unless ($] >= 5.006001);
26
27 =head1 NAME
28
29 Makefile.PL - Koha packager and installer
30
31 =head1 SYNOPSIS
32
33 =head2 BASIC INSTALLATION
34
35         perl Makefile.PL 
36         or perl Makefile.PL INSTALL_BASE=/path/to/your/home/dir MARCFLAVOUR=marc21 LANGUAGE=en
37         make
38         sudo make install
39
40 =head2 PACKAGING RELEASE TARBALLS
41
42         make manifest tardist
43         make manifest zipdist
44
45 =head2 CLEANING UP
46
47         make clean
48
49 =head1 DESCRIPTION
50
51 This is a packager and installer that uses
52 ExtUtils::MakeMaker, which is fairly common
53 on perl systems.
54 As well as building tar or zip files
55 and installing with the above commands,
56 it allows us to check pre-requisites
57 and generate configuration files.
58
59 =head1 VARIABLES
60
61 =head2 NAME, VERSION_FROM, ABSTRACT, AUTHOR
62
63 Basic metadata about this software.
64
65 =head2 NO_META
66
67 Suppress generation of META.yml file.
68
69 =head2 PREREQ_PM
70
71 Hash of perl modules and versions required.
72
73 =head2 PM
74
75 Hash of file mappings
76
77 =head2 CONFIGURE
78
79 Maybe use prompt() here in future to get configuration values 
80 interactively at installation time.
81
82 =head2 PL_FILES
83
84 This is a hash of PL scripts to run after installation and
85 the files to ask them to generate.
86 Maybe use the values from CONFIGURE
87 to generate initial configuration files in future.
88
89 =cut
90
91 my $marc_value;
92 my $lang_value;
93
94
95 while ($marc_value ne 'marc21' && $marc_value ne 'unimarc'){
96    my $message= "Chose your flavour of MARC, unimarc or marc21 [marc21]";
97    $marc_value=prompt($message) || 'marc21';
98 }
99 while ($lang_value ne 'en' && $lang_value ne 'fr'){
100    my $message= "Choose your language, en or fr [en]";
101    $lang_value=prompt($message) || 'en';
102 }
103
104 WriteMakefile(
105
106     NAME => 'koha',
107     #VERSION => strftime('2.9.%Y%m%d%H',gmtime),
108     VERSION_FROM => 'kohaversion.pl',
109     ABSTRACT => 'Award-winning integrated library system (ILS) and Web OPAC',
110     AUTHOR => 'Koha Developers <koha-devel@nongnu.org>',
111     NO_META => 1,
112         INSTALLSITEBIN => '$(INSTALL_BASE)/lib',
113     PREREQ_PM => {
114 'Biblio::EndnoteStyle' => 0.05,
115 'CGI' => 3.15,
116 'CGI::Carp' => 1.29,
117 'CGI::Session' => '4.10',
118 'Class::Factory::Util' => 1.7,
119 'Class::Accessor' => 0.30,
120 'DBD::mysql' => 3.0008,
121 'DBI' => 1.53,
122 'Data::Dumper' => 2.121_08,
123 'Date::Calc' => 5.4,
124 'Date::Manip' => 5.44,
125 'Digest::MD5' => 2.36,
126 'File::Temp' => 0.16,
127 'GD::Barcode::UPCE' => 1.1,
128 'Getopt::Long' => 2.35,
129 'Getopt::Std' => 1.05,
130 'HTML::Template::Pro' => 0.65,
131 'HTTP::Cookies' => 1.39,
132 'HTTP::Request::Common' => 1.26,
133 'LWP::Simple' => 1.41,
134 'LWP::UserAgent' => 2.033,
135 'Lingua::Stem' => 0.82,
136 'List::Util' => 1.18,
137 'Locale::Language' => 2.07,
138 'MARC::Charset' => 0.98,
139 'MARC::Crosswalk::DublinCore' => 0.03,
140 'MARC::File::XML' => 0.88,
141 'MARC::Record' => 2.00,
142 'MARC::Crosswalk::DublinCore' => 0.02,
143 'MIME::Base64' => 3.07,
144 'MIME::QuotedPrint' => 3.07,
145 'Mail::Sendmail' => 0.79,
146 'Net::Z3950::ZOOM' => 1.16,
147 'PDF::API2' => 2.000,
148 'PDF::API2::Page' => 2.000,
149 'PDF::API2::Util' => 2.000,
150 'PDF::Reuse' => 0.33,
151 'PDF::Reuse::Barcode' => 0.05,
152 'POSIX' => 1.09,
153 'Schedule::At' => 1.06,
154 'Term::ANSIColor' => 1.10,
155 'Test' => 1.25,
156 'Test::Harness' => 2.56,
157 'Test::More' => 0.62,
158 'Text::CSV' => 0.01,
159 'Text::CSV_XS' => 0.32,
160 'Text::Wrap' => 2005.082401,
161 'Time::HiRes' => 1.86,
162 'Time::localtime' => 1.02,
163 'Unicode::Normalize' => 0.32,
164 'XML::Dumper' => 0.81,
165 'XML::LibXML' => 1.59,
166 'XML::LibXSLT' => 1.63,
167 'XML::SAX::ParserFactory' => 1.01,
168 'XML::Simple' => 2.14,
169 'XML::RSS' => 1.31,
170         },
171
172         # File tree mapping
173         PM => map_tree(),
174
175         # disable tests
176         'test' => {TESTS => 't/dummy.t'},
177
178 #   CONFIGURE => sub {
179 #     # Ask for options with prompt($question,$default) calls here?
180 #     return { macro => { 'export TEST' => '755' } }
181 #     },
182
183    PL_FILES => { # generator => target(s)
184       'rewrite-config.PL' => [
185          '$(INST_LIBDIR)/etc/koha-conf.xml',
186          '$(INST_LIBDIR)/etc/koha-httpd.conf',
187          '$(INST_LIBDIR)/etc/zebradb/etc/passwd',
188          '$(INST_LIBDIR)/etc/zebradb/zebra-biblios.cfg',
189          '$(INST_LIBDIR)/etc/zebradb/zebra-authorities.cfg'
190          ]
191    }
192 #     'opac/getfromintranet.PL' => ['$(INST_LIBDIR)/opac/cgi-bin/detail.pl','$(INST_LIBDIR)/opac/cgi-bin/moredetail.pl','$(INST_LIBDIR)/opac/cgi-bin/search.pl','$(INST_LIBDIR)/opac/cgi-bin/subjectsearch.pl','$(INST_LIBDIR)/opac/cgi-bin/logout.pl'],
193 #     'misc/koha.conf.PL' => '$(INST_LIBDIR)/../etc/koha.conf',
194 #     'misc/apache-koha.conf.PL' => '$(INST_LIBDIR)/../etc/apache-koha.conf',
195 #     'misc/koha.sql.PL' => '$(INST_LIBDIR)/intranet/scripts/koha.sql',
196 #     'z3950/z3950-daemon-options.PL' => '$(INST_LIBDIR)/intranet/scripts/z3950daemon/z3950-daemon-options',
197 #     # fake target to check permissions
198 #     'misc/chmod.PL' => '$(INST_LIBDIR)/fake-target'
199 #     }
200    
201
202    # need to set ownerships
203    # need to load koha.sql
204    # need to link koha-httpd.conf
205    # need to start z3950-daemon
206 );
207
208 =head1 FUNCTIONS
209
210 =head2 map_tree
211
212 This function lists all files and where to install each one.
213 It returns a hash reference suitable for the PM variable above.
214
215 =cut
216
217 sub map_tree {
218         my %result => ();
219
220 =pod
221
222 C4/*.pm is copied to perl's lib namespace.
223
224 =cut
225         foreach my $src (glob("C4/*.pm")) {
226                 $result{$src} = '$(INST_LIBDIR)/'.$src;
227         }
228
229 =pod
230
231 CGIs are copied to $(INSTALL_BASE)/lib/cgi-bin/koha/
232 and other scripts to koha/
233
234 =cut
235         foreach my $src ("mainpage.pl","help.pl","kohaversion.pl",glob("*/*.pl"),glob("installer/*"),glob("installer/*/*/*/*"),glob("installer/*/*/*/*/*"),glob("*/*/*.pl"),glob("*/*/*/*.pl"),glob("installer/*/*/*.sql"))
236 {
237           if (-f $src) {
238                 if ($src =~ /(misc|updater|rss)\//) {
239                         $result{$src} = '$(INST_BIN)/koha/'.$src;
240                 } else {
241                         $result{$src} = '$(INST_BIN)/cgi-bin/koha/'.$src;
242                 }
243           }
244         }
245
246 =pod
247
248 Templates are copied to koha/templates,
249
250 =cut
251         foreach my $src (glob("koha-tmpl/*"),glob("koha-tmpl/intranet-tmpl/*/*/*"),glob("koha-tmpl/intranet-tmpl/*/*/*/*"),glob("koha-tmpl/intranet-tmpl/*/*/*/*/*"),glob("koha-tmpl/opac-tmpl/*/*/*"),glob("koha-tmpl/opac-tmpl/*/*/*/*"),glob("koha-tmpl/opac-tmpl/*/*/*/*/*")) {
252
253 =pod
254
255 excluding non-files and whitespace in filenames.
256
257 =cut
258                 if ((-f $src) && ($src !~ /(\s)/)) {
259                         $result{$src} = '$(INST_LIBDIR)/koha/templates/'.$src;
260                 }
261         }
262         
263 =pod
264
265 etc files are copied to /usr/share/koha/etc/
266
267 =cut
268         # Misc etc to koha/etc
269         foreach my $src (glob("etc/zebradb/*/*/*"),glob("etc/zebradb/*/*"),glob("etc/zebradb/*"),glob("etc/*")) {
270                 if (-f $src) {
271                         $result{$src} = '$(INST_LIBDIR)/'.$src;
272                 }
273         }
274         
275         # set up zebra with the appropriate language and marc config
276     $result{"etc/zebradb/lang_defs/sort-string-$lang_value.chr"} = '$(INST_LIBDIR)/etc/zebradb/etc/sort-string-utf.chr';
277     $result{"etc/zebradb/marc_defs/biblios-$marc_value.abs"} = '$(INST_LIBDIR)/etc/zebradb/biblios/etc/record.abs';
278         $result{"etc/zebradb/marc_defs/authorities-$marc_value.abs"} = '$(INST_LIBDIR)/etc/zebradb/authorities/etc/record.abs';
279         return \%result;
280 }
281
282 __END__
283
284
285 =head1 SEE ALSO
286
287 ExtUtils::MakeMaker(3)
288
289 =head1 AUTHOR
290
291 MJ Ray mjr at phonecoop.coop
292
293 =cut
294