diff mbox

Fix cross compilation

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

Commit Message

Stefan Weil March 28, 2010, 9:44 a.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}sdl_config              (new, only used for cross compilation)
$(cross_prefix}pkg-config              (old)
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.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 configure |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Comments

Aurelien Jarno April 9, 2010, 7:44 p.m. UTC | #1
On Sun, Mar 28, 2010 at 11:44:05AM +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}sdl_config              (new, only used for cross compilation)
> $(cross_prefix}pkg-config              (old)
> pkg-config                             (old, needs PATH)
> sdl-config                             (old, needs PATH)

Why a different order for cross-compilation than for native
compilation? I would expect the same order in both case, that is
pkg-config first, and then sdl_config. The general rule, not specific to
QEMU, is to prefer pkg-config over *config programs.

> 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.
> 
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  configure |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/configure b/configure
> index 664c920..eb2d759 100755
> --- a/configure
> +++ b/configure
> @@ -1047,7 +1047,10 @@ fi
>  ##########################################
>  # SDL probe
>  
> -if $pkgconfig sdl --modversion >/dev/null 2>&1; then
> +if 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 April 10, 2010, 7:34 a.m. UTC | #2
Aurelien Jarno schrieb:
> On Sun, Mar 28, 2010 at 11:44:05AM +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}sdl_config (new, only used for cross compilation)
>> $(cross_prefix}pkg-config (old)
>> pkg-config (old, needs PATH)
>> sdl-config (old, needs PATH)
>
> Why a different order for cross-compilation than for native
> compilation? I would expect the same order in both case, that is
> pkg-config first, and then sdl_config. The general rule, not specific to
> QEMU, is to prefer pkg-config over *config programs.
>

Maybe the correct solution should be

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

Fallback to native *-config and "hope for the best"
is no good solution for cross compilations.

If nobody disagrees, I'll send a patch without this fallback.

Stefan
Aurelien Jarno April 10, 2010, 3:06 p.m. UTC | #3
On Sat, Apr 10, 2010 at 09:34:31AM +0200, Stefan Weil wrote:
> Aurelien Jarno schrieb:
> > On Sun, Mar 28, 2010 at 11:44:05AM +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}sdl_config (new, only used for cross compilation)
> >> $(cross_prefix}pkg-config (old)
> >> pkg-config (old, needs PATH)
> >> sdl-config (old, needs PATH)
> >
> > Why a different order for cross-compilation than for native
> > compilation? I would expect the same order in both case, that is
> > pkg-config first, and then sdl_config. The general rule, not specific to
> > QEMU, is to prefer pkg-config over *config programs.
> >
> 
> Maybe the correct solution should be
> 
> $(cross_prefix}pkg-config (old)
> ${cross_prefix}sdl_config (new, only used for cross compilation)

Why sdl_config only for cross compilation? If $(cross_prefix} is not set
for native compilation, always looking for:

- first to $(cross_prefix}pkg-config
- and then to ${cross_prefix}sdl-config

looks the way to go.
Stefan Weil April 10, 2010, 3:15 p.m. UTC | #4
Aurelien Jarno schrieb:
> On Sat, Apr 10, 2010 at 09:34:31AM +0200, Stefan Weil wrote:
>> Aurelien Jarno schrieb:
>>> On Sun, Mar 28, 2010 at 11:44:05AM +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}sdl_config (new, only used for cross compilation)
>>>> $(cross_prefix}pkg-config (old)
>>>> pkg-config (old, needs PATH)
>>>> sdl-config (old, needs PATH)
>>> Why a different order for cross-compilation than for native
>>> compilation? I would expect the same order in both case, that is
>>> pkg-config first, and then sdl_config. The general rule, not specific to
>>> QEMU, is to prefer pkg-config over *config programs.
>>>
>> Maybe the correct solution should be
>>
>> $(cross_prefix}pkg-config (old)
>> ${cross_prefix}sdl_config (new, only used for cross compilation)
>
> Why sdl_config only for cross compilation? If $(cross_prefix} is not set
> for native compilation, always looking for:
>
> - first to $(cross_prefix}pkg-config
> - and then to ${cross_prefix}sdl-config
>
> looks the way to go.

D'accord. That's what I wanted to say.
The "only used for cross compilation" was too much copy + paste.
diff mbox

Patch

diff --git a/configure b/configure
index 664c920..eb2d759 100755
--- a/configure
+++ b/configure
@@ -1047,7 +1047,10 @@  fi
 ##########################################
 # SDL probe
 
-if $pkgconfig sdl --modversion >/dev/null 2>&1; then
+if 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