+=head2 target_map
+
+This is a hash mapping directories and files in the
+source tree to installation target directories. The rules
+for this mapping are:
+
+=over 4
+
+=item If a directory or file is specified, it and its
+contents will be copied to the installation target directory.
+
+=item If a subdirectory of a mapped directory is specified,
+its target overrides the parent's target for that subdirectory.
+
+=item The value of each map entry may either be a scalar containing
+one target or a reference to a hash containing 'target' and 'trimdir'
+keys.
+
+=item Any files at the top level of the source tree that are
+not included in the map will not be installed.
+
+=item Any directories at the top level of the source tree
+that are not included in the map will be installed in
+INTRANET_CGI_DIR. This is a sensible default given the
+current organization of the source tree, but (FIXME) it
+would be better to reorganize the source tree to better
+match the installation system, to allow adding new directories
+without having to adjust Makefile.PL each time. The idea
+is to make the C<$target_map> hash as minimal as possible.
+
+=back
+
+The permitted installation targets are:
+
+=over 4
+
+=item INTRANET_CGI_DIR
+
+CGI scripts for intranet (staff) interface.
+
+=item INTRANET_TMPL_DIR
+
+HTML templates for the intranet interface.
+
+=item INTRANET_WWW_DIR
+
+HTML files, images, etc. for DocumentRoot for the intranet interface.
+
+=item OPAC_CGI_DIR
+
+CGI scripts for OPAC (public) interface.
+
+=item OPAC_TMPL_DIR
+
+HTML templates for the OPAC interface.
+
+=item OPAC_WWW_DIR
+
+HTML files, images, etc. for DocumentRoot for the OPAC interface.
+
+=item PERL_MODULE_DIR
+
+Perl modules (at present just the C4 modules) that are intimately
+tied to Koha. Depending on the installation options, these
+may or may not be installed one of the standard directories
+in Perl's default @LIB.
+
+=item KOHA_CONF_DIR
+
+Directory for Koha configuration files.
+
+=item ZEBRA_CONF_DIR
+
+Directory for Zebra configuration files.
+
+=item ZEBRA_LOCK_DIR
+
+Directory for Zebra's lock files.
+
+=item ZEBRA_DATA_DIR
+
+Directory for Zebra's data files.
+
+=item ZEBRA_RUN_DIR
+
+Directory for Zebra's UNIX-domain sockets.
+
+=item MISC_DIR
+
+Directory for for miscellaenous scripts, among other
+things the translation toolkit and RSS feed tools.
+
+=item SCRIPT_DIR
+
+Directory for command-line scripts and daemons.
+
+=item MAN_DIR
+
+Directory for man pages created from POD -- will mostly
+contain information of interest to Koha developers.
+
+=item DOC_DIR
+
+Directory for Koha documentation accessed from the
+command-line, e.g., READMEs.
+
+=item LOG_DIR
+
+Directory for Apache and Zebra logs produced by Koha.
+
+=item NONE
+
+This is a dummy target used to explicitly state
+that a given file or directory is not to be installed.
+This is used either for parts of the installer itself
+or for development tools that are not applicable to a
+production installation.
+
+=back
+
+=cut
+
+my $target_map = {
+ './about.pl' => 'INTRANET_CGI_DIR',
+ './acqui' => 'INTRANET_CGI_DIR',
+ './admin' => 'INTRANET_CGI_DIR',
+ './authorities' => 'INTRANET_CGI_DIR',
+ './C4' => 'PERL_MODULE_DIR',
+ './C4/SIP/t' => 'NONE',
+ './C4/SIP/koha_test' => 'NONE',
+ './C4/tests' => 'NONE',
+ './catalogue' => 'INTRANET_CGI_DIR',
+ './cataloguing' => 'INTRANET_CGI_DIR',
+ './changelanguage.pl' => 'INTRANET_CGI_DIR',
+ './check_sysprefs.pl' => 'NONE',
+ './circ' => 'INTRANET_CGI_DIR',
+ './edithelp.pl' => 'INTRANET_CGI_DIR',
+ './etc' => { target => 'KOHA_CONF_DIR', trimdir => -1 },
+ './etc/zebradb' => { target => 'ZEBRA_CONF_DIR', trimdir => -1 },
+ './help.pl' => 'INTRANET_CGI_DIR',
+ './installer-CPAN.pl' => 'NONE',
+ './installer' => 'INTRANET_CGI_DIR',
+ './koha-tmpl/errors' => {target => 'INTRANET_CGI_DIR', trimdir => 2},
+ './koha-tmpl/intranet-tmpl' => {target => 'INTRANET_TMPL_DIR', trimdir => -1},
+ './koha-tmpl/opac-tmpl' => {target => 'OPAC_TMPL_DIR', trimdir => -1},
+ './kohaversion.pl' => 'INTRANET_CGI_DIR',
+ './labels' => 'INTRANET_CGI_DIR',
+ './mainpage.pl' => 'INTRANET_CGI_DIR',
+ './Makefile.PL' => 'NONE',
+ './MANIFEST.SKIP' => 'NONE',
+ './members' => 'INTRANET_CGI_DIR',
+ './misc' => { target => 'SCRIPT_DIR', trimdir => -1 },
+ './misc/info' => { target => 'DOC_DIR', trimdir => 2 },
+ './misc/release notes' => { target => 'DOC_DIR', trimdir => 2 },
+ './misc/translator' => { target => 'MISC_DIR', trimdir => 2 },
+ './misc/installer_devel_notes' => 'NONE',
+ './opac' => 'OPAC_CGI_DIR',
+ './README.txt' => 'NONE',
+ './reports' => 'INTRANET_CGI_DIR',
+ './reserve' => 'INTRANET_CGI_DIR',
+ './reviews' => 'INTRANET_CGI_DIR',
+ './rewrite-config.PL' => 'NONE',
+ './reviews' => 'INTRANET_CGI_DIR',
+ './rss' => 'MISC_DIR',
+ './serials' => 'INTRANET_CGI_DIR',
+ './skel' => 'NONE',
+ './skel/var/log/koha' => { target => 'LOG_DIR', trimdir => -1 },
+ './skel/var/run/koha/zebradb' => { target => 'ZEBRA_RUN_DIR', trimdir => -1 },
+ './skel/var/lock/koha/zebradb/authorities' => { target => 'ZEBRA_LOCK_DIR', trimdir => 6 },
+ './skel/var/lib/koha/zebradb/authorities/key' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
+ './skel/var/lib/koha/zebradb/authorities/register' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
+ './skel/var/lib/koha/zebradb/authorities/shadow' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
+ './skel/var/lib/koha/zebradb/authorities/tmp' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
+ './skel/var/lock/koha/zebradb/biblios' => { target => 'ZEBRA_LOCK_DIR', trimdir => 6 },
+ './skel/var/lib/koha/zebradb/biblios/key' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
+ './skel/var/lib/koha/zebradb/biblios/register' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
+ './skel/var/lib/koha/zebradb/biblios/shadow' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
+ './skel/var/lib/koha/zebradb/biblios/tmp' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
+ './sms' => 'INTRANET_CGI_DIR',
+ './suggestion' => 'INTRANET_CGI_DIR',
+ './svc' => 'INTRANET_CGI_DIR',
+ './t' => 'NONE',
+ './tmp' => 'NONE', # FIXME need to determine whether
+ # Koha generates any persistent temp files
+ # that should go in /var/tmp/koha
+ './tools' => 'INTRANET_CGI_DIR',
+ './virtualshelves' => 'INTRANET_CGI_DIR',
+ # ignore files and directories created by the install itself
+ './pm_to_blib' => 'NONE',
+ './blib' => 'NONE',
+};
+
+=head1 CONFIGURATION OPTIONS
+
+The following configuration options are used by the installer.
+
+=over 4
+
+=item INSTALL_MODE
+
+Specifies whether installation will be FHS-compliant (default,
+assumes user has root), put everything under
+a single directory (for users installing on a web host
+that allows CGI scripts and a MySQL database but not root
+access), or development (for a developer who wants to run
+Koha from a git clone with no fuss).
+
+=item INSTALL_BASE
+
+Directory under which most components will go. Default
+value will vary depending on INSTALL_MODE.
+
+=item DB_TYPE
+
+Type of DBMS (e.g., mysql or Pg).
+
+=item DB_HOST
+
+Name of DBMS server.
+
+=item DB_PORT
+
+Port that DBMS server is listening on.
+
+=item DB_NAME
+
+Name of the DBMS database for Koha.
+
+=item DB_USER
+
+Name of DBMS user account for Koha's database.
+
+=item DB_PASS
+
+Pasword of DMBS user account for Koha's database.
+
+=item INSTALL_ZEBRA
+
+Whether to install Zebra configuration files and data
+directories.
+
+=item ZEBRA_MARC_FORMAT
+
+Specifies format of MARC records to be indexed by Zebra.
+
+=item ZEBRA_LANGUAGE
+
+Specifies primary language of records that will be
+indexed by Zebra.
+
+=item ZEBRA_USER
+
+Internal Zebra user account for the index.
+
+=item ZEBRA_PASS
+
+Internal Zebra user account's password.
+
+=item KOHA_USER
+
+System user account that will own Koha's files.
+
+=item KOHA_GROUP
+
+System group that will own Koha's files.
+
+=back
+
+=cut
+
+# default configuration options
+my %config_defaults = (
+ 'DB_TYPE' => 'mysql',
+ 'DB_HOST' => 'localhost',
+ 'DB_NAME' => 'koha',
+ 'DB_USER' => 'kohaadmin',
+ 'DB_PASS' => 'katikoan',
+ 'INSTALL_ZEBRA' => 'yes',
+ 'ZEBRA_MARC_FORMAT' => 'marc21',
+ 'ZEBRA_LANGUAGE' => 'en',
+ 'ZEBRA_USER' => 'kohauser',
+ 'ZEBRA_PASS' => 'zebrastripes',
+ 'KOHA_USER' => 'koha',
+ 'KOHA_GROUP' => 'koha',
+);
+
+# set some default configuratio options based on OS
+# more conditions need to be added for other OS's
+# this should probably also incorporate usage of Win32::GetOSName() and/or Win32::GetOSVersion()
+# to allow for more granular decisions based on which Win32 platform
+
+warn "Your platform appears to be $^O.\n" if $DEBUG;
+
+if ( $^O eq 'MSWin32' ) {
+ # Most Unix2Win32 ports seem to poke everything into the Program Files directory
+ # this could be changed to put some files (ie. libraries) into system32, etc.
+ $config_defaults{'INSTALL_MODE'} = 'single';
+ $config_defaults{'INSTALL_BASE'} = 'c:/progra~1/koha'; # Use 8.3 names to be safe...
+}
+elsif ( $^O eq 'cygwin' ) {
+ # Most Unix2Win32 ports seem to poke everything into the Program Files directory
+ # this could be changed to put some files (ie. libraries) into system32, etc.
+ $config_defaults{'INSTALL_MODE'} = 'single';
+ $config_defaults{'INSTALL_BASE'} = 'c:/progra~1/koha'; # Use 8.3 names to be safe...
+}
+else {
+ $config_defaults{'INSTALL_MODE'} = 'standard';
+ $config_defaults{'INSTALL_BASE'} = '/usr/share/koha';
+}