#! /bin/bash

prefix=/usr
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
core_path=$prefix/core
file_conf=""

usage="usage : genere_ptools [-b bindir] [-c corefile] file_of_commands" 

while test $# -gt 0; 
do
	if [ $# -ne 0 ]; then
		case "$1" in
			-h) echo $usage ;
					exit 0;;
			-c) shift;
					core_path=$1;
					shift;;
			-b) shift;
					bindir=$1;
					shift;;
			 *) fileconf=$1
					break;;
		esac
	fi
done			

mkdir -p $path/bin

for i in `cat $1`
do
	echo "#! /bin/bash" > ${bindir}/p$i
	echo "tool=$i" >> ${bindir}/p$i
	cat $core_path/ptools_core>> ${bindir}/p$i
	chmod +x ${bindir}/p$i
	echo $prefix/bin/p$i >> ~/.ptools.conf
done
