diff mbox

configure: Fix creation of symbolic links for MinGW toolchain

Message ID 1331998306-30941-1-git-send-email-sw@weilnetz.de
State Superseded
Headers show

Commit Message

Stefan Weil March 17, 2012, 3:31 p.m. UTC
The MinGW toolchain on w32/w64 hosts does not create symbolic links,
but implements 'ln -s' similar to 'cp -r'.

In incremental out of tree builds, this resulted in files which
were not updated when their counterparts in the QEMU source tree
changed. Especially for Makefile* this happened very often.

With this patch, the 'symlinked' files are now always updated for
out of tree builds. Similar code was already used for the symbolic
link of libcacard/Makefile.

The symlink macro always removes the target before it is created
again, therefore the rm command for libcacard/Makefile was redundant
and is removed now.

Macro symlink is also used with directories. To remove them on w32
hosts, a recursive rm is needed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

Comments

Peter Maydell March 17, 2012, 3:49 p.m. UTC | #1
On 17 March 2012 15:31, Stefan Weil <sw@weilnetz.de> wrote:
> Macro symlink is also used with directories. To remove them on w32
> hosts, a recursive rm is needed.

Where do we symlink directories? (I exclude the setting up
of the linux headers because that will only happen on Linux
hosts where we know we have working symlinks.)

-- PMM
Stefan Weil March 17, 2012, 3:59 p.m. UTC | #2
Am 17.03.2012 16:49, schrieb Peter Maydell:
> On 17 March 2012 15:31, Stefan Weil<sw@weilnetz.de>  wrote:
>> Macro symlink is also used with directories. To remove them on w32
>> hosts, a recursive rm is needed.
> Where do we symlink directories? (I exclude the setting up
> of the linux headers because that will only happen on Linux
> hosts where we know we have working symlinks.)
>
> -- PMM

pc-bios/keymaps

Cheers,
Stefan W.
Peter Maydell March 17, 2012, 5:24 p.m. UTC | #3
On 17 March 2012 15:59, Stefan Weil <sw@weilnetz.de> wrote:
> Am 17.03.2012 16:49, schrieb Peter Maydell:
>> Where do we symlink directories? (I exclude the setting up
>> of the linux headers because that will only happen on Linux
>> hosts where we know we have working symlinks.)

> pc-bios/keymaps

Oh yes, missed that one (since it's a directory name cunningly
hidden in a variable named FILES :-)).

I'm just a little wary of 'rm -rf', especially here where
we're nuking whatever was passed as an argument and we
aren't getting the shell quoting right. In theory we could
use a wildcard for the keymaps the same way we do for a
bunch of the other pc-bios files; I'm not sure if it's worth
the effort, though.

-- PMM
Stefan Hajnoczi March 19, 2012, 11:30 a.m. UTC | #4
On Sat, Mar 17, 2012 at 05:24:08PM +0000, Peter Maydell wrote:
> On 17 March 2012 15:59, Stefan Weil <sw@weilnetz.de> wrote:
> > Am 17.03.2012 16:49, schrieb Peter Maydell:
> >> Where do we symlink directories? (I exclude the setting up
> >> of the linux headers because that will only happen on Linux
> >> hosts where we know we have working symlinks.)
> 
> > pc-bios/keymaps
> 
> Oh yes, missed that one (since it's a directory name cunningly
> hidden in a variable named FILES :-)).
> 
> I'm just a little wary of 'rm -rf', especially here where
> we're nuking whatever was passed as an argument and we
> aren't getting the shell quoting right. In theory we could
> use a wildcard for the keymaps the same way we do for a
> bunch of the other pc-bios files; I'm not sure if it's worth
> the effort, though.

Yes, I'm not comfortable with the 'rm -rf' either.  Please use "$2" so
that the path is at least quoted.

Stefan
diff mbox

Patch

diff --git a/configure b/configure
index afe7395..acf63a9 100755
--- a/configure
+++ b/configure
@@ -41,7 +41,7 @@  compile_prog() {
 
 # symbolically link $1 to $2.  Portable version of "ln -sf".
 symlink() {
-  rm -f $2
+  rm -rf $2
   ln -s $1 $2
 }
 
@@ -3883,7 +3883,7 @@  do
 done
 mkdir -p $DIRS
 for f in $FILES ; do
-    if [ -e "$source_path/$f" ] && ! [ -e "$f" ]; then
+    if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
         symlink "$source_path/$f" "$f"
     fi
 done
@@ -3914,7 +3914,6 @@  done
 if [ "$source_path" != `pwd` ]; then
     # out of tree build
     mkdir -p libcacard
-    rm -f libcacard/Makefile
     symlink "$source_path/libcacard/Makefile" libcacard/Makefile
 fi