#!/bin/sh -e # # subst-configvars - Build-time script used to substitute configuration # variables in files without keeping inter-references # like exec_prefix=${prefix}. # # Use in Makefile rules like this: # # file : file.in # sh $(top_srcdir)/all/script/subst-configvars $< > $@ # # Used in all/lib/config-spec/Makefile.am , to generate lire.xml from # lire.xml.in . # # Copyright (C) 2003 Stichting LogReport Foundation LogReport@LogReport.org # $Id: subst-configvars.in,v 1.5 2006/07/23 13:16:33 vanbaal Exp $ # # This program is part of Lire. # # Lire is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program (see COPYING); if not, check with # http://www.gnu.org/copyleft/gpl.html. if test $# -ne 1 then echo "Usage: subs-configvars file.in > file" >&2 exit 1 fi dir=`dirname $0` substfile=$dir/configvars . $substfile { for v in `cut -d= -f 1 $substfile` do echo $v=`eval echo '$'$v` done } | @PERL@ -e ' my %subst = (); while ( ) { chomp; next unless /^(\w+)=(.*)/; $subst{$1} = $2; } # Substitute the @VAR@ in the file open FILE, $ARGV[1] or die "open of $ARGV[1] failed: $!\n"; while ( ) { s/\@(\w+)\@/$subst{$1}/eg; print; } ' $substfile $1