summaryrefslogtreecommitdiffhomepage
path: root/project
diff options
context:
space:
mode:
Diffstat (limited to 'project')
-rw-r--r--project/common.mk26
-rw-r--r--project/w32def/w32def.mk31
-rwxr-xr-xproject/w32def/w32def.sh83
3 files changed, 140 insertions, 0 deletions
diff --git a/project/common.mk b/project/common.mk
index 4b72987..f3d101a 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -5,3 +5,29 @@ INTERNAL_SRCS = \
APP_SRCS = \
COMMON_SRCS = $(API_SRCS) $(INTERNAL_SRCS)
+
+
+# list of underlying .dll's and .drv's
+W32DLL = \
+ advapi32.dll \
+ comctl32.dll \
+ comdlg32.dll \
+ gdi32.dll \
+ kernel32.dll \
+ imm32.dll \
+ ole32.dll \
+ shell32.dll \
+ user32.dll \
+ usp10.dll \
+ winmm.dll \
+
+W32DRV = \
+ winspool.drv
+
+# cross-compilation support
+W32FAKE += $(W32DLL:%.dll=$(SOURCE_DIR)/fake/%.dll)
+W32FAKE += $(W32DRV:%.drv=$(SOURCE_DIR)/fake/%.drv)
+
+# list of manually generated .def files
+W32DEF += $(W32DLL:%.dll=$(SOURCE_DIR)/def/%.def)
+W32DEF += $(W32DRV:%.drv=$(SOURCE_DIR)/def/%.def)
diff --git a/project/w32def/w32def.mk b/project/w32def/w32def.mk
new file mode 100644
index 0000000..b007064
--- /dev/null
+++ b/project/w32def/w32def.mk
@@ -0,0 +1,31 @@
+PERK ?= perk
+W32_SYSDIR ?= /dev/null
+PROJECT_DIR ?= .
+SOURCE_DIR ?= .
+
+include $(PROJECT_DIR)/project/common.mk
+
+fake/%.dll:
+ touch $@
+
+fake/%.drv:
+ touch $@
+
+config.project: $(W32FAKE)
+
+$(SOURCE_DIR)/def/kernel32.def: APIS_WITH_CAPS = -c
+
+$(SOURCE_DIR)/def/%.def: $(W32_SYSDIR)/%.dll
+ $(PROJECT_DIR)/project/w32def/w32def.sh -p $(PERK) -l $< -o $@ $(APIS_WITH_CAPS)
+
+$(SOURCE_DIR)/def/%.def: $(W32_SYSDIR)/%.drv
+ $(PROJECT_DIR)/project/w32def/w32def.sh -p $(PERK) -l $< -o $@ $(APIS_WITH_CAPS)
+
+w32def: config.project $(W32DEF)
+
+w32def-clean:
+ rm -f $(W32DEF)
+ rm -f $(W32FAKE)
+
+.PHONY: w32def
+.PHONY: w32def-clean
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