Module Name: xsrc
Committed By: mrg
Date: Wed Apr 27 07:23:01 UTC 2016
Modified Files:
xsrc/external/mit/xkbcomp/dist: expr.c
xsrc/external/mit/xrandr/dist: xrandr.c
Added Files:
xsrc/external/mit/xrandr/dist: compile
Log Message:
merge xkbcomp 1.3.1 and xrandr 1.5.0.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/xkbcomp/dist/expr.c
cvs rdiff -u -r0 -r1.3 xsrc/external/mit/xrandr/dist/compile
cvs rdiff -u -r1.12 -r1.13 xsrc/external/mit/xrandr/dist/xrandr.c
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/xkbcomp/dist/expr.c
diff -u xsrc/external/mit/xkbcomp/dist/expr.c:1.2 xsrc/external/mit/xkbcomp/dist/expr.c:1.3
--- xsrc/external/mit/xkbcomp/dist/expr.c:1.2 Wed Jul 22 08:39:03 2015
+++ xsrc/external/mit/xkbcomp/dist/expr.c Wed Apr 27 07:23:01 2016
@@ -729,9 +729,8 @@ ExprResolveString(ExprDef * expr,
val_rtrn->str = XkbAtomGetString(NULL, expr->value.str);
if (val_rtrn->str == NULL)
{
- static char empty_char = '\0';
- char *empty = &empty_char;
- val_rtrn->str = empty;
+ static char empty_char = '\0';
+ val_rtrn->str = &empty_char;
}
return True;
case ExprIdent:
Index: xsrc/external/mit/xrandr/dist/xrandr.c
diff -u xsrc/external/mit/xrandr/dist/xrandr.c:1.12 xsrc/external/mit/xrandr/dist/xrandr.c:1.13
--- xsrc/external/mit/xrandr/dist/xrandr.c:1.12 Wed Jul 22 08:47:22 2015
+++ xsrc/external/mit/xrandr/dist/xrandr.c Wed Apr 27 07:23:01 2016
@@ -153,7 +153,11 @@ usage(void)
" --delmode <output> <name>\n"
" --listproviders\n"
" --setprovideroutputsource <prov-xid> <source-xid>\n"
- " --setprovideroffloadsink <prov-xid> <sink-xid>\n");
+ " --setprovideroffloadsink <prov-xid> <sink-xid>\n"
+ " --listmonitors\n"
+ " --listactivemonitors\n"
+ " --setmonitor <name> {auto|<w>/<mmw>x<h>/<mmh>+<x>+<y>} {none|<output>,<output>,...}\n"
+ " --delmonitor <name>\n");
}
static void _X_NORETURN _X_ATTRIBUTE_PRINTF(1,2)
@@ -304,6 +308,8 @@ typedef struct _transform transform_t;
typedef struct _umode umode_t;
typedef struct _output_prop output_prop_t;
typedef struct _provider provider_t;
+typedef struct _monitors monitors_t;
+typedef struct _umonitor umonitor_t;
struct _transform {
XTransform transform;
@@ -397,6 +403,22 @@ struct _provider {
XRRProviderInfo *info;
};
+struct _monitors {
+ int n;
+ XRRMonitorInfo *monitors;
+};
+
+struct _umonitor {
+ struct _umonitor *next;
+ char *name;
+ Bool set;
+ Bool primary;
+ int x, y, width, height;
+ int mmwidth, mmheight;
+ int noutput;
+ name_t *outputs;
+};
+
static const char *connection[3] = {
"connected",
"disconnected",
@@ -431,7 +453,10 @@ static int minWidth, maxWidth, minHeight
static Bool has_1_2 = False;
static Bool has_1_3 = False;
static Bool has_1_4 = False;
+static Bool has_1_5 = False;
static name_t provider_name, output_source_provider_name, offload_sink_provider_name;
+static monitors_t *monitors;
+static umonitor_t *umonitors;
static int
mode_height (XRRModeInfo *mode_info, Rotation rotation)
@@ -541,7 +566,7 @@ mode_geometry (XRRModeInfo *mode_info, R
/* v refresh frequency in Hz */
static double
-mode_refresh (XRRModeInfo *mode_info)
+mode_refresh (const XRRModeInfo *mode_info)
{
double rate;
double vTotal = mode_info->vTotal;
@@ -567,7 +592,7 @@ mode_refresh (XRRModeInfo *mode_info)
/* h sync frequency in Hz */
static double
-mode_hsync (XRRModeInfo *mode_info)
+mode_hsync (const XRRModeInfo *mode_info)
{
double rate;
@@ -579,6 +604,30 @@ mode_hsync (XRRModeInfo *mode_info)
}
static void
+print_verbose_mode (const XRRModeInfo *mode, Bool current, Bool preferred)
+{
+ int f;
+
+ printf (" %s (0x%x) %6.3fMHz",
+ mode->name, (int)mode->id,
+ (double)mode->dotClock / 1000000.0);
+ for (f = 0; mode_flags[f].flag; f++)
+ if (mode->modeFlags & mode_flags[f].flag)
+ printf (" %s", mode_flags[f].string);
+ if (current)
+ printf (" *current");
+ if (preferred)
+ printf (" +preferred");
+ printf ("\n");
+ printf (" h: width %4d start %4d end %4d total %4d skew %4d clock %6.2fKHz\n",
+ mode->width, mode->hSyncStart, mode->hSyncEnd,
+ mode->hTotal, mode->hSkew, mode_hsync (mode) / 1000);
+ printf (" v: height %4d start %4d end %4d total %4d clock %6.2fHz\n",
+ mode->height, mode->vSyncStart, mode->vSyncEnd, mode->vTotal,
+ mode_refresh (mode));
+}
+
+static void
init_name (name_t *name)
{
name->kind = name_none;
@@ -2194,6 +2243,8 @@ static void
pick_crtcs (void)
{
output_t *output;
+ int saved_crtc_noutput[num_crtcs];
+ int n;
/*
* First try to match up newly enabled outputs with spare crtcs
@@ -2225,7 +2276,18 @@ pick_crtcs (void)
*/
for (output = all_outputs; output; output = output->next)
output->current_crtc_info = output->crtc_info;
+
+ /* Mark all CRTC as currently unused */
+ for (n = 0; n < num_crtcs; n++) {
+ saved_crtc_noutput[n] = crtcs[n].crtc_info->noutput;
+ crtcs[n].crtc_info->noutput = 0;
+ }
+
pick_crtcs_score (all_outputs);
+
+ for (n = 0; n < num_crtcs; n++)
+ crtcs[n].crtc_info->noutput = saved_crtc_noutput[n];
+
for (output = all_outputs; output; output = output->next)
{
if (output->mode_info && !output->crtc_info)
@@ -2262,12 +2324,24 @@ property_values_from_string(const char *
{
char *token, *tmp;
void *returned_bytes = NULL;
- int nitems = 0, bytes_per_item = format / 8;
+ int nitems = 0, bytes_per_item;
- if ((type != XA_INTEGER && type != XA_CARDINAL) ||
- (format != 8 && format != 16 && format != 32))
- {
+ if (type != XA_INTEGER && type != XA_CARDINAL)
return NULL;
+
+ /* compute memory needed for Xlib datatype (sigh) */
+ switch (format) {
+ case 8:
+ bytes_per_item = sizeof(char);
+ break;
+ case 16:
+ bytes_per_item = sizeof(short);
+ break;
+ case 32:
+ bytes_per_item = sizeof(long);
+ break;
+ default:
+ return NULL;
}
tmp = strdup (str);
@@ -2286,33 +2360,33 @@ property_values_from_string(const char *
if (type == XA_INTEGER && format == 8)
{
- int8_t *ptr = returned_bytes;
- ptr[nitems] = (int8_t) val;
+ signed char *ptr = returned_bytes;
+ ptr[nitems] = (char) val;
}
else if (type == XA_INTEGER && format == 16)
{
- int16_t *ptr = returned_bytes;
- ptr[nitems] = (int16_t) val;
+ short *ptr = returned_bytes;
+ ptr[nitems] = (short) val;
}
else if (type == XA_INTEGER && format == 32)
{
- int32_t *ptr = returned_bytes;
- ptr[nitems] = (int32_t) val;
+ long *ptr = returned_bytes;
+ ptr[nitems] = (long) val;
}
else if (type == XA_CARDINAL && format == 8)
{
- uint8_t *ptr = returned_bytes;
- ptr[nitems] = (uint8_t) val;
+ unsigned char *ptr = returned_bytes;
+ ptr[nitems] = (unsigned char) val;
}
else if (type == XA_CARDINAL && format == 16)
{
- uint16_t *ptr = returned_bytes;
- ptr[nitems] = (uint16_t) val;
+ unsigned short *ptr = returned_bytes;
+ ptr[nitems] = (unsigned short) val;
}
else if (type == XA_CARDINAL && format == 32)
{
- uint32_t *ptr = returned_bytes;
- ptr[nitems] = (uint32_t) val;
+ unsigned long *ptr = returned_bytes;
+ ptr[nitems] = (unsigned long) val;
}
else
{
@@ -2352,20 +2426,20 @@ print_output_property_value(int value_fo
{
if (value_format == 8)
{
- const int8_t *val = value_bytes;
- printf ("%" PRId8, *val);
+ const signed char *val = value_bytes;
+ printf ("%d", *val);
return;
}
if (value_format == 16)
{
- const int16_t *val = value_bytes;
- printf ("%" PRId16, *val);
+ const short *val = value_bytes;
+ printf ("%d", *val);
return;
}
if (value_format == 32)
{
- const int32_t *val = value_bytes;
- printf ("%" PRId32, *val);
+ const long *val = value_bytes;
+ printf ("%ld", *val);
return;
}
}
@@ -2374,20 +2448,20 @@ print_output_property_value(int value_fo
{
if (value_format == 8)
{
- const uint8_t *val = value_bytes;
- printf ("%" PRIu8, *val);
+ const unsigned char *val = value_bytes;
+ printf ("%u", *val);
return;
}
if (value_format == 16)
{
- const uint16_t *val = value_bytes;
- printf ("%" PRIu16, *val);
+ const unsigned short *val = value_bytes;
+ printf ("%u", *val);
return;
}
if (value_format == 32)
{
- const uint32_t *val = value_bytes;
- printf ("%" PRIu32, *val);
+ const unsigned long *val = value_bytes;
+ printf ("%lu", *val);
return;
}
}
@@ -2441,9 +2515,22 @@ print_output_property(const char *atom_n
int nitems,
const unsigned char *prop)
{
- int bytes_per_item = value_format / 8;
+ int bytes_per_item;
int k;
+ switch (value_format) {
+ case 8:
+ bytes_per_item = sizeof(char);
+ break;
+ case 16:
+ bytes_per_item = sizeof(short);
+ break;
+ case 32:
+ bytes_per_item = sizeof(long);
+ break;
+ default:
+ return;
+ }
/*
* Check for properties that need special formatting.
*/
@@ -2531,6 +2618,22 @@ find_provider (name_t *name)
exit (1);
}
+static void
+get_monitors(Bool get_active)
+{
+ XRRMonitorInfo *m;
+ int n;
+
+ if (!has_1_5 || monitors)
+ return;
+
+ m = XRRGetMonitors(dpy, root, get_active, &n);
+ if (n == -1)
+ fatal("get monitors failed\n");
+ monitors = calloc(1, sizeof (monitors_t));
+ monitors->n = n;
+ monitors->monitors = m;
+}
int
main (int argc, char **argv)
@@ -2570,6 +2673,9 @@ main (int argc, char **argv)
Bool list_providers = False;
Bool provsetoutsource = False;
Bool provsetoffsink = False;
+ Bool monitorit = False;
+ Bool list_monitors = False;
+ Bool list_active_monitors = False;
int major, minor;
Bool current = False;
Bool toggle_x = False;
@@ -2936,7 +3042,7 @@ main (int argc, char **argv)
if (!config_output) argerr ("%s must be used after --output\n", argv[i]);
set_name_xid (&config_output->mode, None);
set_name_xid (&config_output->crtc, None);
- config_output->changes |= changes_mode;
+ config_output->changes |= changes_mode | changes_crtc;
continue;
}
if (!strcmp ("--fb", argv[i])) {
@@ -3105,6 +3211,72 @@ main (int argc, char **argv)
provsetoffsink = True;
continue;
}
+ if (!strcmp("--listmonitors", argv[i]))
+ {
+ list_monitors = True;
+ action_requested = True;
+ continue;
+ }
+ if (!strcmp("--listactivemonitors", argv[i]))
+ {
+ list_active_monitors = True;
+ action_requested = True;
+ continue;
+ }
+ if (!strcmp("--setmonitor", argv[i]))
+ {
+ umonitor_t *m = calloc(1, sizeof (umonitor_t)), **l;
+ char *t;
+ char *o;
+ char *n;
+ char *geom;
+
+ if (i+3 >= argc) argerr("%s requires three argument\n", argv[i]);
+ n = argv[++i];
+ if (*n == '*') {
+ m->primary = True;
+ n++;
+ }
+ m->name = n;
+ m->set = True;
+ geom = argv[++i];
+
+ if (strncmp (geom, "auto", 4) != 0) {
+ if (sscanf(geom, "%d/%dx%d/%d+%d+%d",
+ &m->width, &m->mmwidth, &m->height, &m->mmheight, &m->x, &m->y) != 6)
+ argerr ("failed to parse '%s' as monitor geometry\n", argv[i]);
+ }
+
+ o = argv[++i];
+ if (strcmp(o, "none") != 0) {
+ printf ("output list %s\n", o);
+ for (; (t = strtok(o, ",")) != NULL; o = NULL) {
+ m->outputs = realloc(m->outputs, (m->noutput + 1) * sizeof (name_t));
+ printf ("add monitor %s\n", t);
+ set_name(&m->outputs[m->noutput++], t, name_string|name_xid|name_index);
+ printf ("output name %s\n", m->outputs[m->noutput-1].string);
+ }
+ }
+ for (l = &umonitors; *l; l = &((*l)->next));
+ *l = m;
+ action_requested = True;
+ monitorit = True;
+ continue;
+ }
+ if (!strcmp("--delmonitor", argv[i]))
+ {
+ umonitor_t *m = calloc(1, sizeof (umonitor_t)), **l;
+
+ if (++i >= argc) argerr("%s requires an argument\n", argv[i-1]);
+
+ m->name = argv[i];
+ m->set = False;
+ for (l = &umonitors; *l; l = &((*l)->next));
+ *l = m;
+ action_requested = True;
+ monitorit = True;
+ continue;
+ }
argerr ("unrecognized option '%s'\n", argv[i]);
}
@@ -3147,12 +3319,13 @@ main (int argc, char **argv)
has_1_3 = True;
if (major > 1 || (major == 1 && minor >= 4))
has_1_4 = True;
-
+ if (major > 1 || (major == 1 && minor >= 5))
+ has_1_5 = True;
if (has_1_2 && modeit)
{
umode_t *m;
- get_screen (current);
+ get_screen (True);
get_crtcs();
get_outputs();
@@ -3191,7 +3364,7 @@ main (int argc, char **argv)
break;
}
}
- if (!setit_1_2)
+ if (!propit && !setit_1_2 && !monitorit)
{
XSync (dpy, False);
exit (0);
@@ -3201,7 +3374,7 @@ main (int argc, char **argv)
{
output_t *output;
- get_screen (current);
+ get_screen (True);
get_crtcs();
get_outputs();
@@ -3292,7 +3465,7 @@ main (int argc, char **argv)
if (!has_1_4)
fatal ("--setprovideroutputsource requires RandR 1.4\n");
- get_screen (current);
+ get_screen (True);
get_providers ();
provider = find_provider (&provider_name);
@@ -3307,7 +3480,7 @@ main (int argc, char **argv)
if (!has_1_4)
fatal ("--setprovideroffloadsink requires RandR 1.4\n");
- get_screen (current);
+ get_screen (True);
get_providers ();
provider = find_provider (&provider_name);
@@ -3317,7 +3490,7 @@ main (int argc, char **argv)
}
if (setit_1_2)
{
- get_screen (current);
+ get_screen (True);
get_crtcs ();
get_outputs ();
set_positions ();
@@ -3402,6 +3575,73 @@ main (int argc, char **argv)
*/
apply ();
+ if (!monitorit) {
+ XSync (dpy, False);
+ exit (0);
+ }
+ }
+ if (monitorit) {
+ umonitor_t *u;
+ Atom name;
+
+ if (!has_1_5) {
+ printf("RandR 1.5 not supported\n");
+ exit(0);
+ }
+
+ get_screen(True);
+ get_monitors(True);
+ get_crtcs();
+ get_outputs();
+
+ for (u = umonitors; u; u = u->next) {
+ if (u->set) {
+ XRRMonitorInfo *m;
+ int o;
+
+ name = XInternAtom(dpy, u->name, False);
+ m = XRRAllocateMonitor(dpy, u->noutput);
+
+ m->name = name;
+ m->primary = u->primary;
+ m->x = u->x;
+ m->y = u->y;
+ m->width = u->width;
+ m->height = u->height;
+ m->mwidth = u->mmwidth;
+ m->mheight = u->mmheight;
+ for (o = 0; o < u->noutput; o++) {
+ output_t *output = find_output(&u->outputs[o]);
+ if (!output)
+ fatal("cannot find output\n");
+ m->outputs[o] = output->output.xid;
+ }
+
+ XRRSetMonitor(dpy, root, m);
+
+ XRRFreeMonitors(m);
+ } else {
+ int m;
+
+ name = XInternAtom(dpy, u->name, True);
+ if (!name) {
+ printf("No monitor named '%s'\n", u->name);
+ } else {
+ if (!monitors)
+ printf ("No monitors\n");
+ else {
+ for (m = 0; m < monitors->n; m++) {
+ if (monitors->monitors[m].name == name)
+ break;
+ }
+ if (m == monitors->n)
+ printf("No monitor named '%s'\n", u->name);
+ else
+ XRRDeleteMonitor(dpy, root, name);
+ }
+ }
+ }
+ }
XSync (dpy, False);
exit (0);
}
@@ -3633,25 +3873,9 @@ main (int argc, char **argv)
for (j = 0; j < output_info->nmode; j++)
{
XRRModeInfo *mode = find_mode_by_xid (output_info->modes[j]);
- int f;
-
- printf (" %s (0x%x) %6.3fMHz",
- mode->name, (int)mode->id,
- (double)mode->dotClock / 1000000.0);
- for (f = 0; mode_flags[f].flag; f++)
- if (mode->modeFlags & mode_flags[f].flag)
- printf (" %s", mode_flags[f].string);
- if (mode == output->mode_info)
- printf (" *current");
- if (j < output_info->npreferred)
- printf (" +preferred");
- printf ("\n");
- printf (" h: width %4d start %4d end %4d total %4d skew %4d clock %6.2fKHz\n",
- mode->width, mode->hSyncStart, mode->hSyncEnd,
- mode->hTotal, mode->hSkew, mode_hsync (mode) / 1000);
- printf (" v: height %4d start %4d end %4d total %4d clock %6.2fHz\n",
- mode->height, mode->vSyncStart, mode->vSyncEnd, mode->vTotal,
- mode_refresh (mode));
+
+ print_verbose_mode (mode, mode == output->mode_info,
+ j < output_info->npreferred);
mode->modeFlags |= ModeShown;
}
}
@@ -3696,17 +3920,7 @@ main (int argc, char **argv)
XRRModeInfo *mode = &res->modes[m];
if (!(mode->modeFlags & ModeShown))
- {
- printf (" %s (0x%x) %6.3fMHz\n",
- mode->name, (int)mode->id,
- (double)mode->dotClock / 1000000.0);
- printf (" h: width %4d start %4d end %4d total %4d skew %4d clock %6.2fKHz\n",
- mode->width, mode->hSyncStart, mode->hSyncEnd,
- mode->hTotal, mode->hSkew, mode_hsync (mode) / 1000);
- printf (" v: height %4d start %4d end %4d total %4d clock %6.2fHz\n",
- mode->height, mode->vSyncStart, mode->vSyncEnd, mode->vTotal,
- mode_refresh (mode));
- }
+ print_verbose_mode(mode, False, False);
}
exit (0);
}
@@ -3739,6 +3953,46 @@ main (int argc, char **argv)
}
}
}
+ if (list_monitors || list_active_monitors) {
+
+ if (!has_1_5) {
+ printf("RandR 1.5 not supported\n");
+ exit(0);
+ }
+
+ get_screen(current);
+ get_monitors(list_active_monitors ? True : False);
+ get_crtcs();
+ get_outputs();
+
+ if (monitors) {
+ int m, o;
+
+ printf("Monitors: %d\n", monitors->n);
+
+ for (m = 0; m < monitors->n; m++) {
+ printf (" %d: %s%s%s %d/%dx%d/%d+%d+%d ",
+ m,
+ monitors->monitors[m].automatic ? "+" : "",
+ monitors->monitors[m].primary ? "*" : "",
+ XGetAtomName(dpy, monitors->monitors[m].name),
+ monitors->monitors[m].width,
+ monitors->monitors[m].mwidth,
+ monitors->monitors[m].height,
+ monitors->monitors[m].mheight,
+ monitors->monitors[m].x,
+ monitors->monitors[m].y);
+ for (o = 0; o < monitors->monitors[m].noutput; o++) {
+ output_t *output = find_output_by_xid(monitors->monitors[m].outputs[o]);
+ if (output)
+ printf (" %s", output->output.string);
+ else
+ printf (" unknown output 0x%x\n", (CARD32) monitors->monitors[m].outputs[o]);
+ }
+ printf ("\n");
+ }
+ }
+ }
sc = XRRGetScreenInfo (dpy, root);
Added files:
Index: xsrc/external/mit/xrandr/dist/compile
diff -u /dev/null xsrc/external/mit/xrandr/dist/compile:1.3
--- /dev/null Wed Apr 27 07:23:01 2016
+++ xsrc/external/mit/xrandr/dist/compile Wed Apr 27 07:23:01 2016
@@ -0,0 +1,347 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand '-c -o'.
+
+scriptversion=2012-10-14.11; # UTC
+
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Written by Tom Tromey <[email protected]>.
+#
+# 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 <[email protected]> or send patches to
+# <[email protected]>.
+
+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 <[email protected]>.
+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: