diff --git a/lib/compile b/lib/compile index c0096a7..ce89059 100755 --- a/lib/compile +++ b/lib/compile @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand `-c -o'. -scriptversion=2009-10-06.20; # UTC +scriptversion=2010-06-14.06; # UTC -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010 Free Software # Foundation, Inc. # Written by Tom Tromey . # @@ -29,6 +29,108 @@ scriptversion=2009-10-06.20; # UTC # bugs to or send patches to # . +path_conv= + +# func_path_conf build_path +# Convert a $build path to $host form and store it in $path +func_path_conv () +{ + path=$1 + case $path in + /[^/]*) # absolute path, and no UNC path + if test -z "$path_conv"; then + # lazily determine how to convert abs paths + case `uname -s` in + MINGW*) + path_conv=mingw + ;; + CYGWIN*) + path_conv=cygwin + ;; + *) + path_conv=wine + ;; + esac + fi + case $path_conv in + mingw) + path=`cmd //C echo "$path " | sed -e 's/"\(.*\) " *\$/\1/'` + ;; + cygwin) + path=`cygpath -w "$path"` + ;; + wine) + path=`winepath -w "$path"` + ;; + esac + ;; + esac +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suite cl +func_cl_wrapper () +{ + # Assume a capable shell + 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 | *.obj) + func_path_conv "$2" + set x "$@" -Fo"$path" + shift + ;; + *) + func_path_conv "$2" + set x "$@" -Fe"$path" + shift + ;; + esac + ;; + -I*) + func_path_conv "${1#-I}" + set x "$@" -I"$path" + shift + ;; + -l*) + set x "$@" "${1#-l}.lib" + shift + ;; + -L*) + func_path_conv "${1#-L}" + export LINK="$LINK -LIBPATH:$path" + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + export LINK="$LINK $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + export LINK="$LINK $2" + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + exec "$@" +} + case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 @@ -53,6 +155,9 @@ EOF echo "compile $scriptversion" exit $? ;; + cl | *[/\\]cl) + func_cl_wrapper "$@" # Doesn't return... + ;; esac ofile=