commit 06770d9fb9231014f7066d7f79aa7c1fa8d21ea1 Author: Peter Rosin Date: Wed Jun 16 22:21:36 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 file names 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..1eeacd4 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 file names 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..ae290d5 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 for a better + user experience. + * 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..491fafe 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 file name +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..dc56ea0 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.20; # 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" + +file_conv= + +# func_file_conv build_file +# Convert a $build file to $host form and store it in $file +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 in + mingw) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin) + file=`cygpath -w "$file" || echo "$file"` + ;; + wine) + file=`winepath -w "$file" || echo "$file"` + ;; + 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_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I*) + func_file_conv "${1#-I}" + set x "$@" -I"$file" + shift + ;; + -l*) + set x "$@" "${1#-l}.lib" + shift + ;; + -L*) + func_file_conv "${1#-L}" + linker_opts="$linker_opts -LIBPATH:$file" + ;; + -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=