3 # $Id: SWConfig.pm.in,v 1.2 2004/04/08 01:52:19 mdw Exp $
5 # Exports configuration variables
10 #----- Licensing notice -----------------------------------------------------
12 # This file is part of sw-tools.
14 # sw-tools is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # sw-tools is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with sw-tools; if not, write to the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #----- Package preamble -----------------------------------------------------
36 #----- Configuration variables ----------------------------------------------
39 $C{pkg} = '@PACKAGE@';
40 $C{version} = '@VERSION@';
41 $C{prefix} = '@prefix@';
42 $C{datadir} = '@datadir@';
43 $C{index} = '${prefix}/sw-index';
44 $C{doc} = '${prefix}/doc';
46 foreach my $k (qw(datadir index doc)) {
47 $C{$k} =~ s/\$\{(\w+)\}/$C{$1}/eg;
50 #----- Read a configuration file --------------------------------------------
52 if (my $fh = IO::File->new("$C{datadir}/sw.conf")) {
53 LINE: while (my $line = $fh->getline()) {
55 next LINE if $line =~ /^\s*\#/ || $line =~ /^\s*$/;
56 my ($k, $v) = split(/\s*=\s*|\s+/, $line, 2);
57 $v =~ s/\$\{(\w+)\}/$C{$1}/eg;
62 #----- That's all, folks ----------------------------------------------------