Move many files to more FHS-like paths
[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 use ExtUtils::MakeMaker;
22 use POSIX;
23
24 die "perl 5.6.1 or later required" unless ($] >= 5.006001);
25
26 =head1 NAME
27
28 Makefile.PL - Koha packager and installer
29
30 =head1 SYNOPSIS
31
32 =head2 BASIC INSTALLATION
33
34         perl Makefile.PL
35         make
36         sudo make install
37
38 =head2 PACKAGING RELEASE TARBALLS
39
40         make manifest tardist
41         make manifest zipdist
42
43 =head2 CLEANING UP
44
45         make clean
46
47 =head1 DESCRIPTION
48
49 This is a packager and installer that uses
50 ExtUtils::MakeMaker, which is fairly common
51 on perl systems.
52 As well as building tar or zip files
53 and installing with the above commands,
54 it allows us to check pre-requisites
55 and generate configuration files.
56
57 =head1 VARIABLES
58
59 =head2 NAME, VERSION_FROM, ABSTRACT, AUTHOR
60
61 Basic metadata about this software.
62
63 =head2 NO_META
64
65 Suppress generation of META.yml file.
66
67 =head2 PREREQ_PM
68
69 Hash of perl modules and versions required.
70
71 =head2 PM
72
73 Hash of file mappings
74
75 =head2 CONFIGURE
76
77 Maybe use prompt() here in future to get configuration values 
78 interactively at installation time.
79
80 =head2 PL_FILES
81
82 This is a hash of PL scripts to run after installation and
83 the files to ask them to generate.
84 Maybe use the values from CONFIGURE
85 to generate initial configuration files in future.
86
87 =cut
88
89 WriteMakefile(
90
91     NAME => 'koha',
92     #VERSION => strftime('2.9.%Y%m%d%H',gmtime),
93     VERSION_FROM => 'C4/Context.pm',
94     ABSTRACT => 'Award-winning integrated library system (ILS) and Web OPAC',
95     AUTHOR => 'Koha Developers <koha-devel@nongnu.org>',
96     NO_META => 1,
97     PREREQ_PM => {
98 'CGI' => 3.15,
99 'CGI::Carp' => 1.29,
100 'CGI::Session' => '4.10',
101 'Class::Accessor' => 0.30,
102 'DBD::mysql' => 3.0008,
103 'DBI' => 1.53,
104 'Data::Dumper' => 2.121_08,
105 'Data::Random' => 0.05,
106 'Date::Calc' => 5.4,
107 'Date::Manip' => 5.44,
108 'Digest::MD5' => 2.36,
109 'Event' => 1.06,
110 'File::Temp' => 0.16,
111 'GD::Barcode::UPCE' => 1.1,
112 'Getopt::Long' => 2.35,
113 'Getopt::Std' => 1.05,
114 'HTML::Template' => 2.8,
115 'HTML::Template::Pro' => 0.65,
116 'HTML::Tree' => 3.1901,
117 'HTTP::Cookies' => 1.39,
118 'HTTP::Request::Common' => 1.26,
119 'LWP::Simple' => 1.41,
120 'LWP::UserAgent' => 2.033,
121 'Lingua::Stem' => 0.82,
122 'List::Util' => 1.18,
123 'Locale::Language' => 2.07,
124 'MARC::Charset' => 0.95,
125 'MARC::File::XML' => 0.86,
126 'MARC::Record' => 1.38,
127 'MIME::Base64' => 3.07,
128 'MIME::QuotedPrint' => 3.07,
129 'Mail::Sendmail' => 0.79,
130 'Net::Z3950' => 0,
131 'Net::Z3950::ZOOM' => 1.16,
132 'PDF::API2' => 2.000,
133 'PDF::API2::Page' => 2.000,
134 'PDF::API2::Util' => 2.000,
135 'PDF::Reuse' => 0.33,
136 'PDF::Reuse::Barcode' => 0.05,
137 'POSIX' => 1.09,
138 'Term::ANSIColor' => 1.10,
139 'Test' => 1.25,
140 'Test::Harness' => 2.56,
141 'Test::More' => 0.62,
142 'Text::Wrap' => 2005.082401,
143 'Time::HiRes' => 1.86,
144 'Time::localtime' => 1.02,
145 'Unicode::Normalize' => 0.32,
146 'XML::LibXML' => 1.59,
147 'XML::SAX::ParserFactory' => 1.01,
148 'XML::Simple' => 2.14,
149 'XML::RSS' => 1.31,
150 'ZOOM' => 0,
151         },
152
153         # File tree mapping
154         PM => map_tree(),
155
156         # disable tests
157         'test' => {TESTS => 't/dummy.t'},
158
159 #   CONFIGURE => sub {
160 #     # Ask for options with prompt($question,$default) calls here?
161 #     return { macro => { 'export TEST' => '755' } }
162 #     },
163
164    PL_FILES => { # generator => target(s)
165       'rewrite-config.PL' => [
166          '$(PREFIX)/share/koha/etc/koha-conf.xml',
167          '$(PREFIX)/share/koha/etc/koha-httpd.conf',
168          '$(PREFIX)/share/koha/etc/zebra-biblios.cfg',
169          '$(PREFIX)/share/koha/etc/zebra-authorities.cfg'
170          ]
171    }
172 #     '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'],
173 #     'misc/koha.conf.PL' => '$(INST_LIBDIR)/../etc/koha.conf',
174 #     'misc/apache-koha.conf.PL' => '$(INST_LIBDIR)/../etc/apache-koha.conf',
175 #     'misc/koha.sql.PL' => '$(INST_LIBDIR)/intranet/scripts/koha.sql',
176 #     'z3950/z3950-daemon-options.PL' => '$(INST_LIBDIR)/intranet/scripts/z3950daemon/z3950-daemon-options',
177 #     # fake target to check permissions
178 #     'misc/chmod.PL' => '$(INST_LIBDIR)/fake-target'
179 #     }
180    # need to set ownerships
181    # need to load koha.sql
182    # need to link koha-httpd.conf
183    # need to start z3950-daemon
184 );
185
186 =head1 FUNCTIONS
187
188 =head2 map_tree
189
190 This function lists all files and where to install each one.
191 It returns a hash reference suitable for the PM variable above.
192
193 =cut
194
195 sub map_tree {
196         my %result => ();
197
198 =pod
199
200 C4/*.pm is copied to perl's lib namespace.
201
202 =cut
203         foreach my $src (glob("C4/*.pm")) {
204                 $result{$src} = '$(INST_LIBDIR)/'.$src;
205         }
206
207 =pod
208
209 CGIs are copied to $(PREFIX)/lib/cgi-bin/koha/
210 and other scripts to koha/
211
212 =cut
213         foreach my $src ("mainpage.pl","help.pl",glob("*/*.pl"),glob("installer/*.pm"),glob("*/*/*.pl"),glob("*/*/*/*.pl")) {
214                 if ($src =~ /(misc|updater|rss)\//) {
215                         $result{$src} = '$(INST_LIBDIR)/koha/'.$src;
216                 } else {
217                         $result{$src} = '$(PREFIX)/lib/cgi-bin/koha/'.$src;
218                 }
219         }
220
221 =pod
222
223 Templates are copied to koha/templates,
224
225 =cut
226         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/*/*/*/*/*")) {
227
228 =pod
229
230 excluding non-files, CVS files and whitespace in filenames.
231
232 =cut
233                 if ((-f $src) && ($src !~ /(\/CVS\/|\s)/)) {
234                         $result{$src} = '$(INST_LIBDIR)/koha/templates/'.$src;
235                 }
236         }
237 =pod
238
239 etc files are copied to /usr/share/koha/etc/
240
241 =cut
242         # Misc etc to koha/etc
243         foreach my $src (glob("etc/*")) {
244                 $result{$src} = '$(PREFIX)/share/koha/'.$src;
245         }
246
247
248         return \%result;
249 }
250
251 __END__
252
253
254 =head1 SEE ALSO
255
256 ExtUtils::MakeMaker(3)
257
258 =head1 AUTHOR
259
260 MJ Ray mjr at phonecoop.coop
261
262 =cut
263