commit ddfb842637997554b16d6a427bb77fd679050c1c Author: Peter Rosin Date: Wed Jun 16 14:13:43 2010 +0200 Wrap some MSVC options in the compile script. * lib/compile: MSVC supports naming the output file, the option is just not called -o, so transform -o into the appropriate form for MSVC. Also wrap some other options while at it (-L, -l, -Wl, -Xlinker and -I) and convert paths to windows form where needed for those options to make MSVC more usable in an autotooled environment. * doc/automake.texi (Auxiliary Programs): Document the above extension of the compile script. * NEWS: Updated. diff --git a/ChangeLog b/ChangeLog index b5f1433..bc61105 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2010-06-16 Peter Rosin + + Wrap some MSVC options in the compile script. + * lib/compile: MSVC supports naming the output file, the option + is just not called -o, so transform -o into the appropriate form + for MSVC. Also wrap some other options while at it (-L, -l, -Wl, + -Xlinker and -I) and convert paths to windows form where needed + for those options to make MSVC more usable in an autotooled + environment. + * doc/automake.texi (Auxiliary Programs): Document the above + extension of the compile script. + * NEWS: Updated. + 2010-06-13 Stefano Lattarini Add useful comment in test script obsolete.test. diff --git a/NEWS b/NEWS index 13b28c0..fa26c88 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,9 @@ New in 1.11a: - automake now generates silenced rules for texinfo outputs. + - The `compile' script now converts some options for MSVC to make the + user experience better. + * New targets: - New `cscope' target to build a cscope database for the source tree. diff --git a/doc/automake.texi b/doc/automake.texi index f5ccca1..c24a9eb 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -2169,7 +2169,11 @@ These two files are used for de-ANSI-fication support (obsolete @item compile This is a wrapper for compilers that do not accept options @option{-c} and @option{-o} at the same time. It is only used when absolutely -required. Such compilers are rare. +required. Such compilers are rare, with the Microsoft C/C++ Compiler +as the most notable exception. This wrapper also makes the following +common options available for that compiler, while performing path +translation where needed: @option{-I}, @option{-L}, @option{-l}, address@hidden,} and @option{-Xlinker}. @item config.guess @itemx config.sub diff --git a/lib/compile b/lib/compile index c0096a7..1c79ce3 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-16.12; # 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,120 @@ scriptversion=2009-10-06.20; # UTC # bugs to or send patches to # . +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" + +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" || echo "$path"` + ;; + wine) + path=`winepath -w "$path" || echo "$path"` + ;; + esac + ;; + esac +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suite cl +func_cl_wrapper () +{ + # Assume a capable shell + 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_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}" + linker_opts="$linker_opts -LIBPATH:$path" + ;; + -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 + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 @@ -53,6 +167,9 @@ EOF echo "compile $scriptversion" exit $? ;; + cl | *[/\\]cl) + func_cl_wrapper "$@" # Doesn't return... + ;; esac ofile=