Blame project/w32def/w32def.sh

b743da
#!/bin/sh
b743da
b743da
usage()
b743da
{
b743da
cat << EOF >&2
b743da
b743da
Usage:
b743da
  -h            show this HELP message
b743da
  -p  PERK      set pe parser utility
b743da
  -o  OUTPUT    set output file name
b743da
  -l  SYSLIB    set system library from which to extract symbols
b743da
b743da
EOF
b743da
exit 1
b743da
}
b743da
b743da
b743da
# one
b743da
perk=
b743da
caps=
b743da
b743da
workdir=$(pwd)
b743da
output=
b743da
syslib=
b743da
b743da
b743da
while getopts "hp:o:l:c" opt; do
b743da
	case $opt in
b743da
	h)
b743da
  		usage
b743da
		;;
b743da
	p)
b743da
    		perk="$OPTARG"
b743da
		;;
b743da
	o)
b743da
    		output="$OPTARG"
b743da
		;;
b743da
	l)
b743da
    		syslib="$OPTARG"
b743da
		;;
b743da
	c)
b743da
		caps='yes'
b743da
		;;
b743da
	\?)
b743da
    		printf "$0: Invalid option: -%s" "$OPTARG" >&2
b743da
    		usage
b743da
		;;
b743da
	esac
b743da
done
b743da
b743da
b743da
# two
b743da
if [ -z "$perk" ] || [ -z "$output" ] || [ -z "$syslib" ]; then
b743da
	usage
b743da
fi
b743da
b743da
tmpdef=`mktemp`
b743da
b743da
if [ -z "$tmpdef" ]; then
b743da
	printf "$0: Failed to create a temporary file!" >&2
b743da
	exit 1
b743da
fi
b743da
b743da
# three
b743da
if [ -z "$caps" ]; then
b743da
	"$perk" -e "$syslib"                   > "$tmpdef" || exit 1
b743da
else
b743da
	"$perk" -e "$syslib" | grep -e '[A-Z]' > "$tmpdef" || exit 1
b743da
fi
b743da
b743da
# four
b743da
grep -v                                      \
b743da
		-e 'DllMain'                 \
b743da
		-e 'DllCanUnloadNow'         \
b743da
		-e 'DllDebugObjectRPCHook'   \
b743da
		-e 'DllGetClassObject'       \
b743da
		-e 'DllRegisterServer'       \
b743da
		-e 'DllUnregisterServer'     \
b743da
		-e '?'                       \
b743da
	"$tmpdef" > "$output" || exit 1
b743da
b743da
# all done
b743da
exit 0