--- configure-old	2015-07-31 23:45:28.000000000 +0300
+++ configure	2015-08-26 00:58:02.000000000 +0300
@@ -18,6 +18,7 @@
 export LC_ALL
 
 # append some extra paths
+OS2PATH=$PATH
 PATH="$PATH:/opt/gnome/bin"
 # Solaris (order of paths important for tr, echo, grep, sed to work)
 PATH="/usr/xpg4/bin:/usr/ucb:$PATH:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin"
@@ -35,16 +36,18 @@
   fi
   if [ "$have_ancient_which" = "yes" ]; then
     retval=`which $* 2>/dev/null`
-    echo "$retval"
+    # echo "$retval"
     test -n "$retval" -a -x "$retval"
-    unset retval
+    # unset retval
   else
     which $* 2> /dev/null
   fi
 }
 
 OS=`uname -s | sed -e 's/GNU\/Linux/Linux/g' | tr '[:upper:]' '[:lower:]'`
-case "$OS" in
+OS=`echo $OS | sed -e 's|/||'`
+
+case $OS in
   linux)
     ;;
   darwin)
@@ -56,6 +59,9 @@
     ;;
   haiku)
     ;;
+  os2)
+    PATH=${OS2PATH}
+    ;;
   *)
     echo "Cannot determine OS!"
     exit 1
@@ -142,6 +148,9 @@
   INCPNG="-I/usr/local/include"
   LIBPNG="-L/usr/local/lib -lpng"
 else
+  if [ "${OS}" = "os2" ]; then
+    CXX_FLAGS="-Zomf"
+  fi
   INCCURL=""
   LIBCURL="-lcurl"
   INCPNG=""
@@ -150,7 +159,7 @@
 INCVPX=""
 LIBVPX="-lvpx"
 PKGCONFIG="`which_wrapper pkg-config`"
-PYTHONDIR="/usr /usr/local"
+PYTHONDIR="/usr /usr/lib /usr/local"
 QT4DIR="/usr/lib/qt4 /usr/share/qt4 /usr/lib64/qt4 /usr /usr/local"
 QT4DIR_PKGCONFIG=1
 QT4UIC3DIR="/usr/bin"
@@ -222,7 +231,9 @@
 
 cnf_append()
 {
-  printf "%-30s := %s\n" "$1" "$2" >> $CNF
+  # change backslashes in paths to forward slashes
+  x=`echo "$2" | sed -e 's,\\\\,\/,g'`
+  printf "%-30s := %s\n" "$1" "$x" >> $CNF
 }
 
 strip_l()
@@ -242,7 +253,7 @@
 
 prefix_I()
 {
-  echo "$1"|$KBUILD_SED 's|^\/|-I/|g; s| \/| -I/|g'
+  echo "$1"|$KBUILD_SED 's|^\/|-I/|g; s| \/| -I/|g; s|^\([a-zA-Z]\:\/\)|-I\1|g; s| \([a-zA-Z]\:\/\)| -I\1|g'
 }
 
 check_avail()
@@ -377,6 +388,8 @@
   DEVDIR_BIN="$DEVDIR/$OS.$BUILD_MACHINE/bin"
   log_success "Determined build machine: $OS.$BUILD_MACHINE, target machine: $OS.$TARGET_MACHINE"
 
+  echo "BUILD_HOST=\"$OS\"" >> $ENV
+  echo "export BUILD_HOST" >> $ENV
   echo "BUILD_PLATFORM=\"$OS\"" >> $ENV
   echo "export BUILD_PLATFORM" >> $ENV
   echo "BUILD_PLATFORM_ARCH=\"$BUILD_MACHINE\"" >> $ENV
@@ -389,6 +402,46 @@
   echo "export BUILD_TARGET_CPU" >> $ENV
   echo "BUILD_TYPE=\"$BUILD_TYPE\"" >> $ENV
   echo "export BUILD_TYPE" >> $ENV
+  
+  if [ "$OS" = "os2" ]; then
+    # current dir
+    wd=`pwd`
+
+    # Additional paths
+    echo "EMXOMFLD_TYPE=\"$EMXOMFLD_TYPE\"" >> $ENV
+    echo "export EMXOMFLD_TYPE" >> $ENV
+
+    echo "EMXOMFLD_LINKER=\"$EMXOMFLD_LINKER\"" >> $ENV
+    echo "export EMXOMFLD_LINKER" >> $ENV
+
+    # static libs search path
+    LIBRARY_PATH="${wd}/out/${OS}.${BUILD_MACHINE}/${BUILD_TYPE}/lib;${GCC_DIR}/usr/lib;${LIBRARY_PATH}"
+
+    echo "LIBRARY_PATH=\"${LIBRARY_PATH}\"" >> $ENV
+    echo "export LIBRARY_PATH" >> $ENV
+
+    # echo "LD_LIBRARY_PATH=\"${LIBRARY_PATH}\"" >> $ENV
+    # echo "export LD_LIBRARY_PATH" >> $ENV
+
+    echo "LIB=\"${WATCOM}/lib286\"" >> $ENV
+    echo "export LIB" >> $ENV
+
+    C_INCLUDE_PATH="${GCC_DIR}/usr/include;${C_INCLUDE_PATH}"
+
+    echo "C_INCLUDE_PATH=\"${C_INCLUDE_PATH}\"" >> $ENV
+    echo "export C_INCLUDE_PATH" >> $ENV
+
+    echo "CPLUS_INCLUDE_PATH=\"${C_INCLUDE_PATH}\"" >> $ENV
+    echo "export CPLUS_INCLUDE_PATH" >> $ENV
+
+    echo "INCLUDE=\"${WATCOM}/h\"" >> $ENV
+    echo "export INCLUDE" >> $ENV
+
+    EXT_LIBPATH="${wd}/out/${OS}.${BUILD_MACHINE}/${BUILD_TYPE}/bin"
+    EXT_LIBPATH=`echo "$EXT_LIBPATH" | sed -e 's,\/,\\\\\\\\,g'`
+    echo "BEGINLIBPATH=$EXT_LIBPATH" >> $ENV
+    echo "export BEGINLIBPATH" >> $ENV
+  fi
 }
 
 #
@@ -526,7 +579,7 @@
   # Check that the tools we use are there.
   for prog in wasm wcc wlink;
   do
-    if [ ! -f "$WATCOM/$wc_bin/$prog" ]; then
+    if [ ! -f "${WATCOM}/${wc_bin}/${prog}" -a ! -f "${WATCOM}/${wc_bin}/${prog}.exe" ]; then
       log_failure "$WATCOM/$wc_bin/$prog does not exist or is not a regular file."
       fail
     fi
@@ -581,7 +634,21 @@
 check_iasl()
 {
   test_header iasl
+  IASL2="`pwd`/tools/${OS}.${BUILD_MACHINE}/bin/iasl"
+
   if check_avail "$IASL" IASL; then
+    iasl_found="yes"
+  elif [ -f "${IASL2}" ]; then
+    iasl_found="yes"
+    IASL="${IASL2}"
+  elif [ -f "${IASL2}.exe" ]; then
+    iasl_found="yes"
+    IASL="${IASL2}.exe"
+  else
+    iasl_found="no"
+  fi
+
+  if [ "${iasl_found}" = "yes" ]; then
     iasl_ver=`$IASL|grep "ASL.*version"|sed 's+^ASL.*version \([0-9]*\).*+\1+'`
     if [ $? -ne 0 ]; then
       log_failure "iasl not found"
@@ -590,6 +657,9 @@
       log_success "found version $iasl_ver"
       cnf_append "VBOX_IASLCMD" "`which_wrapper $IASL`"
     fi
+  else
+    log_failure "iasl not found"
+    fail
   fi
 }
 
@@ -739,10 +809,11 @@
       fail
     else
       log_success "found version $libidl_ver"
-      cnf_append "VBOX_LIBIDL_CONFIG" \
-        "PKG_CONFIG_PATH=`libIDL-config-2 --prefix`/$LIB/pkgconfig `which_wrapper libIDL-config-2`"
+      cnf_append "VBOX_LIBIDL_CONFIG" "`which_wrapper libIDL-config-2`"
+      cnf_append "VBOX_PATH_LIBIDL" "`libIDL-config-2 --prefix`"
+      cnf_append "PKG_CONFIG_PATH" "`libIDL-config-2 --prefix`/$LIB/pkgconfig"
     fi
-  elif check_avail "libIDL-config" libIDL-config; then
+  elif which_wrapper libIDL-config > /dev/null; then
     libidl_ver=`libIDL-config --version`
     if [ $? -ne 0 ]; then
       log_failure "libIDL-config not working"
@@ -750,6 +821,84 @@
     else
       log_success "found version $libidl_ver"
       cnf_append "VBOX_LIBIDL_CONFIG" "`which_wrapper libIDL-config`"
+      cnf_append "VBOX_PATH_LIBIDL" "`libIDL-config --prefix`"
+      cnf_append "PKG_CONFIG_PATH" "`libIDL-config --prefix`/$LIB/pkgconfig"
+    fi
+  else
+    # no libIDL-config or libIDL-config-2 on PATH
+    idl_prefix="/usr"
+
+    if [ "${GLIBIDL2}" != "" ]; then
+      idl_prefix="${GLIBIDL2}"
+    fi
+
+    idl_config=""
+
+    if [ -f "${idl_prefix}/bin/libIDL-config-2" ]; then
+        idl_config="${idl_prefix}/bin/libIDL-config-2"
+    elif [ -f "${idl_prefix}/bin/libIDL-config" ]; then
+        idl_config="${idl_prefix}/bin/libIDL-config"
+    fi
+
+    if [ "${idl_config}" = "" ]; then
+      log_failure "${idl_config} not working"
+      fail
+    fi
+
+    libidl_ver=`${idl_config} --version`
+    if [ $? -ne 0 ]; then
+      log_failure "${idl_config} not working"
+      fail
+    else
+      log_success "found version $libidl_ver"
+      cnf_append "VBOX_LIBIDL_CONFIG" "${idl_config}"
+      cnf_append "VBOX_PATH_LIBIDL" "`${idl_config} --prefix`"
+      cnf_append "PKG_CONFIG_PATH" "`${idl_config} --prefix`/$LIB/pkgconfig"
+    fi
+  fi
+
+  test_header libglib
+
+  if which_wrapper glib-config > /dev/null; then
+    glib_ver=`glib-config --version`
+    if [ $? -ne 0 ]; then
+      log_failure "glib-config not working"
+      return
+      # fail
+    else
+      log_success "found version $glib_ver"
+      cnf_append "VBOX_PATH_GLIB" "`glib-config --prefix`"
+      cnf_append "VBOX_GLIB_CONFIG" "`which_wrapper glib-config`"
+    fi
+  else
+    # no glib-config on PATH
+    glib_prefix="/usr"
+
+    if [ "${GLIBIDL2}" != "" ]; then
+      glib_prefix="${GLIBIDL2}"
+    fi
+
+    glib_config=""
+
+    if [ -f "${glib_prefix}/bin/glib-config" ]; then
+        glib_config="${glib_prefix}/bin/glib-config"
+    fi
+
+    if [ "${glib_config}" = "" ]; then
+      log_failure "${glib_config} not working"
+      return
+      # fail
+    fi
+
+    glib_ver=`${glib_config} --version`
+    if [ $? -ne 0 ]; then
+      log_failure "${glib_config} not working"
+      return
+      # fail
+    else
+      log_success "found version ${glib_ver}"
+      cnf_append "VBOX_PATH_GLIB" "`${glib_config} --prefix`"
+      cnf_append "VBOX_GLIB_CONFIG" "${glib_config}"
     fi
   fi
 }
@@ -837,6 +986,18 @@
         cnf_append "SDK_VBOX_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
         cnf_append "SDK_VBOX_BLD_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
       fi
+    elif test_compile "$INCCRYPTO $LIBCRYPTO" crypto10 ssl10; then
+      if test_execute nofatal; then
+        cnf_append "SDK_VBOX_OPENSSL_INCS" "`strip_I "$INCCRYPTO"`"
+        cnf_append "SDK_VBOX_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
+        cnf_append "SDK_VBOX_BLD_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
+      fi
+    elif test_compile "$INCCRYPTO $LIBCRYPTO" kcrypt10 kssl10; then
+      if test_execute nofatal; then
+        cnf_append "SDK_VBOX_OPENSSL_INCS" "`strip_I "$INCCRYPTO"`"
+        cnf_append "SDK_VBOX_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
+        cnf_append "SDK_VBOX_BLD_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
+      fi
     fi
   fi
 }
@@ -901,7 +1062,7 @@
   [ -n "$INCZ" ] && I_INCZ=`prefix_I "$INCZ"`
   if test_compile "$LIBZ $I_INCZ" zlib zlib; then
     if test_execute; then
-      echo "if1of (\$(KBUILD_TARGET),darwin freebsd haiku linux)" >> $CNF
+      echo "if1of (\$(KBUILD_TARGET),darwin freebsd haiku linux os2)" >> $CNF
       cnf_append " SDK_VBOX_ZLIB_LIBS" "`strip_l "$LIBZ"`"
       cnf_append " SDK_VBOX_ZLIB_INCS" "$INCZ"
       echo "endif" >> $CNF
@@ -1093,6 +1254,14 @@
       log_failure "SDL framework not found"
       fail
     fi
+  elif [ "$OS" = "os2" -a -d "${LIBSDL2}" ]; then
+    FLGSDL="-I${LIBSDL2}/include/SDL"
+    INCSDL="$FLGSDL"
+    LIBSDL="-L${LIBSDL2}/lib -lSDL12"
+    LIBSDLMAIN=""
+    FLDSDL=""
+    WITH_X11=0
+    foundsdl=1
   else
     if which_wrapper sdl-config > /dev/null; then
       FLGSDL=`sdl-config --cflags`
@@ -1126,9 +1295,12 @@
     [ -n "$INCSDL" ] && I_INCSDL=`prefix_I "$INCSDL"`
     if test_compile "$LIBSDL $LIBSDLMAIN $I_INCSDL $FLDSDL" SDL SDL; then
       if test_execute; then
+        if [ -d "${LIBSDL2}" ]; then
+          cnf_append "PATH_SDK_LIBSDL"      "${LIBSDL2}"
+        fi
         cnf_append "LIB_SDK_LIBSDL_SDL"     "`strip_l "$LIBSDL"`"
-        cnf_append "SDK_LIBSDL_LIBPATH"     "`strip_L "$LIBSDL"`"
-        cnf_append "LIB_SDK_LIBSDL_SDLMAIN" "`strip_l "$LIBSDLMAIN"`"
+        cnf_append "# SDK_LIBSDL_LIBPATH"     "`strip_L "$LIBSDL"`"
+        cnf_append "# LIB_SDK_LIBSDL_SDLMAIN" "`strip_l "$LIBSDLMAIN"`"
         [ -n "$INCSDL" ] && cnf_append "SDK_LIBSDL_INCS"    "$INCSDL"
         [ -n "$FLDSDL" ] && cnf_append "SDK_LIBSDL_LDFLAGS" "$FLDSDL"
       fi
@@ -1513,11 +1685,12 @@
 extern "C" int main(void)
 {
   printf("found version %s", QT_VERSION_STR);
-#if QT_VERSION >= 0x040800
+//#if QT_VERSION >= 0x040800
+#if QT_VERSION >= 0x040700
   printf(", OK.\n");
   return 0;
 #else
-  printf(", expected version 4.8.0 or higher\n");
+  printf(", expected version 4.7.0 or higher\n");
   return 1;
 #endif
 }
@@ -1526,6 +1699,11 @@
         INCQT4="$q/include $q/include/QtCore"
         FLGQT4="-DQT_SHARED"
         I_INCQT4=`prefix_I "$INCQT4"`
+        LIBQT4="-L$q/lib -lQtCore4"
+        if test_compile "$LIBQT4 $LIBPTHREAD $I_INCQT4 $FLGQT4" qt4 qt4 nofatal; then
+          foundqt4=3
+          break;
+        fi
         LIBQT4="-L$q/lib -lQtCoreVBox"
         if test_compile "$LIBQT4 $LIBPTHREAD $I_INCQT4 $FLGQT4" qt4 qt4 nofatal; then
           foundqt4=2
@@ -1546,11 +1724,13 @@
 extern "C" int main(void)
 {
   printf("found version %s", QT_VERSION_STR);
-#if QT_VERSION >= 0x040800
+//#if QT_VERSION >= 0x040800
+#if QT_VERSION >= 0x040700
   printf(", OK.\n");
   return 0;
 #else
-  printf(", expected version 4.8.0 or higher\n");
+  //printf(", expected version 4.8.0 or higher\n");
+  printf(", expected version 4.7.0 or higher\n");
   return 1;
 #endif
 }
@@ -1769,52 +1949,86 @@
 #
 check_kbuild()
 {
-  test_header kBuild
-  if which_wrapper "$KBUILDDIR/bin/$OS.$BUILD_MACHINE/kmk" > /dev/null; then
-    KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.$BUILD_MACHINE"
+    test_header kBuild
+    # a current working directory
+    wd=`pwd`
+
+    if which_wrapper "$KBUILDDIR/bin/$OS.$BUILD_MACHINE/kmk" > /dev/null; then
+      # binaries in a subdirectory of sources
+      KBUILDDIR_BIN="$KBUILDDIR/bin/${OS}.${BUILD_MACHINE}"
+    elif check_avail "kmk" KBUILDDIR really; then
+      # a KBUILDDIR="/usr/share/kbuild" case, not `pwd`/kBuild
+      KBUILDDIR="/usr/share/kbuild"
+      # binaries in /usr/bin
+      KBUILDDIR_BIN="/usr/bin"
+    else
+      fail
+    fi
+
     echo "PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
     echo "export PATH_KBUILD" >> $ENV
     echo "PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
     echo "export PATH_DEVTOOLS" >> $ENV
-    echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
-    echo "export PATH_KBUILD_BIN" >> $ENV
-    echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
-    if [ "$OS" = "solaris" ]; then
+
+    KBUILD_SED="${KBUILDDIR_BIN}/kmk_sed"
+
+    if [ "$OS" = "os2" ]; then
+      echo "path_kbuild_bin=`echo \"\${KBUILDDIR_BIN}\" | sed -e 's,\/,\\\\\\\\,g'`" >> $ENV
+      echo "PATH_KBUILD_BIN=\"\${path_kbuild_bin}\"" >> $ENV
+      echo "export PATH_KBUILD_BIN" >> $ENV
+      path_dev_bin_x=`echo "${DEVDIR}/${OS}.${BUILD_MACHINE}/bin" | sed -e 's,\/,\\\\\\\\,g'`
+      echo "path_dev_bin=\"${path_dev_bin_x}\"" >> $ENV
+      path_out_dir_x=`echo "${wd}/out/${OS}.${BUILD_MACHINE}/${BUILD_TYPE}" | sed -e 's,\/,\\\\\\\\,g'`
+      echo "path_out_dir=\"${path_out_dir_x}\"" >> $ENV
+      path_out_bin_x=`echo "${path_out_dir_x}/bin" | sed -e 's,\/,\\\\\\\\,g'`
+      echo "path_out_bin=\"${path_out_bin_x}\"" >> $ENV
+      path_bin_x=`echo "${UNIXROOT}/usr/bin" | sed -e 's,\/,\\\\\\\\,g'`
+      echo "path_bin=\"${path_bin_x}\"" >> $ENV
+      path_gcc_bin_x=`echo "${GCC_DIR}/usr/i386-pc-os2-emx/bin;${GCC_DIR}/usr/bin" | sed -e 's,\/,\\\\\\\\,g'`
+      echo "path_gcc_bin=\"${path_gcc_bin_x}\"" >> $ENV
+    else
+      echo "path_kbuild_bin=`echo \"\${KBUILDDIR_BIN}\"`" >> $ENV
+      echo "PATH_KBUILD_BIN=\"\${path_kbuild_bin}\"" >> $ENV
+      echo "export PATH_KBUILD_BIN" >> $ENV
+      echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
+    fi
+
+    # PATH setting
+    if [ "$OS" = "os2" ]; then
+      echo "echo \"\$PATH\" | sed -e 's,\\\\\\\\,/,g' | grep -q \"\$path_bin\" || PATH=\"\$path_bin;\$PATH\"" >> $ENV
+      echo "echo \"\$PATH\" | sed -e 's,\\\\\\\\,/,g' | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin;\$PATH\"" >> $ENV
+      echo "echo \"\$PATH\" | sed -e 's,\\\\\\\\,/,g' | grep -q \"\$path_gcc_bin\" || PATH=\"\$path_gcc_bin;\$PATH\"" >> $ENV
+      echo "echo \"\$PATH\" | sed -e 's,\\\\\\\\,/,g' | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin;\$PATH\"" >> $ENV
+      echo "echo \"\$PATH\" | sed -e 's,\\\\\\\\,/,g' | grep -q \"\$path_out_bin\" || PATH=\"\$path_out_bin;\$PATH\"" >> $ENV
+      echo "export PATH" >> $ENV
+      echo "unset path_dev_bin_x path_out_bin_x path_out_dir_x \
+                path_kbuild_bin path_dev_bin path_out_bin path_out_dir" >> $ENV
+    elif [ "$OS" = "solaris" ]; then
       # Because of sh being non-default shell in Solaris we need to export PATH again when
       # sourcing env.sh. Simply exporting from ./configure does not export PATH correctly.
       echo "PATH=\"$ORGPATH\"" >> $ENV
       echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
       echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
-    else
+      echo "export PATH" >> $ENV
+      echo "unset path_kbuild_bin path_dev_bin" >> $ENV
+    elif [ "$OS.$BUILD_MACHINE" = "darwin.amd64" ]; then
+      # Currently there are no amd64 kBuild bins. So use the x86 variant in any case.
+      KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.x86"
+      echo "PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
+      echo "export PATH_KBUILD" >> $ENV
+      echo "PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
+      echo "export PATH_DEVTOOLS" >> $ENV
+      echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.x86\"" >> $ENV
+      echo "PATH_KBUILD_BIN=\"\$path_kbuild_bin\"" >> $ENV
+      echo "export PATH_KBUILD_BIN" >> $ENV
+      echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
       echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
       echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
+      echo "export PATH" >> $ENV
+      echo "unset path_kbuild_bin path_dev_bin" >> $ENV
+      KBUILD_SED="$KBUILDDIR_BIN/kmk_sed"
     fi
-    echo "export PATH" >> $ENV
-    echo "unset path_kbuild_bin path_dev_bin" >> $ENV
-    KBUILD_SED="$KBUILDDIR_BIN/kmk_sed"
-  elif [ "$OS.$BUILD_MACHINE" = "darwin.amd64" ]; then
-    # Currently there are no amd64 kBuild bins. So use the x86 variant in any case.
-    KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.x86"
-    echo "PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
-    echo "export PATH_KBUILD" >> $ENV
-    echo "PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
-    echo "export PATH_DEVTOOLS" >> $ENV
-    echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.x86\"" >> $ENV
-    echo "PATH_KBUILD_BIN=\"\$path_kbuild_bin\"" >> $ENV
-    echo "export PATH_KBUILD_BIN" >> $ENV
-    echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
-    echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
-    echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
-    echo "export PATH" >> $ENV
-    echo "unset path_kbuild_bin path_dev_bin" >> $ENV
-    KBUILD_SED="$KBUILDDIR_BIN/kmk_sed"
-  elif check_avail "kmk" KBUILDDIR really; then
-    # check for installed kBuild
-    KBUILD_SED="`which_wrapper kmk_sed`"
-  else
-    fail
-  fi
-  log_success "found"
+    log_success "found"
 }
 
 
@@ -1949,8 +2163,13 @@
         echo "compiling the following source file:" >> $LOG
         cat $ODIR.tmp_src.cc >> $LOG
         echo "using the following command line:" >> $LOG
-        echo "$CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so" >> $LOG
-        $CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so >> $LOG 2>&1
+        if [ "$OS" = "os2" ]; then
+          echo "$CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc $CXX_FLAGS -I$p/include/$d $p/$b/${d}_dll.lib" >> $LOG
+          $CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc $CXX_FLAGS -I$p/include/$d $p/$b/${d}_dll.lib >> $LOG 2>&1
+        else
+          echo "$CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc $CXX_FLAGS -I$p/include/$d $p/$b/lib$d.so" >> $LOG
+          $CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc $CXX_FLAGS -I$p/include/$d $p/$b/lib$d.so >> $LOG 2>&1
+        fi
         if [ $? -eq 0 ]; then
           found=1
           break
@@ -1964,7 +2183,11 @@
     if test_execute; then
       cnf_append "VBOX_WITH_PYTHON"     "1"
       cnf_append "VBOX_PATH_PYTHON_INC" "$p/include/$d"
-      cnf_append "VBOX_LIB_PYTHON"      "$p/$b/lib$d.so"
+      if [ "$OS" = "os2" ]; then
+        cnf_append "VBOX_LIB_PYTHON"      "$p/$b/${d}_dll.lib"
+      else
+        cnf_append "VBOX_LIB_PYTHON"      "$p/$b/lib$d.so"
+      fi
     else
       log_failure "Python not working"
       fail
