bin/setlib.cfg
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
permissions -rw-r--r--
RELEASE 4.2.0 freetown
     1 #
     2 # TWiki Collaboration Platform, http://TWiki.org/
     3 #
     4 # This program is free software; you can redistribute it and/or
     5 # modify it under the terms of the GNU General Public License
     6 # as published by the Free Software Foundation; either version 2
     7 # of the License, or (at your option) any later version. For
     8 # more details read LICENSE in the root of this distribution.
     9 #
    10 # This program is distributed in the hope that it will be useful,
    11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    13 #
    14 # setlib.cfg: determines the defaults for TWiki and Perl library paths
    15 #
    16 
    17 ###########################################################################
    18 # DO NOT CHANGE THIS FILE - instead, create a file called LocalLib.cfg    #
    19 # using the LocalLib.cfg.txt template file and customise your settings in #
    20 # there. They will override any settings in this file.                    #
    21 ###########################################################################
    22 
    23 # for development, you can enable ASSERTS by adding
    24 # $ENV{TWIKI_ASSERTS} = 1;
    25 # to your bin/LocalLib.cfg
    26 
    27 use vars qw( $twikiLibPath @localPerlLibPath );
    28 
    29 eval 'require "LocalLib.cfg"';
    30 
    31 unless (( defined ($twikiLibPath) ) and (-e $twikiLibPath)) {
    32 	use Cwd qw( abs_path );
    33 	( $twikiLibPath ) = ($twikiLibPath = Cwd::abs_path( "../lib" )) =~ /(.*)/;
    34 }
    35 if ($twikiLibPath eq "") {
    36     $twikiLibPath = "../lib";
    37     warn "using relative path for libs - some plugins may break";
    38 }
    39 
    40 #    Path to local Perl modules
    41 my $defaultingCPANBASE = !defined($CPANBASE);
    42 $CPANBASE = "$twikiLibPath/CPAN/lib/" unless $CPANBASE;
    43 if ( -e $CPANBASE ) {
    44 	require Config;
    45 	my $VER = $Config::Config{version};
    46 	my $SITEARCH = $Config::Config{archname};
    47 	push @localPerlLibPath, ( "$CPANBASE/arch", "$CPANBASE/$VER/$SITEARCH", "$CPANBASE/$VER", "$CPANBASE" );
    48 }
    49 
    50 # Prepend to @INC, the Perl search path for modules
    51 unshift @INC, $twikiLibPath;
    52 if ($defaultingCPANBASE) {
    53 	push @INC, @localPerlLibPath if defined @localPerlLibPath;
    54 } else {
    55 	unshift @INC, @localPerlLibPath if defined @localPerlLibPath;
    56 }
    57 
    58 1;			    	# Return success for module loading
    59