Subject: pkg/28647: devel/SDL on darwin needs -framework support in libtool
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Darrin B.Jewell <dbj@netbsd.org>
List: pkgsrc-bugs
Date: 12/13/2004 19:37:01
>Number:         28647
>Category:       pkg
>Synopsis:       devel/SDL on darwin needs -framework support in libtool
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 13 19:37:00 +0000 2004
>Originator:     Darrin B. Jewell
>Release:        pkgsrc-2004Q3
>Organization:
>Environment:
$ uname -a
Darwin Quiteria 7.6.0 Darwin Kernel Version 7.6.0: Sun Oct 10 12:05:27 PDT 2004; root:xnu/xnu-517.9.4.obj~1/RELEASE_PPC  Power Macintosh powerpc
$
using xcode 1.5 + nov 2004 update for dev tools. (gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1671))
>Description:
  devel/SDL now uses the pkgsrc system libtool instead of the one
supplied with the SDL distribution.  However, the SDL distribution's libtool
includes extra support for -framework link arguments.

When compiling devel/SDL on macosx, the link will fail with a lot of
undefined symbols.

>How-To-Repeat:
   Build devel/SDL on macosx.
>Fix:

The following patch against the 2004Q3 version
of devel/libtool will add support for -framework arguments
to libtool.  With this change, then devel/SDL will build cleanly.

Unfortunately, I haven't ported this patch to the trunk, since I'm
not using the trunk, but I hope it is straightforward.

If this patch-to-a-patch is suboptimal, let me know and
I can provide this fix in another format.

Thanks,
Darrin

Index: patch-ac
===================================================================
RCS file: /u3/n/rsync/cvsroot/pkgsrc/devel/libtool/patches/patch-ac,v
retrieving revision 1.12
diff -u -r1.12 patch-ac
--- patch-ac	22 Apr 2004 14:40:29 -0000	1.12
+++ patch-ac	13 Dec 2004 18:35:51 -0000
@@ -1,6 +1,6 @@
-$NetBSD: patch-ac,v 1.12 2004/04/22 14:40:29 tv Exp $
+$NetBSD$
 
---- ltmain.sh.orig	Sun Apr 11 01:44:45 2004
+--- ltmain.sh.orig	Mon Dec 13 13:24:30 2004
 +++ ltmain.sh
 @@ -192,10 +192,26 @@ func_infer_tag () {
        case $@ in
@@ -62,7 +62,88 @@
  	  if test "$prev" = rpath; then
  	    case "$rpath " in
  	    *" $arg "*) ;;
-@@ -2983,8 +3004,8 @@ EOF
+@@ -1227,6 +1248,19 @@ EOF
+ 	  prev=
+ 	  continue
+ 	  ;;
++	framework)
++	  case $host in
++	    *-*-darwin*)
++	      case "$deplibs " in
++	        *" $qarg.framework "*) ;;
++		*) deplibs="$deplibs $qarg.framework" # this is fixed later
++		   ;;
++              esac
++              ;;
++   	  esac
++	  prev=
++	  continue
++	  ;;
+ 	*)
+ 	  eval "$prev=\"\$arg\""
+ 	  prev=
+@@ -1548,6 +1582,11 @@ EOF
+ 	continue
+ 	;;
+ 
++      -framework)
++        prev=framework
++	continue
++	;;
++
+       # Some other compiler flag.
+       -* | +*)
+ 	# Unknown arguments in both finalize_command and compile_command need
+@@ -1931,6 +1970,18 @@ EOF
+ 	    fi
+ 	  fi
+ 	  ;; # -l
++	*.framework)
++	  if test "$linkmode,$pass" = "prog,link"; then
++	    compile_deplibs="$deplib $compile_deplibs"
++	    finalize_deplibs="$deplib $finalize_deplibs"
++	  else
++	    deplibs="$deplib $deplibs"
++	    if test "$linkmode" = lib ; then
++	      newdependency_libs="$deplib $newdependency_libs"
++	    fi
++	  fi
++	  continue
++	  ;;
+ 	-L*)
+ 	  case $linkmode in
+ 	  lib)
+@@ -2059,6 +2110,13 @@ EOF
+ 	*) . ./$lib ;;
+ 	esac
+ 
++	case $host in
++	*-*-darwin*)
++	  # Convert "-framework foo" to "foo.framework" in dependency_libs
++	  test -n "$dependency_libs" && dependency_libs=`$echo "X$dependency_libs" | $Xsed -e 's/-framework \([^ $]*\)/\1.framework/g'`
++	  ;;
++	esac
++
+ 	if test "$linkmode,$pass" = "lib,link" ||
+ 	   test "$linkmode,$pass" = "prog,scan" ||
+ 	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+@@ -2668,6 +2726,15 @@ EOF
+ 		*) continue ;;
+ 		esac
+ 		;;
++
++	      *.framework)
++		case $host in
++		  *-*-darwin*)
++		    depdepl="$deplib"
++		    ;;
++		esac
++		;;
++
+ 	      *) continue ;;
+ 	      esac
+ 	      case " $deplibs " in
+@@ -2983,8 +3050,8 @@ EOF
  	darwin)
  	  # Like Linux, but with the current version available in
  	  # verstring for coding it into the library header
@@ -73,7 +154,38 @@
  	  # Darwin ld doesn't like 0 for these options...
  	  minor_current=`expr $current + 1`
  	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
-@@ -5384,8 +5405,16 @@ relink_command=\"$relink_command\""
+@@ -3527,6 +3594,13 @@ EOF
+ 	    fi
+ 	  fi
+ 	fi
++	# Time to change all our "foo.framework" stuff back to "-framework foo"
++	case $host in
++	  *-*-darwin*)
++	    newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'`
++	    dependency_libs=`$echo "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).framework%%g'`
++	    ;;
++	esac
+ 	# Done checking deplibs!
+ 	deplibs=$newdeplibs
+       fi
+@@ -4122,12 +4196,15 @@ EOF
+       esac
+ 
+       case $host in
+-      *darwin*)
++      *-*-darwin*)
+         # Don't allow lazy linking, it breaks C++ global constructors
+         if test "$tagname" = CXX ; then
+         compile_command="$compile_command ${wl}-bind_at_load"
+         finalize_command="$finalize_command ${wl}-bind_at_load"
+         fi
++	# Time to change all our "foo.framework" stuff back to "-framework foo"
++	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'`
++	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'`
+         ;;
+       esac
+ 
+@@ -5384,8 +5461,16 @@ relink_command=\"$relink_command\""
        exit $EXIT_FAILURE
      fi