Fix for if instead of while in 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     PREREQ_PM => {
113 'Biblio::EndnoteStyle' => 0.05,
114 'CGI' => 3.15,
115 'CGI::Carp' => 1.29,
116 'CGI::Session' => '4.10',
117 'Class::Factory::Util' => 1.7,
118 'Class::Accessor' => 0.30,
119 'DBD::mysql' => 3.0008,
120 'DBI' => 1.53,
121 'Data::Dumper' => 2.121_08,
122 'Date::Calc' => 5.4,
123 'Date::Manip' => 5.44,
124 'Digest::MD5' => 2.36,
125 'File::Temp' => 0.16,
126 'GD::Barcode::UPCE' => 1.1,
127 'Getopt::Long' => 2.35,
128 'Getopt::Std' => 1.05,
129 'HTML::Template::Pro' => 0.65,
130 'HTTP::Cookies' => 1.39,
131 'HTTP::Request::Common' => 1.26,
132 'LWP::Simple' => 1.41,
133 'LWP::UserAgent' => 2.033,
134 'Lingua::Stem' => 0.82,
135 'List::Util' => 1.18,
136 'Locale::Language' => 2.07,
137 'MARC::Charset' => 0.98,
138 'MARC::Crosswalk::DublinCore' => 0.03,
139 'MARC::File::XML' => 0.88,
140 'MARC::Record' => 2.00,
141 'MARC::Crosswalk::DublinCore' => 0.02,
142 'MIME::Base64' => 3.07,
143 'MIME::QuotedPrint' => 3.07,
144 'Mail::Sendmail' => 0.79,
145 'Net::Z3950::ZOOM' => 1.16,
146 'PDF::API2' => 2.000,
147 'PDF::API2::Page' => 2.000,
148 'PDF::API2::Util' => 2.000,
149 'PDF::Reuse' => 0.33,
150 'PDF::Reuse::Barcode' => 0.05,
151 'POSIX' => 1.09,
152 'Schedule::At' => 1.06,
153 'Term::ANSIColor' => 1.10,
154 'Test' => 1.25,
155 'Test::Harness' => 2.56,
156 'Test::More' => 0.62,
157 'Text::CSV' => 0.01,
158 'Text::CSV_XS' => 0.32,
159 'Text::Wrap' => 2005.082401,
160 'Time::HiRes' => 1.86,
161 'Time::localtime' => 1.02,
162 'Unicode::Normalize' => 0.32,
163 'XML::Dumper' => 0.81,
164 'XML::LibXML' => 1.59,
165 'XML::LibXSLT' => 1.63,
166 'XML::SAX::ParserFactory' => 1.01,
167 'XML::Simple' => 2.14,
168 'XML::RSS' => 1.31,
169         },
170
171         # File tree mapping
172         PM => map_tree(),
173
174         # disable tests
175         'test' => {TESTS => 't/dummy.t'},
176
177 #   CONFIGURE => sub {
178 #     # Ask for options with prompt($question,$default) calls here?
179 #     return { macro => { 'export TEST' => '755' } }
180 #     },
181
182    PL_FILES => { # generator => target(s)
183       'rewrite-config.PL' => [
184          '$(INSTALL_BASE)/share/koha/etc/koha-conf.xml',
185          '$(INSTALL_BASE)/share/koha/etc/koha-httpd.conf',
186          '$(INSTALL_BASE)/share/koha/etc/zebradb/etc/passwd',
187          '$(INSTALL_BASE)/share/koha/etc/zebradb/zebra-biblios.cfg',
188          '$(INSTALL_BASE)/share/koha/etc/zebradb/zebra-authorities.cfg'
189          ]
190    }
191 #     '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'],
192 #     'misc/koha.conf.PL' => '$(INST_LIBDIR)/../etc/koha.conf',
193 #     'misc/apache-koha.conf.PL' => '$(INST_LIBDIR)/../etc/apache-koha.conf',
194 #     'misc/koha.sql.PL' => '$(INST_LIBDIR)/intranet/scripts/koha.sql',
195 #     'z3950/z3950-daemon-options.PL' => '$(INST_LIBDIR)/intranet/scripts/z3950daemon/z3950-daemon-options',
196 #     # fake target to check permissions
197 #     'misc/chmod.PL' => '$(INST_LIBDIR)/fake-target'
198 #     }
199    # need to set ownerships
200    # need to load koha.sql
201    # need to link koha-httpd.conf
202    # need to start z3950-daemon
203 );
204
205 =head1 FUNCTIONS
206
207 =head2 map_tree
208
209 This function lists all files and where to install each one.
210 It returns a hash reference suitable for the PM variable above.
211
212 =cut
213
214 sub map_tree {
215         my %result => ();
216
217 =pod
218
219 C4/*.pm is copied to perl's lib namespace.
220
221 =cut
222         foreach my $src (glob("C4/*.pm")) {
223                 $result{$src} = '$(INST_LIBDIR)/'.$src;
224         }
225
226 =pod
227
228 CGIs are copied to $(INSTALL_BASE)/lib/cgi-bin/koha/
229 and other scripts to koha/
230
231 =cut
232         foreach my $src ("mainpage.pl","help.pl","kohaversion.pl",glob("*/*.pl"),glob("installer/*"),glob("installer/*/*/*/*"),glob("installer/*/*/*/*/*"),glob("*/*/*.pl"),glob("*/*/*/*.pl"),glob("installer/*/*/*.sql"))
233 {
234           if (-f $src) {
235                 if ($src =~ /(misc|updater|rss)\//) {
236                         $result{$src} = '$(INST_LIBDIR)/koha/'.$src;
237                 } else {
238                         $result{$src} = '$(INSTALL_BASE)/lib/cgi-bin/koha/'.$src;
239                 }
240           }
241         }
242
243 =pod
244
245 Templates are copied to koha/templates,
246
247 =cut
248         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/*/*/*/*/*")) {
249
250 =pod
251
252 excluding non-files and whitespace in filenames.
253
254 =cut
255                 if ((-f $src) && ($src !~ /(\s)/)) {
256                         $result{$src} = '$(INST_LIBDIR)/koha/templates/'.$src;
257                 }
258         }
259         
260 =pod
261
262 etc files are copied to /usr/share/koha/etc/
263
264 =cut
265         # Misc etc to koha/etc
266         foreach my $src (glob("etc/zebradb/*/*/*"),glob("etc/zebradb/*/*"),glob("etc/zebradb/*"),glob("etc/*")) {
267                 if (-f $src) {
268                         $result{$src} = '$(INSTALL_BASE)/share/koha/'.$src;
269                 }
270         }
271         
272         # set up zebra with the appropriate language and marc config
273     $result{"etc/zebradb/lang_defs/sort-string-$lang_value.chr"} = '$(INSTALL_BASE)/share/koha/etc/zebradb/etc/sort-string-utf.chr';
274     $result{"etc/zebradb/marc_defs/biblios-$marc_value.abs"} = '$(INSTALL_BASE)/share/koha/etc/zebradb/biblios/etc/record.abs';
275         $result{"etc/zebradb/marc_defs/authorities-$marc_value.abs"} = '$(INSTALL_BASE)/share/koha/etc/zebradb/authorities/etc/record.abs';
276         return \%result;
277 }
278
279 __END__
280
281
282 =head1 SEE ALSO
283
284 ExtUtils::MakeMaker(3)
285
286 =head1 AUTHOR
287
288 MJ Ray mjr at phonecoop.coop
289
290 =cut
291