summaryrefslogtreecommitdiff
path: root/configure
blob: 3cb0b29d5b59a7d2c25e50c2a9ba40f45f179696 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
name='configure' # rvs configureation script
# version 0.7.0
# Copyright (C) 2009 Luke Shumaker
# 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.
# 
# Originally written by Luke Shumaker <lukeshu@sbcglobal.net>.

     _srcdir=$(readlink -f `dirname "$0"`)
      _SHELL='/bin/sh'
     _prefix='/usr/local'
_exec_prefix='$(prefix)'
     _bindir='$(exec_prefix)/bin'
    _sbindir='$(exec_prefix)/sbin'
      rvsdir='/etc'

vars='srcdir SHELL prefix exec_prefix bindir sbindir rvsdir'

error() {
	echo "$name: $1" >> /dev/stderr
	exit 1
}

args=`getopt -n "$name" -o "${sopt}" -l "${lopt}${vars}" -- "$@"`
if [ $? == 0 ]; then
	set -- $args
	while [ $# -gt 0 ]; do case "$1" in
		--) break;;
		--*)
			var0="${1/--/}"
			match='false'
			for var1 in $vars; do
				if [ "$var0" == "$var1" ]; then
					match='true'
					break;
				fi
			done
			if [ "$match" == 'true' ]; then
				val="$2"
				eval _$var0=$val
			else
				error "option \`$1' not recognized";
			fi
			:;;
		*) error "option \`$1' not recognized";;
	esac
	shift
	done
else
	error 'unable to parse command line arguments'
fi

echo '#!/bin/sed -f' > var.sed
for var in $vars; do
	var1="_$var"
	val=${!var1}
	
	var=${var//':'/'\:'}
	val=${val//':'/'\:'}
	
	echo "s:@$var@:$val:g" >> var.sed
done

echo "11 a# DO NOT edit this file, it has been generated by configure, and will
11 a# be overwritten. Instead, edit the file \`Makefile.orig'" >> var.sed

Makefiles=`find "${_srcdir}/" -regextype posix-extended \
-regex '(.*/)?Makefile\.orig' -type f`

for orig in $Makefiles; do
	new=${orig/%.orig/}
	new=${new/#$_srcdir/}
	sed -f var.sed < "${orig}" > "${new}"
done