#!/bin/sh
rm -f Makefile

# some defaults
version=0.3
prefix=/usr/local
mandir=${prefix}/share/man
name=gcc

for i; do
	opt=$(echo ${i}|sed 's|=.*||g')
	val=$(echo ${i}|sed 's|.*=||g')
	if [ "--help" = "${opt}" ]; then
		echo "Options:"
		echo "--prefix=PREFIX   install in PREFIX"
		echo "--mandir=MANDIR   install manpages in MANDIR"
		echo "--name=NAME       use NAME_select for tool"
		exit 0
	elif [ "--prefix" = "${opt}" ]; then
		prefix=${val}
	elif [ "--mandir" = "${opt}" ]; then
		mandir=${val}
	elif [ "--name" = "${opt}" ]; then
		name=${val}
	fi
done

cat Makefile.in | \
	sed "s|@prefix@|${prefix}|g" | \
	sed "s|@mandir@|${mandir}|g" | \
	sed "s|@version@|${version}|g" | \
	sed "s|@name@|${name}|g" > Makefile

