configure: Automatically add -isysroot for darwin if --sysroot is specified

Message ID 20170621135845.15673-1-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö June 21, 2017, 1:58 p.m.
Check the existing flags in the cc/cflags/cppflags/ldflags for
occurrances of -isysroot; if none is found but --sysroot was specified,
set -isysroot to the same value as --sysroot.

This simplifies configuring cross-builds for iOS, if the global
environment variable SDKROOT isn't set.
---
 configure | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Luca Barbato June 21, 2017, 2:53 p.m. | #1
On 6/21/17 3:58 PM, Martin Storsjö wrote:
> Check the existing flags in the cc/cflags/cppflags/ldflags for
> occurrances of -isysroot; if none is found but --sysroot was specified,
> set -isysroot to the same value as --sysroot.
> 
> This simplifies configuring cross-builds for iOS, if the global
> environment variable SDKROOT isn't set.
> ---
>  configure | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/configure b/configure
> index 22de1b358e..c976ee82bd 100755
> --- a/configure
> +++ b/configure
> @@ -3981,6 +3981,10 @@ case $target_os in
>              { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
>          check_header dispatch/dispatch.h &&
>              add_cppflags '-I\$(SRC_PATH)/compat/dispatch_semaphore'
> +        if test -n "$sysroot"; then
> +            echo "$cc $CPPFLAGS $CFLAGS" | grep -q -- '-isysroot' || check_cppflags -isysroot $sysroot
> +            echo "$ld $LDFLAGS" | grep -q -- '-isysroot' || check_ldflags -isysroot $sysroot
> +        fi
>          ;;
>      msys*)
>          die "Native MSYS builds are discouraged, please use the MINGW environment."
> 

Seems harmless. I'm ok with that.

lu
Diego Biurrun June 21, 2017, 3:46 p.m. | #2
On Wed, Jun 21, 2017 at 04:58:45PM +0300, Martin Storsjö wrote:
> --- a/configure
> +++ b/configure
> @@ -3981,6 +3981,10 @@ case $target_os in
>              { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
>          check_header dispatch/dispatch.h &&
>              add_cppflags '-I\$(SRC_PATH)/compat/dispatch_semaphore'
> +        if test -n "$sysroot"; then
> +            echo "$cc $CPPFLAGS $CFLAGS" | grep -q -- '-isysroot' || check_cppflags -isysroot $sysroot

is_in -isysroot $cc $CPPFLAGS $CFLAGS || check_cppflags -isysroot $sysroot

> +            echo "$ld $LDFLAGS" | grep -q -- '-isysroot' || check_ldflags -isysroot $sysroot

same

I'm OK with the change as such, so feel free to push with the implementation
changed (if it works as it should).

Diego

Patch

diff --git a/configure b/configure
index 22de1b358e..c976ee82bd 100755
--- a/configure
+++ b/configure
@@ -3981,6 +3981,10 @@  case $target_os in
             { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
         check_header dispatch/dispatch.h &&
             add_cppflags '-I\$(SRC_PATH)/compat/dispatch_semaphore'
+        if test -n "$sysroot"; then
+            echo "$cc $CPPFLAGS $CFLAGS" | grep -q -- '-isysroot' || check_cppflags -isysroot $sysroot
+            echo "$ld $LDFLAGS" | grep -q -- '-isysroot' || check_ldflags -isysroot $sysroot
+        fi
         ;;
     msys*)
         die "Native MSYS builds are discouraged, please use the MINGW environment."