diff options
author | Alexandre Duret-Lutz <adl@gnu.org> | 2004-09-10 18:38:33 +0000 |
---|---|---|
committer | Alexandre Duret-Lutz <adl@gnu.org> | 2004-09-10 18:38:33 +0000 |
commit | ff95d45f1a6eb3aa3faac895e95d0df62aab9eb0 (patch) | |
tree | 1bd5f97ffbe0b8d8a90a5ae51b821176e97f4fe1 | |
parent | dfe7f7545e074ab51b53ac169ed0e622bae4386c (diff) | |
download | automake-ff95d45f1a6eb3aa3faac895e95d0df62aab9eb0.tar.gz |
* lib/compile: Preserve spaces in arguments (for example
-DPACKAGE_STRING="foo 0.1").
* tests/compile.test: New file.
* tests/Makefile.am (TESTS): Add compile.test.
-rw-r--r-- | ChangeLog | 8 | ||||
-rwxr-xr-x | lib/compile | 80 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/Makefile.in | 2 | ||||
-rwxr-xr-x | tests/compile.test | 43 |
5 files changed, 96 insertions, 38 deletions
@@ -1,3 +1,11 @@ +2004-09-10 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> + Alexandre Duret-Lutz <adl@gnu.org> + + * lib/compile: Preserve spaces in arguments (for example + -DPACKAGE_STRING="foo 0.1"). + * tests/compile.test: New file. + * tests/Makefile.am (TESTS): Add compile.test. + 2004-09-07 Alexandre Duret-Lutz <adl@gnu.org> * automake.in (handle_clean): Sort rm commands output for diff --git a/lib/compile b/lib/compile index a81e000ae..e6084f46e 100755 --- a/lib/compile +++ b/lib/compile @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand `-c -o'. -scriptversion=2003-11-09.00 +scriptversion=2004-09-10.20 -# Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. # Written by Tom Tromey <tromey@cygnus.com>. # # This program is free software; you can redistribute it and/or modify @@ -55,37 +55,41 @@ EOF ;; esac - -prog=$1 -shift - ofile= cfile= -args= -while test $# -gt 0; do - case "$1" in - -o) - # configure might choose to run compile as `compile cc -o foo foo.c'. - # So we do something ugly here. - ofile=$2 - shift - case "$ofile" in - *.o | *.obj) - ;; - *) - args="$args -o $ofile" - ofile= - ;; - esac - ;; - *.c) - cfile=$1 - args="$args $1" - ;; - *) - args="$args $1" - ;; - esac +eat= + +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 @@ -95,35 +99,35 @@ if test -z "$ofile" || test -z "$cfile"; then # normal compilation that the losing compiler can handle. If no # `.c' file was seen then we are probably linking. That is also # ok. - exec "$prog" $args + exec "$@" fi # Name of file we expect compiler to create. -cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'` +cofile=`echo "$cfile" | sed -e 's|^.*/||' -e '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 +lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d while true; do - if mkdir $lockdir > /dev/null 2>&1; then + 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 +trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. -"$prog" $args +"$@" status=$? if test -f "$cofile"; then mv "$cofile" "$ofile" fi -rmdir $lockdir +rmdir "$lockdir" exit $status # Local Variables: diff --git a/tests/Makefile.am b/tests/Makefile.am index 41c446d8d..e2261756a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -93,6 +93,7 @@ comment4.test \ comment5.test \ comment6.test \ comment7.test \ +compile.test \ compile_f90_c_cxx.test \ compile_f_c_cxx.test \ cond.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 51013650e..db5a5e439 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -66,6 +66,7 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ FGREP = @FGREP@ +GREP = @GREP@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -210,6 +211,7 @@ comment4.test \ comment5.test \ comment6.test \ comment7.test \ +compile.test \ compile_f90_c_cxx.test \ compile_f_c_cxx.test \ cond.test \ diff --git a/tests/compile.test b/tests/compile.test new file mode 100755 index 000000000..1c78a71d0 --- /dev/null +++ b/tests/compile.test @@ -0,0 +1,43 @@ +#! /bin/sh +# Copyright (C) 2004 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake 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. +# +# GNU Automake 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 Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Make sure `compile' preserves spaces in its arguments. + +. ./defs || exit 1 + +set -e + +cp $testsrcdir/../lib/compile . + +# -o 'a c' should not be stripped because 'a c' is not an object +# (it does not matter whether touch creates ./-- or not) +./compile touch a.o -- -o 'a c' a.c +test -f 'a c' +test -f ./-o +test -f a.o +test -f a.c + +rm 'a c' ./-o a.o a.c + +./compile touch a.o -- -o 'a c.o' a.c +test -f 'a c.o' +test ! -f ./-o +test ! -f a.o +test -f a.c |