3 # This script uses the current values of Girocco::Config to
4 # convert apache.conf.in into apache.conf.
6 # It is run automatically by "make" or "make apache.conf" but
7 # may be run separately if desired.
13 trap "rm -f 'apache.conf.$$'" EXIT
17 # Include custom configuration, if any
18 [ ! -e config.sh
] ||
[ ! -f config.sh
] ||
[ ! -r config.sh
] || . .
/config.sh
20 __girocco_conf
="$GIROCCO_CONF"
21 [ -n "$__girocco_conf" ] || __girocco_conf
="Girocco::Config"
22 perl
-I"$PWD" -M"$__girocco_conf" -- - apache.conf.
in >apache.conf.$$
<<'EOT'
23 #line 21 "make-apache-conf.sh"
27 my $frombegin = '# ---- BEGIN LINES TO DUPLICATE ----';
28 my $fromend = '# ---- END LINES TO DUPLICATE ----';
29 my $tobegin = '# ---- BEGIN DUPLICATE LINES ----';
30 my $toend = '# ---- END DUPLICATE LINES ----';
32 open IN, '<', $ARGV[0] or die "could not open $ARGV[0] for reading: $!\n";
39 $input =~ s/^##.*(?:\n|$)//gm;
42 if (eval '$Girocco::Config::'.$_[1]) {
43 $_[0] ? "Girocco_Config_$_[1]_Disabled" : "!Girocco_Config_$_[1]_Disabled";
45 $_[0] ? "!Girocco_Config_$_[1]_Enabled" : "Girocco_Config_$_[1]_Enabled";
48 $input =~ s/^(\s*<IfDefine\s+)(!?)\@\@([a-zA-Z][a-zA-Z0-9_]*)\@\@>/
49 $1 . &$repl($2, $3) . '>'/gmexi;
52 $input =~ s/\@\@([a-zA-Z][a-zA-Z0-9_]*)\@\@/eval
53 "\$Girocco::Config::$1 ne ''?\$Girocco::Config::$1:'\@\@'.\"$1\".'\@\@'"/gsex;
55 if ($input =~ /(?:^|\n)$frombegin[^\n]*\n(.*)(?<=\n)$fromend/s) {
57 if ($input =~ /^((?:.+\n)?$tobegin[^\n]*\n).*((?<=\n)$toend.*)$/s) {
58 $input = $1 . $dupelines . $2;
63 mv -f apache.conf.$$ apache.conf