#! /bin/sh -e
## 44-kfreebsd.dpatch by Luca Falavigna <dktrkranz@debian.org>
## DP: kFreeBSD support.

if [ $# -lt 1 ]; then
    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
    exit 1
fi

[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"

case "$1" in
    -patch) patch -p0 ${patch_opts} < $0;;
    -unpatch) patch -R -p0 ${patch_opts} < $0;;
    *)
        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
        exit 1;;
esac

exit 0

@DPATCH@
--- 4Suite-XML-1.0.2/Ft/Lib/DistExt/BuildExt.py
+++ 4Suite-XML-1.0.2/Ft/Lib/DistExt/BuildExt.py
@@ -58,7 +58,7 @@ class BuildExt(build_ext.build_ext):
         # If built as shared, remove the library dir if the shared library
         # is not installed there (which Python does not do by default).
         # This fixes the errors building on openSUSE 10.2 w/Python 2.5.
-        if (sys.platform.startswith('linux') and
+        if ((sys.platform.startswith('linux') or sys.platform.startswith('gnukfreebsd')) and
             sysconfig.get_config_var('Py_ENABLE_SHARED')):
             libpl, ldlibrary = sysconfig.get_config_vars('LIBPL', 'LDLIBRARY')
             if libpl in self.library_dirs:
@@ -83,6 +83,7 @@ class BuildExt(build_ext.build_ext):
             self.symbol_stripping = STRIP_NONE
 
         elif (sys.platform.startswith('linux')
+              or sys.platform.startswith('gnukfreebsd')
               or sys.platform.startswith('freebsd')
               or sys.platform.startswith('openbsd')
               or sys.platform.startswith('netbsd')):

