diff --git a/configure b/configure
index a59c9b2..c85dc5d 100755
--- a/configure
+++ b/configure
@@ -77,8 +77,8 @@ if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
 # The user is always right.
 if ${PATH_SEPARATOR+false} :; then
   PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+  (PATH='/bin;/bin;/@unixroot/usr/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin:/@unixroot/usr/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
       PATH_SEPARATOR=';'
   }
 fi
@@ -1179,7 +1179,7 @@ do
   esac
   # Be sure to have absolute directory names.
   case $ac_val in
-    [\\/$]* | ?:[\\/]* )  continue;;
+    [\\/$]* | ?:[\\/]* | ?: )  continue;;
     NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
   esac
   as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
@@ -2169,6 +2169,58 @@ See 'config.log' for more details" "$LINENO" 5; }
   fi
 done
 
+# Backslashes into forward slashes:
+# The following OS/2 specific code is performed AFTER config.site
+# has been loaded to allow users to change their environment there.
+# This strange code is necessary to deal with handling of backslashes by ksh.
+
+if test "$ac_emxsupport" != "no" -a "$ac_emxsupport" != "NO"; then
+  ac_save_IFS="$IFS"
+  IFS="\\"
+  ac_TEMP_PATH=
+  for ac_dir in $PATH; do
+    IFS=$ac_save_IFS
+    if test -z "$ac_TEMP_PATH"; then
+      ac_TEMP_PATH="$ac_dir"
+    else
+      ac_TEMP_PATH="$ac_TEMP_PATH/$ac_dir"
+    fi
+  done
+  export PATH="$ac_TEMP_PATH"
+  unset ac_TEMP_PATH
+
+  # Also, make sure that unix-like entries in PATH contain /@unixroot instead of
+  # hardcoded absolute paths to avoid these hardcoded paths in generated files.
+  if test -n "$UNIXROOT"; then
+    ac_save_IFS="$IFS"
+    ac_TEMP_UNIXROOT=`echo "$UNIXROOT" | tr [:upper:] [:lower:]`
+    IFS="$PATH_SEPARATOR"
+    ac_TEMP_PATH=
+    for ac_dir in `echo "$PATH" | tr [:upper:] [:lower:]`; do
+      IFS=$ac_save_IFS
+      case "$ac_dir" in
+        $ac_TEMP_UNIXROOT/usr/*) ac_dir="/@unixroot${ac_dir#$ac_TEMP_UNIXROOT}" ;;
+      esac
+      if test -z "$ac_TEMP_PATH"; then
+        ac_TEMP_PATH="$ac_dir"
+      else
+        ac_TEMP_PATH="$ac_TEMP_PATH$PATH_SEPARATOR$ac_dir"
+      fi
+    done
+    unset ac_TEMP_UNIXROOT
+    export PATH="$ac_TEMP_PATH"
+    unset ac_TEMP_PATH
+  fi
+fi
+
+# set ac_executable_extensions!
+if test "$ac_executable_extensions" = ""; then
+  if (sh -c : && sh.exe -c :) >/dev/null 2>/dev/null; then
+    ac_executable_extensions=".exe"
+    export ac_executable_extensions
+  fi
+fi
+
 if test -r "$cache_file"; then
   # Some versions of bash will fail to source /dev/null (special files
   # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
@@ -2585,7 +2637,7 @@ fi
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_link='eval $CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
@@ -2812,7 +2864,7 @@ fi
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_link='eval $CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
@@ -3594,7 +3646,7 @@ else case e in #(
   e) ac_save_c_werror_flag=$ac_c_werror_flag
    ac_c_werror_flag=yes
    ac_cv_prog_cc_g=no
-   CFLAGS="-g"
+            CFLAGS="$CFLAGS -g"
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -3822,7 +3874,7 @@ fi
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_link='eval $CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
@@ -4369,7 +4421,7 @@ printf "%s\n" "$as_me: CHECKS for programs" >&6;}
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_link='eval $CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 if test -n "$ac_tool_prefix"; then
   for ac_prog in cc gcc
@@ -4566,7 +4618,7 @@ else case e in #(
   e) ac_save_c_werror_flag=$ac_c_werror_flag
    ac_c_werror_flag=yes
    ac_cv_prog_cc_g=no
-   CFLAGS="-g"
+            CFLAGS="$CFLAGS -g"
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -4794,7 +4846,7 @@ fi
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_link='eval $CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
@@ -5013,7 +5065,7 @@ fi
 config_appended_defs="$config_appended_defs${newline}CC_LD_DYNPATH=${CC_LD_DYNPATH}"
 #AC_PROG_INSTALL		# needs install-sh or install.sh in sources
 if test -n "$ac_tool_prefix"; then
-  for ac_prog in gar ar
+  for ac_prog in emxomfar gar ar
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
@@ -5063,7 +5115,7 @@ fi
 fi
 if test -z "$AR"; then
   ac_ct_AR=$AR
-  for ac_prog in gar ar
+  for ac_prog in emxomfar gar ar
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -6769,7 +6821,7 @@ config_appended_defs="$config_appended_defs${newline}NO_IPV6=${NO_IPV6}"
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_link='eval $CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
 printf %s "checking how to run the C preprocessor... " >&6; }
@@ -6901,7 +6953,7 @@ fi
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_link='eval $CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
@@ -9011,8 +9063,8 @@ if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
 # The user is always right.
 if ${PATH_SEPARATOR+false} :; then
   PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+  (PATH='/bin;/bin;/@unixroot/usr/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin:/@unixroot/usr/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
       PATH_SEPARATOR=';'
   }
 fi
diff --git a/path.h b/path.h
index 9fd5d00..4b080ac 100644
--- a/path.h
+++ b/path.h
@@ -54,15 +54,15 @@ const char *repo_common_path_replace(const struct repository *repo,
  */
 char *repo_git_path(struct repository *repo,
 		    const char *fmt, ...)
-	__attribute__((__format_ (__printf__, 2, 3)));
+	__attribute__((__format__ (__printf__, 2, 3)));
 const char *repo_git_path_append(struct repository *repo,
 				 struct strbuf *sb,
 				 const char *fmt, ...)
-	__attribute__((__format_ (__printf__, 3, 4)));
+	__attribute__((__format__ (__printf__, 3, 4)));
 const char *repo_git_path_replace(struct repository *repo,
 				  struct strbuf *sb,
 				  const char *fmt, ...)
-	__attribute__((__format_ (__printf__, 3, 4)));
+	__attribute__((__format__ (__printf__, 3, 4)));
 
 /*
  * Similar to repo_git_path() but can produce paths for a specified
@@ -72,7 +72,7 @@ const char *repo_git_path_replace(struct repository *repo,
 const char *worktree_git_path(struct repository *r,
 			      const struct worktree *wt,
 			      const char *fmt, ...)
-	__attribute__((__format_ (__printf__, 3, 4)));
+	__attribute__((__format__ (__printf__, 3, 4)));
 
 /*
  * The `repo_worktree_path` family of functions will construct a path into a
diff --git a/ref-filter.c b/ref-filter.c
index 7a27463..de83651 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -34,6 +34,10 @@
 #include "worktree.h"
 #include "hashmap.h"
 
+#ifdef __OS2__
+#undef O_SIZE
+#endif
+
 static struct ref_msg {
 	const char *gone;
 	const char *ahead;
diff --git a/run-command.c b/run-command.c
index fde970d..e855597 100644
--- a/run-command.c
+++ b/run-command.c
@@ -224,7 +224,6 @@ static char *locate_in_PATH(const char *file)
 	strbuf_release(&buf);
 	return NULL;
 }
-#endif
 
 int exists_in_PATH(const char *command)
 {
diff --git a/sane-ctype.h b/sane-ctype.h
index cbea1b2..c7c1629 100644
--- a/sane-ctype.h
+++ b/sane-ctype.h
@@ -1,6 +1,8 @@
 #ifndef SANE_CTYPE_H
 #define SANE_CTYPE_H
 
+#include <ctype.h>
+
 /* Sane ctype - no locale, and works with signed chars */
 #undef isascii
 #undef isspace
