[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] Remove the extra -lrt switch
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2] Remove the extra -lrt switch |
Date: |
Fri, 27 Apr 2012 16:30:41 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 |
On 04/27/2012 04:20 PM, Andreas Färber wrote:
> Am 27.04.2012 23:55, schrieb Eric Blake:
>> On 04/27/2012 02:16 PM, Peter Portante wrote:
>>> The package config check for gthreads might have already placed a
>>> -lrt switch in LIBS earlier.
>>>
>>> Refactored the code from the pthread switch removal, from commit
>>> e3c56761b465a4253871c32b06ebbc2d8b3fc3e1, to make it work for
>>> the more general case.
>>>
>
>>> +add_to_libs() { + found=no + for lib_entry in $LIBS; do +
>>> if test "$lib_entry" = "$1"; then + found=yes + break +
>>> fi + done + if test "$found" = "no"; then + LIBS="$1 $LIBS"
>>> + fi +}
>
>> Shorter (and probably faster) to write this as:
>
>> add_to_libs() { case " $LIBS " in " $1 ") ;; *) LIBS="$1 $LIBS" ;;
>> esac }
>
> Er, no. That would only catch the initial duplication case -lrt -lrt
> but not -lbla -lrt -lrt or -lrt -lbla -lrt, wouldn't it?
>
> But then again Peter's function wouldn't find duplicates when $1
> contains a space either... tricky.
If you want to filter duplicates out of $1, then:
add_to_libs() {
for lib in $1; do
case " $LIBS " in
*" $lib "*) ;;
*) LIBS="$lib $LIBS" ;;
esac
done
}
Hopefully, we don't encounter any libs with circular dependencies, where
a lib must be listed twice to be effective.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature