Hi all,

I'm currently working on PHP extensions to bring some Mac OS X -native
functionality available to PHP users on the platform. To allow for this, the
PHP build chain needs to support Mac's way of dealing with shared libraries.
Here's some background:

Libraries in Mac OS X and Darwin are delivered in bundles called frameworks.
A framework is simply a directory containing a framework's header and
library files. It is hence atomic in the sense that it can be easily moved
around by a typical, GUI-bound Mac user. Frameworks can also contain
sub-frameworks, allowing for a hierarchical dependency tree to be presented
right on the filesystem level.

I don't need to go into details about the frameworks' structure because
Apple has abstracted that from the developer by providing extensions to the
GNU build tools on the Mac. In particular, Apple's versions of gcc, cpp and
ld support two new command line options: -F and -framework. -F, like the
traditional -I and -L options, add to the framework search path. -framework
specifies the framework used in linking, much like -l.

Anyway, I've written the following four new functions for acinclude.m4 to
enable the use of frameworks in the various config.m4 files. They do work,
but as it's been a long while since I've committed anything, much less m4, I
hope somebody can run the stuff through a quick sanity check and commit.
I've also added a change to PHP_SHLIB_SUFFIX_NAME below. Please email me if
you want this stuff in patch format.

Thanks, Marko

P.S. The changes naturally require support for frameworks in libtool. I have
a patch ready, and will submit it to the libtool list next week. Meanwhile,
what's the maintennance policy of the ltmain.sh file in our tree?
Should/could my changes to libtool be committed locally?

mk

---- cut here ----

dnl
dnl PHP_ADD_FRAMEWORKPATH(path [,before [, shared-libadd]])
dnl
dnl add a (Darwin / Mac OS X) framework path to the link
dnl and include lines. default paths include (but are
dnl not limited to) /Local/Library/Frameworks and
dnl /System/Library/Frameworks, so these don't need
dnl to be specifically added. if before is 1, the
dnl framework path is added to the beginning of the
dnl relevant lines.
AC_DEFUN(PHP_ADD_FRAMEWORKPATH, [
  PHP_EXPAND_PATH($1, ai_p)
  if test "$ext_shared" = "yes" && test -n "$3"; then
    if test "$2"; then
      $3="-F$ai_p [$]$3"
    else
      $3="[$]$3 -F$ai_p"
    fi
  else
    AC_PHP_ONCE(LIBPATH, $ai_p, [
      if test "$2"; then
        LDFLAGS="-F$ai_p $LDFLAGS"
      else
        LDFLAGS="$LDFLAGS -F$ai_p"
      fi
    ])
  fi
  AC_PHP_ONCE(INCLUDEPATH, $ai_p, [
    if test "$2"; then
      INCLUDES="-F$ai_p $INCLUDES"
    else
      INCLUDES="$INCLUDES -F$ai_p"
    fi
  ])
])

dnl
dnl PHP_ADD_FRAMEWORK(framework [,before [, shared-libadd]])
dnl
dnl add a (Darwin / Mac OS X) framework to the link
dnl line. if before is 1, the framework is added
dnl to the beginning of the line.
dnl
dnl (can't use AC_PHP_ONCE since $1 might match a
dnl FRAMEWORKPATH specified earlier)
AC_DEFUN(PHP_ADD_FRAMEWORK, [
  if test "$ext_shared" = "yes" && test -n "$3"; then
    if test "$2"; then
      $3="-framework $1 [$]$3"
    else
      $3="[$]$3 -framework $1"
    fi
  fi
  if test "$2"; then
    LIBS="-framework $1 $LIBS"
  else
    LIBS="$LIBS -framework $1"
  fi
])

dnl
dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path [, shared-libadd])
dnl
dnl add a (Darwin / Mac OS X) framework path and the
dnl framework itself to the link and include lines.
AC_DEFUN(PHP_ADD_FRAMEWORK_WITH_PATH, [
  PHP_ADD_FRAMEWORKPATH($2,,$3)
  PHP_ADD_FRAMEWORK($1,,$3)
])

dnl
dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [,
action-not-found ]])
dnl
dnl Cheezy wrapper for AC_CHECK_LIB
dnl
AC_DEFUN(PHP_CHECK_FRAMEWORK, [
  save_old_LDFLAGS=$LDFLAGS
  LDFLAGS="-framework $1 $LDFLAGS"
  dnl supplying "c" to AC_CHECK_LIB is technically cheating, but
  dnl rewriting AC_CHECK_LIB is overkill and this only affects
  dnl the "checking.." output anyway.
  AC_CHECK_LIB(c,[$2],[
    LDFLAGS=$save_old_LDFLAGS
    $3
  ],[
    LDFLAGS=$save_old_LDFLAGS
    $4
  ])
])

AC_DEFUN(PHP_SHLIB_SUFFIX_NAME,[
  PHP_SUBST(SHLIB_SUFFIX_NAME)
  SHLIB_SUFFIX_NAME=so
  case $host_alias in
  *hpux*)
    SHLIB_SUFFIX_NAME=sl
    ;;
  *darwin*)
    SHLIB_SUFFIX_NAME=dylib
    ;;
  esac
])



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to