diff mbox

Fix cross compilation

Message ID 1271004258-26882-1-git-send-email-weil@mail.berlios.de
State New
Headers show

Commit Message

Stefan Weil April 11, 2010, 4:44 p.m. UTC
This patch enhances the algorithm which finds the correct settings for SDL.
For cross compilations (when cross_prefix is set), it looks for sdl-config
with cross prefix. Here is the complete search order:

$(cross_prefix}pkg-config              (old, only used for cross compilation)
${cross_prefix}sdl_config              (new, only used for cross compilation)
pkg-config                             (old, needs PATH)
sdl-config                             (old, needs PATH)

Cross SDL packages (or the user) now can simply set a link (for example
/usr/bin/i586-mingw32msvc-sdl-config -> /usr/i586-mingw32msvc/bin/sdl-config)
which allows cross compilations without PATH modifications.

Without the patch, configure and make (which calls configure) typically
need a non-standard PATH. Failing to set this special PATH results in
broken builds.

v2:
* Favour pkg-config over sdl-config for cross compilations
  (suggested by Aurelien Jarno) and add comment for this.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 configure |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

Comments

Stefan Weil May 8, 2010, 2:29 p.m. UTC | #1
Am 11.04.2010 18:44, schrieb Stefan Weil:
> This patch enhances the algorithm which finds the correct settings for SDL.
> For cross compilations (when cross_prefix is set), it looks for sdl-config
> with cross prefix. Here is the complete search order:
>
> $(cross_prefix}pkg-config              (old, only used for cross compilation)
> ${cross_prefix}sdl_config              (new, only used for cross compilation)
> pkg-config                             (old, needs PATH)
> sdl-config                             (old, needs PATH)
>
> Cross SDL packages (or the user) now can simply set a link (for example
> /usr/bin/i586-mingw32msvc-sdl-config ->  /usr/i586-mingw32msvc/bin/sdl-config)
> which allows cross compilations without PATH modifications.
>
> Without the patch, configure and make (which calls configure) typically
> need a non-standard PATH. Failing to set this special PATH results in
> broken builds.
>
> v2:
> * Favour pkg-config over sdl-config for cross compilations
>    (suggested by Aurelien Jarno) and add comment for this.
>
> Cc: Aurelien Jarno<aurelien@aurel32.net>
> Signed-off-by: Stefan Weil<weil@mail.berlios.de>
> ---
>   configure |   12 +++++++++++-
>   1 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index 966cd7d..47fca4f 100755
> --- a/configure
> +++ b/configure
> @@ -1064,7 +1064,17 @@ fi
>   ##########################################
>   # SDL probe
>
> -if $pkgconfig sdl --modversion>/dev/null 2>&1; then
> +# Look for sdl configuration program (pkg-config or sdl-config).
> +# Prefer variant with cross prefix if cross compiling,
> +# and favour pkg-config with sdl over sdl-config.
> +if test -n "$cross_prefix" -a $pkgconfig != pkg-config&&  \
> +     $pkgconfig sdl --modversion>/dev/null 2>&1; then
> +  sdlconfig="$pkgconfig sdl"
> +  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
> +elif test -n "$cross_prefix"&&  has ${cross_prefix}sdl-config; then
> +  sdlconfig="${cross_prefix}sdl-config"
> +  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
> +elif $pkgconfig sdl --modversion>/dev/null 2>&1; then
>     sdlconfig="$pkgconfig sdl"
>     _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
>   elif has sdl-config; then
>    

No comments? So this patch can be applied to qemu master?

Thanks, Stefan
Aurelien Jarno May 18, 2010, 5:43 p.m. UTC | #2
On Sun, Apr 11, 2010 at 06:44:18PM +0200, Stefan Weil wrote:
> This patch enhances the algorithm which finds the correct settings for SDL.
> For cross compilations (when cross_prefix is set), it looks for sdl-config
> with cross prefix. Here is the complete search order:
> 
> $(cross_prefix}pkg-config              (old, only used for cross compilation)
> ${cross_prefix}sdl_config              (new, only used for cross compilation)
> pkg-config                             (old, needs PATH)
> sdl-config                             (old, needs PATH)
> 
> Cross SDL packages (or the user) now can simply set a link (for example
> /usr/bin/i586-mingw32msvc-sdl-config -> /usr/i586-mingw32msvc/bin/sdl-config)
> which allows cross compilations without PATH modifications.
> 
> Without the patch, configure and make (which calls configure) typically
> need a non-standard PATH. Failing to set this special PATH results in
> broken builds.
> 
> v2:
> * Favour pkg-config over sdl-config for cross compilations
>   (suggested by Aurelien Jarno) and add comment for this.
> 
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  configure |   12 +++++++++++-
>  1 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/configure b/configure
> index 966cd7d..47fca4f 100755
> --- a/configure
> +++ b/configure
> @@ -1064,7 +1064,17 @@ fi
>  ##########################################
>  # SDL probe
>  
> -if $pkgconfig sdl --modversion >/dev/null 2>&1; then
> +# Look for sdl configuration program (pkg-config or sdl-config).
> +# Prefer variant with cross prefix if cross compiling,
> +# and favour pkg-config with sdl over sdl-config.
> +if test -n "$cross_prefix" -a $pkgconfig != pkg-config && \
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
			       Why this test ?

> +     $pkgconfig sdl --modversion >/dev/null 2>&1; then
> +  sdlconfig="$pkgconfig sdl"

It should probably be sdlconfig="${cross_prefix}$pkgconfig sdl" so that
the cross version of pkg-config is called later in this file.

> +  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
> +elif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
> +  sdlconfig="${cross_prefix}sdl-config"
> +  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
> +elif $pkgconfig sdl --modversion >/dev/null 2>&1; then
>    sdlconfig="$pkgconfig sdl"
>    _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
>  elif has sdl-config; then
> -- 
> 1.7.0
> 
> 
> 
>
Stefan Weil May 18, 2010, 8:12 p.m. UTC | #3
Am 18.05.2010 19:43, schrieb Aurelien Jarno:
> On Sun, Apr 11, 2010 at 06:44:18PM +0200, Stefan Weil wrote:
>    
>> This patch enhances the algorithm which finds the correct settings for SDL.
>> For cross compilations (when cross_prefix is set), it looks for sdl-config
>> with cross prefix. Here is the complete search order:
>>
>> $(cross_prefix}pkg-config              (old, only used for cross compilation)
>> ${cross_prefix}sdl_config              (new, only used for cross compilation)
>> pkg-config                             (old, needs PATH)
>> sdl-config                             (old, needs PATH)
>>
>> Cross SDL packages (or the user) now can simply set a link (for example
>> /usr/bin/i586-mingw32msvc-sdl-config ->  /usr/i586-mingw32msvc/bin/sdl-config)
>> which allows cross compilations without PATH modifications.
>>
>> Without the patch, configure and make (which calls configure) typically
>> need a non-standard PATH. Failing to set this special PATH results in
>> broken builds.
>>
>> v2:
>> * Favour pkg-config over sdl-config for cross compilations
>>    (suggested by Aurelien Jarno) and add comment for this.
>>
>> Cc: Aurelien Jarno<aurelien@aurel32.net>
>> Signed-off-by: Stefan Weil<weil@mail.berlios.de>
>> ---
>>   configure |   12 +++++++++++-
>>   1 files changed, 11 insertions(+), 1 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 966cd7d..47fca4f 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1064,7 +1064,17 @@ fi
>>   ##########################################
>>   # SDL probe
>>
>> -if $pkgconfig sdl --modversion>/dev/null 2>&1; then
>> +# Look for sdl configuration program (pkg-config or sdl-config).
>> +# Prefer variant with cross prefix if cross compiling,
>> +# and favour pkg-config with sdl over sdl-config.
>> +if test -n "$cross_prefix" -a $pkgconfig != pkg-config&&  \
>>      
>                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
> 			       Why this test ?
>
>    

This tests for cross compilation with a working cross pkg-config
(and not the fallback solution "hope for the best" which is used
in the third case).

>> +     $pkgconfig sdl --modversion>/dev/null 2>&1; then
>> +  sdlconfig="$pkgconfig sdl"
>>      
> It should probably be sdlconfig="${cross_prefix}$pkgconfig sdl" so that
> the cross version of pkg-config is called later in this file.
>    

pkgconfig="${cross_prefix}pkg-config" (was set earlier),
so it is the cross version.


>    
>> +  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
>> +elif test -n "$cross_prefix"&&  has ${cross_prefix}sdl-config; then
>> +  sdlconfig="${cross_prefix}sdl-config"
>> +  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
>> +elif $pkgconfig sdl --modversion>/dev/null 2>&1; then
>>     sdlconfig="$pkgconfig sdl"
>>     _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
>>   elif has sdl-config; then
>> -- 
>> 1.7.0
>>
>>
>>
>>
>>      
>
Aurelien Jarno May 19, 2010, 6:06 a.m. UTC | #4
On Tue, May 18, 2010 at 10:12:54PM +0200, Stefan Weil wrote:
> Am 18.05.2010 19:43, schrieb Aurelien Jarno:
> >On Sun, Apr 11, 2010 at 06:44:18PM +0200, Stefan Weil wrote:
> >>This patch enhances the algorithm which finds the correct settings for SDL.
> >>For cross compilations (when cross_prefix is set), it looks for sdl-config
> >>with cross prefix. Here is the complete search order:
> >>
> >>$(cross_prefix}pkg-config              (old, only used for cross compilation)
> >>${cross_prefix}sdl_config              (new, only used for cross compilation)
> >>pkg-config                             (old, needs PATH)
> >>sdl-config                             (old, needs PATH)
> >>
> >>Cross SDL packages (or the user) now can simply set a link (for example
> >>/usr/bin/i586-mingw32msvc-sdl-config ->  /usr/i586-mingw32msvc/bin/sdl-config)
> >>which allows cross compilations without PATH modifications.
> >>
> >>Without the patch, configure and make (which calls configure) typically
> >>need a non-standard PATH. Failing to set this special PATH results in
> >>broken builds.
> >>
> >>v2:
> >>* Favour pkg-config over sdl-config for cross compilations
> >>   (suggested by Aurelien Jarno) and add comment for this.
> >>
> >>Cc: Aurelien Jarno<aurelien@aurel32.net>
> >>Signed-off-by: Stefan Weil<weil@mail.berlios.de>
> >>---
> >>  configure |   12 +++++++++++-
> >>  1 files changed, 11 insertions(+), 1 deletions(-)
> >>
> >>diff --git a/configure b/configure
> >>index 966cd7d..47fca4f 100755
> >>--- a/configure
> >>+++ b/configure
> >>@@ -1064,7 +1064,17 @@ fi
> >>  ##########################################
> >>  # SDL probe
> >>
> >>-if $pkgconfig sdl --modversion>/dev/null 2>&1; then
> >>+# Look for sdl configuration program (pkg-config or sdl-config).
> >>+# Prefer variant with cross prefix if cross compiling,
> >>+# and favour pkg-config with sdl over sdl-config.
> >>+if test -n "$cross_prefix" -a $pkgconfig != pkg-config&&  \
> >                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
> >			       Why this test ?
> >
> 
> This tests for cross compilation with a working cross pkg-config
> (and not the fallback solution "hope for the best" which is used
> in the third case).
> 
> >>+     $pkgconfig sdl --modversion>/dev/null 2>&1; then
> >>+  sdlconfig="$pkgconfig sdl"
> >It should probably be sdlconfig="${cross_prefix}$pkgconfig sdl" so that
> >the cross version of pkg-config is called later in this file.
> 
> pkgconfig="${cross_prefix}pkg-config" (was set earlier),
> so it is the cross version.
> 

Ok, it makes sense now, applied.
diff mbox

Patch

diff --git a/configure b/configure
index 966cd7d..47fca4f 100755
--- a/configure
+++ b/configure
@@ -1064,7 +1064,17 @@  fi
 ##########################################
 # SDL probe
 
-if $pkgconfig sdl --modversion >/dev/null 2>&1; then
+# Look for sdl configuration program (pkg-config or sdl-config).
+# Prefer variant with cross prefix if cross compiling,
+# and favour pkg-config with sdl over sdl-config.
+if test -n "$cross_prefix" -a $pkgconfig != pkg-config && \
+     $pkgconfig sdl --modversion >/dev/null 2>&1; then
+  sdlconfig="$pkgconfig sdl"
+  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
+elif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
+  sdlconfig="${cross_prefix}sdl-config"
+  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
+elif $pkgconfig sdl --modversion >/dev/null 2>&1; then
   sdlconfig="$pkgconfig sdl"
   _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
 elif has sdl-config; then