summaryrefslogtreecommitdiffhomepage
path: root/project/w32def/w32def.sh
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-11-18 21:46:46 +0000
committermidipix <writeonce@midipix.org>2017-11-18 18:16:42 -0500
commitb743dadc04f87b72d040e3c93a1d5084491e9fb9 (patch)
tree3c7da62eae459d8e62e9c003039b16383b7925d7 /project/w32def/w32def.sh
parente3c62e1f68780795a6115d081c78eee579c44e40 (diff)
downloadw32lib-b743dadc04f87b72d040e3c93a1d5084491e9fb9.tar.bz2
w32lib-b743dadc04f87b72d040e3c93a1d5084491e9fb9.tar.xz
project: added w32def.mk, w32def.sh (generation of .def source files).
Diffstat (limited to 'project/w32def/w32def.sh')
-rwxr-xr-xproject/w32def/w32def.sh83
1 files changed, 83 insertions, 0 deletions
diff --git a/project/w32def/w32def.sh b/project/w32def/w32def.sh
new file mode 100755
index 0000000..3fca7c3
--- /dev/null
+++ b/project/w32def/w32def.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+usage()
+{
+cat << EOF >&2
+
+Usage:
+ -h show this HELP message
+ -p PERK set pe parser utility
+ -o OUTPUT set output file name
+ -l SYSLIB set system library from which to extract symbols
+
+EOF
+exit 1
+}
+
+
+# one
+perk=
+caps=
+
+workdir=$(pwd)
+output=
+syslib=
+
+
+while getopts "hp:o:l:c" opt; do
+ case $opt in
+ h)
+ usage
+ ;;
+ p)
+ perk="$OPTARG"
+ ;;
+ o)
+ output="$OPTARG"
+ ;;
+ l)
+ syslib="$OPTARG"
+ ;;
+ c)
+ caps='yes'
+ ;;
+ \?)
+ printf "$0: Invalid option: -%s" "$OPTARG" >&2
+ usage
+ ;;
+ esac
+done
+
+
+# two
+if [ -z "$perk" ] || [ -z "$output" ] || [ -z "$syslib" ]; then
+ usage
+fi
+
+tmpdef=`mktemp`
+
+if [ -z "$tmpdef" ]; then
+ printf "$0: Failed to create a temporary file!" >&2
+ exit 1
+fi
+
+# three
+if [ -z "$caps" ]; then
+ "$perk" -e "$syslib" > "$tmpdef" || exit 1
+else
+ "$perk" -e "$syslib" | grep -e '[A-Z]' > "$tmpdef" || exit 1
+fi
+
+# four
+grep -v \
+ -e 'DllMain' \
+ -e 'DllCanUnloadNow' \
+ -e 'DllDebugObjectRPCHook' \
+ -e 'DllGetClassObject' \
+ -e 'DllRegisterServer' \
+ -e 'DllUnregisterServer' \
+ -e '?' \
+ "$tmpdef" > "$output" || exit 1
+
+# all done
+exit 0