libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

picking "-framework" in -Wl, and -Xlinker arguments


From: mpsuzuki
Subject: picking "-framework" in -Wl, and -Xlinker arguments
Date: Tue, 2 Mar 2010 16:59:06 +0900

Hi,

At present, GNU libtool cares raw "-framework" options
and exports them to inherited_linker_flags in .la file.

But if "-framework" is quoted by -Wl, or -Xlinker options,
they are just passed to the linker transparently, and not
exported to .la file. So the framework dependency caused
by -Wl,-quoted options are invisible.

Attached is a patch to care -Wl,-framework and -Xlinker
-framework. Also tests/inherited_flags.at is extended to
check various combinations of -Wl and -Xlinker. For detailed
background, please check the discussion in fink-devel:

        http://article.gmane.org/gmane.os.apple.fink.devel/18867

Please give me comments.

Regards,
mpsuzuki

diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 56b7497..1187090 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -4111,11 +4111,37 @@ func_mode_link ()
          continue
          ;;
        xlinker)
-         linker_flags="$linker_flags $qarg"
-         compiler_flags="$compiler_flags $wl$qarg"
-         prev=
-         func_append compile_command " $wl$qarg"
-         func_append finalize_command " $wl$qarg"
+         case $wl_prev in
+         framework)
+           case $host in
+           *-*-darwin*)
+             case "$deplibs " in
+             *" $qarg.ltframework "*) ;;
+             *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
+               ;;
+             esac
+             ;;
+           esac
+           wl_prev=
+           prev=
+           ;;
+         *)
+           case $qarg in
+           -framework)
+             wl_prev=framework
+             prev=
+             ;;
+           *)
+             linker_flags="$linker_flags $qarg"
+             compiler_flags="$compiler_flags $wl$qarg"
+             wl_prev=
+             prev=
+             func_append compile_command " $wl$qarg"
+             func_append finalize_command " $wl$qarg"
+             ;;
+           esac
+           ;;
+         esac
          continue
          ;;
        *)
@@ -4452,9 +4478,33 @@ func_mode_link ()
        for flag in $args; do
          IFS="$save_ifs"
           func_quote_for_eval "$flag"
-         arg="$arg $wl$func_quote_for_eval_result"
-         compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
-         linker_flags="$linker_flags $func_quote_for_eval_result"
+         case $flag in
+         -framework)
+           wl_prev=framework
+           ;;
+         *)
+           case $wl_prev in
+           framework)
+             case $host in
+             *-*-darwin*)
+               case "$deplibs " in
+               *" $flag.ltframework "*) ;;
+               *) deplibs="$deplibs $flag.ltframework" # this is fixed later
+                    ;;
+               esac
+               ;;
+             esac
+             wl_prev=
+             ;;
+           *)
+             arg="$arg $wl$func_quote_for_eval_result"
+             compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
+             linker_flags="$linker_flags $func_quote_for_eval_result"
+             wl_prev=
+             ;;
+           esac
+           ;;
+         esac
        done
        IFS="$save_ifs"
        func_stripname ' ' '' "$arg"
diff --git a/tests/inherited_flags.at b/tests/inherited_flags.at
index 65c0c3e..d4fd9c6 100644
--- a/tests/inherited_flags.at
+++ b/tests/inherited_flags.at
@@ -110,4 +110,29 @@ AT_CHECK([$LIBTOOL -n --mode=link --tag=CC $CC $CFLAGS 
$LDFLAGS -framework Cocoa
 AT_CHECK([grep Cocoa.ltframework stdout], [1], [], [])
 AT_CHECK([grep ' -framework Cocoa' stdout], [0], [ignore], [])
 
+AT_CHECK([$LIBTOOL -n --mode=link --tag=CC $CC $CFLAGS $LDFLAGS 
-Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -o libbaz.la baz.lo 
libboth.la -no-undefined -rpath /nonexistent],
+        [], [stdout], [ignore])
+AT_CHECK([grep Cocoa.ltframework stdout], [1], [], [])
+AT_CHECK([grep ' -framework Cocoa' stdout], [0], [ignore], [])
+
+AT_CHECK([$LIBTOOL -n --mode=link --tag=CC $CC $CFLAGS $LDFLAGS 
-Wl,-framework,Cocoa,-framework,ApplicationServices -o libbaz.la baz.lo 
libboth.la -no-undefined -rpath /nonexistent],
+        [], [stdout], [ignore])
+AT_CHECK([grep Cocoa.ltframework stdout], [1], [], [])
+AT_CHECK([grep ' -framework Cocoa' stdout], [0], [ignore], [])
+
+AT_CHECK([$LIBTOOL -n --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -Wl,-framework 
-Wl,Cocoa -Wl,-framework -Wl,ApplicationServices -o libbaz.la baz.lo libboth.la 
-no-undefined -rpath /nonexistent],
+        [], [stdout], [ignore])
+AT_CHECK([grep Cocoa.ltframework stdout], [1], [], [])
+AT_CHECK([grep ' -framework Cocoa' stdout], [0], [ignore], [])
+
+AT_CHECK([$LIBTOOL -n --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -Wl,-framework 
-Xlinker Cocoa -Wl,-framework -Xlinker ApplicationServices -o libbaz.la baz.lo 
libboth.la -no-undefined -rpath /nonexistent],
+        [], [stdout], [ignore])
+AT_CHECK([grep Cocoa.ltframework stdout], [1], [], [])
+AT_CHECK([grep ' -framework Cocoa' stdout], [0], [ignore], [])
+
+AT_CHECK([$LIBTOOL -n --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -Xlinker 
-framework -Wl,Cocoa -Xlinker -framework -Wl,ApplicationServices -o libbaz.la 
baz.lo libboth.la -no-undefined -rpath /nonexistent],
+        [], [stdout], [ignore])
+AT_CHECK([grep Cocoa.ltframework stdout], [1], [], [])
+AT_CHECK([grep ' -framework Cocoa' stdout], [0], [ignore], [])
+
 AT_CLEANUP




reply via email to

[Prev in Thread] Current Thread [Next in Thread]