#!/bin/sh

for p in $*; do
	case $p in
		--with-pcsc-drivers-dir=*)
			pcsc_dir=${p#*=}
		;;
	esac
done

if [ -z $pcsc_dir ]; then
	pcsc_dir=`pkg-config libpcsclite --variable=usbdropdir`
fi

if [ -z $pcsc_dir ]; then
	echo Cannot find pcsc directory
	exit 1
fi

sed "s#\%PCSC_DRIVERS_DIR\%#$pcsc_dir#g" < Makefile.in > Makefile

exit 0
