Module Name:    xsrc
Committed By:   mrg
Date:           Wed Jul 22 08:36:10 UTC 2015

Modified Files:
        xsrc/external/mit/xinit/dist: startx.cpp xinit.c xinitrc.cpp
        xsrc/external/mit/xinput/dist/src: xinput.c
        xsrc/external/mit/xkbcomp/dist: utils.h
Added Files:
        xsrc/external/mit/xfsinfo/dist: compile
Removed Files:
        xsrc/external/mit/xkbevd/dist: xkbevd.man

Log Message:
merge xfsinfo 1.0.5, xinit 1.3.4, xinput 1.6.1 xkbcomp 1.3.0 and xkbevd 1.1.4.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.3 xsrc/external/mit/xfsinfo/dist/compile
cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/xinit/dist/startx.cpp
cvs rdiff -u -r1.5 -r1.6 xsrc/external/mit/xinit/dist/xinit.c
cvs rdiff -u -r1.3 -r1.4 xsrc/external/mit/xinit/dist/xinitrc.cpp
cvs rdiff -u -r1.3 -r1.4 xsrc/external/mit/xinput/dist/src/xinput.c
cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/xkbcomp/dist/utils.h
cvs rdiff -u -r1.1.1.2 -r0 xsrc/external/mit/xkbevd/dist/xkbevd.man

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xinit/dist/startx.cpp
diff -u xsrc/external/mit/xinit/dist/startx.cpp:1.4 xsrc/external/mit/xinit/dist/startx.cpp:1.5
--- xsrc/external/mit/xinit/dist/startx.cpp:1.4	Mon Mar 17 09:43:11 2014
+++ xsrc/external/mit/xinit/dist/startx.cpp	Wed Jul 22 08:36:10 2015
@@ -14,7 +14,7 @@ XCOMM
 unset DBUS_SESSION_BUS_ADDRESS
 unset SESSION_MANAGER
 
-#if defined(__SCO__) || defined(__UNIXWARE__) || defined(__APPLE__)
+#ifdef __APPLE__
 
 XCOMM Check for /usr/bin/X11 and BINDIR in the path, if not add them.
 XCOMM This allows startx to be placed in a place like /usr/bin or /usr/local/bin
@@ -33,11 +33,7 @@ case $PATH in
 esac
 
 XCOMM Now the "old" compiled path
-#ifdef __APPLE__
 oldbindir=/usr/X11R6/bin
-#else
-oldbindir=/usr/bin/X11
-#endif
 
 if [ -d "$oldbindir" ] ; then
     case $PATH in
@@ -51,24 +47,8 @@ XCOMM so export the new PATH just in cas
 export PATH
 #endif
 
-#if defined(__SCO__) || defined(__UNIXWARE__)
-XCOMM Set up the XMERGE env var so that dos merge is happy under X
-
-if [ -f /usr/lib/merge/xmergeset.sh ]; then
-	. /usr/lib/merge/xmergeset.sh
-elif [ -f /usr/lib/merge/console.disp ]; then
-	XMERGE=`cat /usr/lib/merge/console.disp`
-	export XMERGE
-fi
-
-userclientrc=$HOME/.startxrc
-sysclientrc=LIBDIR/sys.startxrc
-scouserclientrc=$HOME/.xinitrc
-scosysclientrc=XINITDIR/xinitrc
-#else
 userclientrc=$HOME/.xinitrc
 sysclientrc=XINITDIR/xinitrc
-#endif
 
 userserverrc=$HOME/.xserverrc
 sysserverrc=XINITDIR/xserverrc
@@ -79,6 +59,7 @@ defaultserverargs="-noretro"
 defaultdisplay=":0"
 clientargs=""
 serverargs=""
+vtarg=""
 
 #ifdef __APPLE__
 
@@ -145,21 +126,6 @@ done
 defaultdisplay=":$d"
 unset d
 
-#if defined(__SCO__) || defined(__UNIXWARE__)
-
-XCOMM SCO -t option: do not start an X server
-case $1 in
-  -t)   if [ -n "$DISPLAY" ]; then
-                REMOTE_SERVER=TRUE
-                shift
-        else
-                echo "DISPLAY environment variable not set"
-                exit 1
-        fi
-        ;;
-esac
-#endif
-
 whoseargs="client"
 while [ x"$1" != x ]; do
     case "$1" in
@@ -209,12 +175,6 @@ if [ x"$client" = x ]; then
             client=$userclientrc
         elif [ -f "$sysclientrc" ]; then
             client=$sysclientrc
-#if defined(__SCO__) || defined(__UNIXWARE__)
-        elif [ -f "$scouserclientrc" ]; then
-            client=$scouserclientrc
-        elif [ -f "$scosysclientrc" ]; then
-            client=$scosysclientrc
-#endif
         fi
     fi
 fi
@@ -228,6 +188,17 @@ XCOMM process server arguments
 if [ x"$server" = x ]; then
     server=$defaultserver
 
+#ifdef __linux__
+    XCOMM When starting the defaultserver start X on the current tty to avoid
+    XCOMM the startx session being seen as inactive:
+    XCOMM "https://bugzilla.redhat.com/show_bug.cgi?id=806491";
+    tty=$(tty)
+    if expr match "$tty" '^/dev/tty[0-9]\+$' > /dev/null; then
+        tty_num=$(echo "$tty" | grep -oE '[0-9]+$')
+        vtarg="vt$tty_num"
+    fi
+#endif
+
     XCOMM For compatibility reasons, only use xserverrc if there were no server command line arguments
     if [ x"$serverargs" = x -a x"$display" = x ]; then
 	if [ -f "$userserverrc" ]; then
@@ -243,6 +214,17 @@ if [ x"$serverargs" = x ]; then
     serverargs=$defaultserverargs
 fi
 
+XCOMM if no vt is specified add vtarg (which may be empty)
+have_vtarg="no"
+for i in $serverargs; do
+    if expr match "$i" '^vt[0-9]\+$' > /dev/null; then
+        have_vtarg="yes"
+    fi
+done
+if [ "$have_vtarg" = "no" ]; then
+    serverargs="$serverargs $vtarg"
+fi
+
 XCOMM if no display, use default
 if [ x"$display" = x ]; then
     display=$defaultdisplay
@@ -319,21 +301,11 @@ EOF
     done
 fi
 
-#if defined(__SCO__) || defined(__UNIXWARE__)
-if [ "$REMOTE_SERVER" = "TRUE" ]; then
-        exec SHELL_CMD ${client}
-else
-        XINIT "$client" $clientargs -- "$server" $display $serverargs
-fi
-#else
-
 #if defined(__APPLE__) || defined(__CYGWIN__)
 eval XINIT \"$client\" $clientargs -- \"$server\" $display $serverargs
 #else
 XINIT "$client" $clientargs -- "$server" $display $serverargs
 #endif
-
-#endif
 retval=$?
 
 if [ x"$enable_xauth" = x1 ] ; then

Index: xsrc/external/mit/xinit/dist/xinit.c
diff -u xsrc/external/mit/xinit/dist/xinit.c:1.5 xsrc/external/mit/xinit/dist/xinit.c:1.6
--- xsrc/external/mit/xinit/dist/xinit.c:1.5	Mon Mar 17 09:43:11 2014
+++ xsrc/external/mit/xinit/dist/xinit.c	Wed Jul 22 08:36:10 2015
@@ -390,7 +390,7 @@ processTimeout(int timeout, const char *
 }
 
 static pid_t
-startServer(char *server[])
+startServer(char *server_argv[])
 {
     sigset_t mask, old;
     const char * const *cpp;
@@ -422,12 +422,12 @@ startServer(char *server[])
          * if client is xterm -L
          */
         setpgid(0,getpid());
-        Execute(server);
+        Execute(server_argv);
 
-        Error("unable to run server \"%s\"", server[0]);
+        Error("unable to run server \"%s\"", server_argv[0]);
 
         fprintf(stderr, "Use the -- option, or make sure that %s is in your path and\n", bindir);
-        fprintf(stderr, "that \"%s\" is a program or a link to the right type of server\n", server[0]);
+        fprintf(stderr, "that \"%s\" is a program or a link to the right type of server\n", server_argv[0]);
         fprintf(stderr, "for your display.  Possible server names include:\n\n");
         for (cpp = server_names; *cpp; cpp++)
             fprintf(stderr, "    %s\n", *cpp);
@@ -556,7 +556,7 @@ setWindowPath(void)
 }
 
 static pid_t
-startClient(char *client[])
+startClient(char *client_argv[])
 {
     clientpid = fork();
     if (clientpid == 0) {
@@ -568,8 +568,8 @@ startClient(char *client[])
             _exit(EXIT_FAILURE);
         }
         setpgid(0, getpid());
-        Execute(client);
-        Error("Unable to run program \"%s\"", client[0]);
+        Execute(client_argv);
+        Error("Unable to run program \"%s\"", client_argv[0]);
 
         fprintf(stderr, "Specify a program on the command line or make sure that %s\n", bindir);
         fprintf(stderr, "is in your path.\n\n");

Index: xsrc/external/mit/xinit/dist/xinitrc.cpp
diff -u xsrc/external/mit/xinit/dist/xinitrc.cpp:1.3 xsrc/external/mit/xinit/dist/xinitrc.cpp:1.4
--- xsrc/external/mit/xinit/dist/xinitrc.cpp:1.3	Tue Mar 18 22:26:50 2014
+++ xsrc/external/mit/xinit/dist/xinitrc.cpp	Wed Jul 22 08:36:10 2015
@@ -41,49 +41,6 @@ fi
 
 XCOMM start some nice programs
 
-#if defined(__SCO__) || defined(__UNIXWARE__)
-if [ -r /etc/default/xdesktops ]; then
-  . /etc/default/xdesktops
-fi
-
-if [ -r $HOME/.x11rc ]; then
-  . $HOME/.x11rc
-else
-  if [ -r /etc/default/X11 ]; then
-  . /etc/default/X11
-  fi
-fi
-
-#if defined(__SCO__)
-if [ -n "$XSESSION" ]; then
-  case "$XSESSION" in
-    [Yy][Ee][Ss])
-      [ -x /usr/bin/X11/scosession ] && exec /usr/bin/X11/scosession
-      ;;
-  esac
-fi
-
-if [ -n "$XDESKTOP" ]; then
-  exec `eval echo $"$XDESKTOP"`
-else
-  if [ -x /usr/bin/X11/pmwm -a -x /usr/bin/X11/scoterm ]; then
-    /usr/bin/X11/scoterm 2> /dev/null &
-    exec /usr/bin/X11/pmwm    2> /dev/null
-  fi
-fi
-#elif defined(__UNIXWARE__)
-if [ -n "$XDESKTOP" ]; then
-  exec `eval echo $"$XDESKTOP"`
-else
-  if [ -x /usr/X/bin/pmwm ]; then
-    exec /usr/X/bin/pmwm    2> /dev/null
-  fi
-fi
-#endif
-
-XCOMM This is the fallback case if nothing else is executed above
-#endif /* !defined(__SCO__)  && !defined(__UNIXWARE__) */
-
 if [ -d XINITDIR/xinitrc.d ] ; then
 	for f in XINITDIR/xinitrc.d/?*.sh ; do
 		[ -x "$f" ] && . "$f"

Index: xsrc/external/mit/xinput/dist/src/xinput.c
diff -u xsrc/external/mit/xinput/dist/src/xinput.c:1.3 xsrc/external/mit/xinput/dist/src/xinput.c:1.4
--- xsrc/external/mit/xinput/dist/src/xinput.c:1.3	Fri May 31 07:21:57 2013
+++ xsrc/external/mit/xinput/dist/src/xinput.c	Wed Jul 22 08:36:10 2015
@@ -101,7 +101,7 @@ static entry drivers[] =
       set_clientpointer
     },
     { "test-xi2",
-      "<device>",
+      "[--root] <device>",
       test_xi2,
     },
     { "map-to-output",
@@ -202,15 +202,26 @@ xinput_version(Display	*display)
     /* Announce our supported version so the server treats us correctly. */
     if (vers >= XI_2_Major)
     {
+        const char *forced_version;
         int maj = 2,
             min = 0;
 
-#if HAVE_XI21
-        min = 1;
-#elif HAVE_XI22
+#if HAVE_XI22
         min = 2;
+#elif HAVE_XI21
+        min = 1;
 #endif
 
+        forced_version = getenv("XINPUT_XI2_VERSION");
+        if (forced_version) {
+            if (sscanf(forced_version, "%d.%d", &maj, &min) != 2) {
+                fprintf(stderr, "Invalid format of XINPUT_XI2_VERSION "
+                                "environment variable. Need major.minor\n");
+                exit(1);
+            }
+            printf("Overriding XI2 version to: %d.%d\n", maj, min);
+        }
+
         XIQueryVersion(display, &maj, &min);
     }
 #endif

Index: xsrc/external/mit/xkbcomp/dist/utils.h
diff -u xsrc/external/mit/xkbcomp/dist/utils.h:1.4 xsrc/external/mit/xkbcomp/dist/utils.h:1.5
--- xsrc/external/mit/xkbcomp/dist/utils.h:1.4	Fri May 31 23:23:10 2013
+++ xsrc/external/mit/xkbcomp/dist/utils.h	Wed Jul 22 08:36:10 2015
@@ -219,15 +219,6 @@ uInformation(const char * /* s */ , ...
 
 /***====================================================================***/
 
-#ifdef	ASSERTIONS_ON
-#define	uASSERT(where,why) \
-	{if (!(why)) uFatalError("assertion botched in %s ( why )\n",where);}
-#else
-#define	uASSERT(where,why)
-#endif
-
-/***====================================================================***/
-
 #ifndef DEBUG_VAR
 #define	DEBUG_VAR	debugFlags
 #endif
@@ -249,7 +240,7 @@ extern
      extern int uDebugIndentSize;
 #define	uDebugIndent(l)		(uDebugIndentLevel+=(l))
 #define	uDebugOutdent(l)	(uDebugIndentLevel-=(l))
-#ifdef DEBUG_ON
+#ifdef DEBUG
 #define	uDEBUG(f,s)		{ if (DEBUG_VAR&(f)) uDebug(s);}
 #define	uDEBUG1(f,s,a)		{ if (DEBUG_VAR&(f)) uDebug(s,a);}
 #define	uDEBUG2(f,s,a,b)	{ if (DEBUG_VAR&(f)) uDebug(s,a,b);}
@@ -277,64 +268,4 @@ extern
 #define	uDEBUG_NOI5(f,s,a,b,c,d,e)
 #endif
 
-     extern Boolean uSetEntryFile(char *name);
-     extern void uEntry(int /* l */ ,
-                        char * /* s  */ , ...
-    ) _X_ATTRIBUTE_PRINTF(2, 3);
-
-     extern void uExit(int l, char *rtVal);
-#ifdef ENTRY_TRACKING_ON
-#define	ENTRY_BIT	0x10
-#define	LOW_ENTRY_BIT	0x1000
-#define	ENTER	(DEBUG_VAR&ENTRY_BIT)
-#define	FLAG(fLag)	(DEBUG_VAR&(fLag))
-
-     extern int uEntryLevel;
-
-#define	uENTRY(s)			{ if (ENTER) uEntry(1,s);}
-#define	uENTRY1(s,a)			{ if (ENTER) uEntry(1,s,a);}
-#define	uENTRY2(s,a,b)			{ if (ENTER) uEntry(1,s,a,b);}
-#define	uENTRY3(s,a,b,c)		{ if (ENTER) uEntry(1,s,a,b,c);}
-#define	uENTRY4(s,a,b,c,d)		{ if (ENTER) uEntry(1,s,a,b,c,d);}
-#define	uENTRY5(s,a,b,c,d,e)		{ if (ENTER) uEntry(1,s,a,b,c,d,e);}
-#define	uENTRY6(s,a,b,c,d,e,f)		{ if (ENTER) uEntry(1,s,a,b,c,d,e,f);}
-#define	uENTRY7(s,a,b,c,d,e,f,g)	{ if (ENTER) uEntry(1,s,a,b,c,d,e,f,g);}
-#define	uRETURN(v)			{ if (ENTER) uEntryLevel--; return(v); }
-#define	uVOIDRETURN			{ if (ENTER) uEntryLevel--; return; }
-
-#define	uFLAG_ENTRY(w,s)		{ if (FLAG(w)) uEntry(0,s);}
-#define	uFLAG_ENTRY1(w,s,a)		{ if (FLAG(w)) uEntry(0,s,a);}
-#define	uFLAG_ENTRY2(w,s,a,b)		{ if (FLAG(w)) uEntry(0,s,a,b);}
-#define	uFLAG_ENTRY3(w,s,a,b,c)		{ if (FLAG(w)) uEntry(0,s,a,b,c);}
-#define	uFLAG_ENTRY4(w,s,a,b,c,d)	{ if (FLAG(w)) uEntry(0,s,a,b,c,d);}
-#define	uFLAG_ENTRY5(w,s,a,b,c,d,e)	{ if (FLAG(w)) uEntry(0,s,a,b,c,d,e);}
-#define	uFLAG_ENTRY6(w,s,a,b,c,d,e,f)	{ if (FLAG(w)) uEntry(0,s,a,b,c,d,e,f);}
-#define	uFLAG_ENTRY7(w,s,a,b,c,d,e,f,g)	{ if(FLAG(w))uEntry(0,s,a,b,c,d,e,f,g);}
-#define	uFLAG_RETURN(v)			{ return(v);}
-#define	uFLAG_VOIDRETURN		{ return; }
-#else
-#define	uENTRY(s)
-#define	uENTRY1(s,a)
-#define	uENTRY2(s,a1,a2)
-#define	uENTRY3(s,a1,a2,a3)
-#define	uENTRY4(s,a1,a2,a3,a4)
-#define	uENTRY5(s,a1,a2,a3,a4,a5)
-#define	uENTRY6(s,a1,a2,a3,a4,a5,a6)
-#define	uENTRY7(s,a1,a2,a3,a4,a5,a6,a7)
-#define	uRETURN(v)	{ return(v); }
-#define	uVOIDRETURN	{ return; }
-
-#define	uFLAG_ENTRY(f,s)
-#define	uFLAG_ENTRY1(f,s,a)
-#define	uFLAG_ENTRY2(f,s,a,b)
-#define	uFLAG_ENTRY3(f,s,a,b,c)
-#define	uFLAG_ENTRY4(f,s,a,b,c,d)
-#define	uFLAG_ENTRY5(f,s,a,b,c,d,e)
-#define	uFLAG_ENTRY6(f,s,a,b,c,d,e,g)
-#define	uFLAG_ENTRY7(f,s,a,b,c,d,e,g,h)
-#define	uFLAG_RETURN(v)			{ return(v);}
-#define	uFLAG_VOIDRETURN		{ return; }
-#endif
-
-
 #endif /* UTILS_H */

Added files:

Index: xsrc/external/mit/xfsinfo/dist/compile
diff -u /dev/null xsrc/external/mit/xfsinfo/dist/compile:1.3
--- /dev/null	Wed Jul 22 08:36:10 2015
+++ xsrc/external/mit/xfsinfo/dist/compile	Wed Jul 22 08:36:10 2015
@@ -0,0 +1,347 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand '-c -o'.
+
+scriptversion=2012-10-14.11; # UTC
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Written by Tom Tromey <tro...@cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-autom...@gnu.org> or send patches to
+# <automake-patc...@gnu.org>.
+
+nl='
+'
+
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent tools from complaining about whitespace usage.
+IFS=" ""	$nl"
+
+file_conv=
+
+# func_file_conv build_file lazy
+# Convert a $build file to $host form and store it in $file
+# Currently only supports Windows hosts. If the determined conversion
+# type is listed in (the comma separated) LAZY, no conversion will
+# take place.
+func_file_conv ()
+{
+  file=$1
+  case $file in
+    / | /[!/]*) # absolute file, and not a UNC file
+      if test -z "$file_conv"; then
+	# lazily determine how to convert abs files
+	case `uname -s` in
+	  MINGW*)
+	    file_conv=mingw
+	    ;;
+	  CYGWIN*)
+	    file_conv=cygwin
+	    ;;
+	  *)
+	    file_conv=wine
+	    ;;
+	esac
+      fi
+      case $file_conv/,$2, in
+	*,$file_conv,*)
+	  ;;
+	mingw/*)
+	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
+	  ;;
+	cygwin/*)
+	  file=`cygpath -m "$file" || echo "$file"`
+	  ;;
+	wine/*)
+	  file=`winepath -w "$file" || echo "$file"`
+	  ;;
+      esac
+      ;;
+  esac
+}
+
+# func_cl_dashL linkdir
+# Make cl look for libraries in LINKDIR
+func_cl_dashL ()
+{
+  func_file_conv "$1"
+  if test -z "$lib_path"; then
+    lib_path=$file
+  else
+    lib_path="$lib_path;$file"
+  fi
+  linker_opts="$linker_opts -LIBPATH:$file"
+}
+
+# func_cl_dashl library
+# Do a library search-path lookup for cl
+func_cl_dashl ()
+{
+  lib=$1
+  found=no
+  save_IFS=$IFS
+  IFS=';'
+  for dir in $lib_path $LIB
+  do
+    IFS=$save_IFS
+    if $shared && test -f "$dir/$lib.dll.lib"; then
+      found=yes
+      lib=$dir/$lib.dll.lib
+      break
+    fi
+    if test -f "$dir/$lib.lib"; then
+      found=yes
+      lib=$dir/$lib.lib
+      break
+    fi
+    if test -f "$dir/lib$lib.a"; then
+      found=yes
+      lib=$dir/lib$lib.a
+      break
+    fi
+  done
+  IFS=$save_IFS
+
+  if test "$found" != yes; then
+    lib=$lib.lib
+  fi
+}
+
+# func_cl_wrapper cl arg...
+# Adjust compile command to suit cl
+func_cl_wrapper ()
+{
+  # Assume a capable shell
+  lib_path=
+  shared=:
+  linker_opts=
+  for arg
+  do
+    if test -n "$eat"; then
+      eat=
+    else
+      case $1 in
+	-o)
+	  # configure might choose to run compile as 'compile cc -o foo foo.c'.
+	  eat=1
+	  case $2 in
+	    *.o | *.[oO][bB][jJ])
+	      func_file_conv "$2"
+	      set x "$@" -Fo"$file"
+	      shift
+	      ;;
+	    *)
+	      func_file_conv "$2"
+	      set x "$@" -Fe"$file"
+	      shift
+	      ;;
+	  esac
+	  ;;
+	-I)
+	  eat=1
+	  func_file_conv "$2" mingw
+	  set x "$@" -I"$file"
+	  shift
+	  ;;
+	-I*)
+	  func_file_conv "${1#-I}" mingw
+	  set x "$@" -I"$file"
+	  shift
+	  ;;
+	-l)
+	  eat=1
+	  func_cl_dashl "$2"
+	  set x "$@" "$lib"
+	  shift
+	  ;;
+	-l*)
+	  func_cl_dashl "${1#-l}"
+	  set x "$@" "$lib"
+	  shift
+	  ;;
+	-L)
+	  eat=1
+	  func_cl_dashL "$2"
+	  ;;
+	-L*)
+	  func_cl_dashL "${1#-L}"
+	  ;;
+	-static)
+	  shared=false
+	  ;;
+	-Wl,*)
+	  arg=${1#-Wl,}
+	  save_ifs="$IFS"; IFS=','
+	  for flag in $arg; do
+	    IFS="$save_ifs"
+	    linker_opts="$linker_opts $flag"
+	  done
+	  IFS="$save_ifs"
+	  ;;
+	-Xlinker)
+	  eat=1
+	  linker_opts="$linker_opts $2"
+	  ;;
+	-*)
+	  set x "$@" "$1"
+	  shift
+	  ;;
+	*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
+	  func_file_conv "$1"
+	  set x "$@" -Tp"$file"
+	  shift
+	  ;;
+	*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
+	  func_file_conv "$1" mingw
+	  set x "$@" "$file"
+	  shift
+	  ;;
+	*)
+	  set x "$@" "$1"
+	  shift
+	  ;;
+      esac
+    fi
+    shift
+  done
+  if test -n "$linker_opts"; then
+    linker_opts="-link$linker_opts"
+  fi
+  exec "$@" $linker_opts
+  exit 1
+}
+
+eat=
+
+case $1 in
+  '')
+     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand '-c -o'.
+Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file 'INSTALL'.
+
+Report bugs to <bug-autom...@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "compile $scriptversion"
+    exit $?
+    ;;
+  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+    func_cl_wrapper "$@"      # Doesn't return...
+    ;;
+esac
+
+ofile=
+cfile=
+
+for arg
+do
+  if test -n "$eat"; then
+    eat=
+  else
+    case $1 in
+      -o)
+	# configure might choose to run compile as 'compile cc -o foo foo.c'.
+	# So we strip '-o arg' only if arg is an object.
+	eat=1
+	case $2 in
+	  *.o | *.obj)
+	    ofile=$2
+	    ;;
+	  *)
+	    set x "$@" -o "$2"
+	    shift
+	    ;;
+	esac
+	;;
+      *.c)
+	cfile=$1
+	set x "$@" "$1"
+	shift
+	;;
+      *)
+	set x "$@" "$1"
+	shift
+	;;
+    esac
+  fi
+  shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+  # If no '-o' option was seen then we might have been invoked from a
+  # pattern rule where we don't need one.  That is ok -- this is a
+  # normal compilation that the losing compiler can handle.  If no
+  # '.c' file was seen then we are probably linking.  That is also
+  # ok.
+  exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use '[/\\:.-]' here to ensure that we don't use the same name
+# that we are using for the .o file.  Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
+while true; do
+  if mkdir "$lockdir" >/dev/null 2>&1; then
+    break
+  fi
+  sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+  test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+  test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:

Reply via email to