Index: libs/libmythtv/jobqueue.cpp
===================================================================
--- libs/libmythtv/jobqueue.cpp	(revision 8766)
+++ libs/libmythtv/jobqueue.cpp	(working copy)
@@ -1705,7 +1705,8 @@
                             "autodetect" :
                             QString::number(transcoder);
 
-    QString path = gContext->GetInstallPrefix() + "/bin/mythtranscode";
+    QString path = gContext->GetAppPath("mythtranscode");
+
     QString command = QString("%1 -j %2 -V %3 -p %4 %5")
                       .arg(path).arg(jobID).arg(print_verbose_messages)
                       .arg(profilearg.ascii()).arg(useCutlist ? "-l" : "");
@@ -2008,7 +2009,7 @@
     gContext->LogEntry("commflag", LP_NOTICE, msg, logDesc);
 
     int breaksFound = 0;
-    QString path = gContext->GetInstallPrefix() + "/bin/mythcommflag";
+    QString path = gContext->GetAppPath("mythcommflag");
     QString cmd = QString("%1 -j %2 -V %3")
                           .arg(path).arg(jobID).arg(print_verbose_messages);
 
Index: libs/libmythtv/progfind.h
===================================================================
--- libs/libmythtv/progfind.h	(revision 8766)
+++ libs/libmythtv/progfind.h	(working copy)
@@ -95,7 +95,6 @@
 
     TV *m_player;
 
-    QString baseDir;
     QString *searchData;
     QString *initData;
     QString *progData;
Index: libs/libmythtv/progfind.cpp
===================================================================
--- libs/libmythtv/progfind.cpp	(revision 8766)
+++ libs/libmythtv/progfind.cpp	(working copy)
@@ -88,8 +88,6 @@
     inFill = false;
     needFill = false;
 
-    baseDir = gContext->GetInstallPrefix();
-
     listRect = QRect(0, 0, 0, 0);
     infoRect = QRect(0, 0, 0, 0);
 
Index: libs/libmyth/lcddevice.cpp
===================================================================
--- libs/libmyth/lcddevice.cpp	(revision 8766)
+++ libs/libmyth/lcddevice.cpp	(working copy)
@@ -142,7 +142,7 @@
     {
         // we need to start the mythlcdserver 
         startedServer = true;
-        system(gContext->GetInstallPrefix() + "/bin/mythlcdserver -v none&");
+        system(gContext->GetAppPath("mythlcdserver") + " -v none&");
         // have to disconnect the error signal otherwise we get connection refused
         // errors while the server is starting up 
         disconnect(socket, SIGNAL(error(int)), 0, 0);
Index: libs/libmyth/mythcontext.h
===================================================================
--- libs/libmyth/mythcontext.h	(revision 8766)
+++ libs/libmyth/mythcontext.h	(working copy)
@@ -264,7 +264,7 @@
     void BlockShutdown(void);
     void AllowShutdown(void);
     
-    QString GetInstallPrefix(void);
+    QString GetAppPath(QString app_name);
     QString GetShareDir(void);
     QString GetLibraryDir(void);
     static QString GetConfDir(void);
Index: libs/libmyth/mythcontext.cpp
===================================================================
--- libs/libmyth/mythcontext.cpp	(revision 8766)
+++ libs/libmyth/mythcontext.cpp	(working copy)
@@ -3,6 +3,7 @@
 #include <qimage.h>
 #include <qpixmap.h>
 #include <qdir.h>
+#include <qfileinfo.h>
 #include <qpainter.h>
 #include <unistd.h>
 #include <qsqldatabase.h>
@@ -185,7 +186,11 @@
     Settings *m_settings;
     Settings *m_qtThemeSettings;
 
-    QString m_installprefix;
+    QDir m_self_directory;
+#ifdef CONFIG_DARWIN
+    bool m_in_package;
+#endif 
+    QString m_share_parent;
 
     bool m_gui;
     bool m_backend;
@@ -254,11 +259,27 @@
 };
 
 
+namespace
+{
+  QDir compute_self_directory()
+  {
+#if QT_VERSION >= 0x030200
+      return qApp->applicationDirPath();
+#else
+      QString appPath = QFileInfo(qApp->argv()[0]).absFilePath();
+      return QDir(appPath.left(appPath.findRev("/")));
+#endif
+  }
+}
 
 MythContextPrivate::MythContextPrivate(MythContext *lparent)
     : parent(lparent),
       m_settings(new Settings()), m_qtThemeSettings(new Settings()),
-      m_installprefix(PREFIX),
+      m_self_directory( compute_self_directory() ),
+#ifdef CONFIG_DARWIN
+      m_in_package( m_self_directory.path().contains(".app/Contents/MacOS") ),
+#endif 
+      m_share_parent(),
       m_gui(false), m_backend(false), m_themeloaded(false),
       m_menuthemepathname(QString::null), m_themepathname(QString::null),
       m_backgroundimage(NULL),
@@ -283,33 +304,36 @@
       display_res(NULL),
       m_priv_mutex(new QMutex(true))
 {
+    
     char *tmp_installprefix = getenv("MYTHTVDIR");
-    if (tmp_installprefix)
-        m_installprefix = tmp_installprefix;
+    QString installprefix(tmp_installprefix ? tmp_installprefix : PREFIX);
 
-#if QT_VERSION >= 0x030200
-    QDir prefixDir = qApp->applicationDirPath();
-#else
-    QString appPath = QFileInfo(qApp->argv()[0]).absFilePath();
-    QDir prefixDir(appPath.left(appPath.findRev("/")));
-#endif
+#ifdef CONFIG_DARWIN
+    QDir resource_dir(m_self_directory);
+    resource_dir.cd("../Resources");
+    if (m_in_package && QDir(resource_dir.canonicalPath() + "/share").exists())
+    {
+        m_share_parent = resource_dir.canonicalPath();
+    }
+    else
+#endif 
 
-    if (QDir(m_installprefix).isRelative())
+    if (QDir(installprefix).isRelative())
     {
+        QDir prefixDir(m_self_directory);
         // If the PREFIX is relative, evaluate it relative to our
         // executable directory. This can be fragile on Unix, so
         // use relative PREFIX values with care.
-        prefixDir.cd(m_installprefix);
-        m_installprefix = prefixDir.canonicalPath();
+        prefixDir.cd(installprefix);
+        m_share_parent = prefixDir.canonicalPath();
     }
-    else if (prefixDir.path().contains(".app/Contents/MacOS"))
+    else
     {
-        prefixDir.cd("../Resources");
-        if (QDir(prefixDir.canonicalPath() + "/share").exists())
-            m_installprefix = prefixDir.canonicalPath();
+        m_share_parent = installprefix;
     }
+
     VERBOSE(VB_IMPORTANT, QString("Using runtime prefix = %1")
-            .arg(m_installprefix));
+            .arg(m_share_parent));
 }
 
 // Get screen size from Qt. If the windowing system environment
@@ -1091,9 +1115,17 @@
     return GetSetting("RecordFilePrefix");
 }
 
-QString MythContext::GetInstallPrefix(void) 
+QString MythContext::GetAppPath(QString executable_name) 
 { 
-    return d->m_installprefix; 
+#ifdef CONFIG_DARWIN
+    if ( d->m_in_package )
+    {
+        QString path(d->m_self_directory.path() + "/" + executable_name); 
+        if ( QFileInfo(path).exists() )
+            return path;
+    }
+#endif 
+    return d->m_share_parent + "/bin/" + executable_name; 
 }
 
 QString MythContext::GetConfDir(void)
@@ -1115,12 +1147,12 @@
 
 QString MythContext::GetShareDir(void) 
 { 
-    return d->m_installprefix + "/share/mythtv/"; 
+    return d->m_share_parent + "/share/mythtv/"; 
 }
 
 QString MythContext::GetLibraryDir(void) 
 { 
-    return d->m_installprefix + "/lib/mythtv/"; 
+    return d->m_share_parent + "/lib/mythtv/"; 
 }
 
 QString MythContext::GetThemesParentDir(void) 
@@ -1180,7 +1212,7 @@
 
 bool MythContext::LoadSettingsFiles(const QString &filename)
 {
-    return d->m_settings->LoadSettingsFiles(filename, d->m_installprefix);
+    return d->m_settings->LoadSettingsFiles(filename, d->m_share_parent);
 }
 
 void MythContext::LoadQtConfig(void)
@@ -1346,7 +1378,7 @@
     
 void MythContext::CacheThemeImages(void)
 {
-    QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
+    QString baseDir = GetThemesParentDir() + "default/";
 
     if (d->m_screenwidth == d->m_baseWidth && d->m_screenheight == d->m_baseHeight)
         return;
@@ -1632,7 +1664,7 @@
     if (dir.exists())
         return testdir;
 
-    testdir = d->m_installprefix + "/share/mythtv/themes/" + themename;
+    testdir = GetThemesParentDir() + themename;
     dir.setPath(testdir);
     if (dir.exists())
         return testdir;
@@ -1646,13 +1678,13 @@
     // Don't complain about the "default" theme being missing
     if (themename == QObject::tr("Default"))
     {
-        testdir = d->m_installprefix + "/share/mythtv/";
+        testdir = GetShareDir();
         dir.setPath(testdir);
         if (dir.exists())
             return testdir;
     }
 
-    testdir = d->m_installprefix + "/share/mythtv/themes/G.A.N.T.";
+    testdir = GetThemesParentDir() + "G.A.N.T.";
     dir.setPath(testdir);
     if (dir.exists())
         return testdir;
@@ -2019,7 +2051,7 @@
 
 bool MythContext::FindThemeFile(QString &filename)
 {
-    QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
+    QString baseDir = GetThemesParentDir() + "/default/";
     QString file;
     int pathStart = filename.findRev('/');
     bool bFound = false;
@@ -2073,7 +2105,7 @@
 {
     if (filename.left(5) == "myth:")
         return NULL;
-    QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
+    QString baseDir = GetThemesParentDir() + "/default/";
 
     if (d->themecachedir != "" && fromcache)
     {
@@ -2167,7 +2199,7 @@
 {
     if (filename.left(5) == "myth:")
         return NULL;
-    QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
+    QString baseDir = GetThemesParentDir() + "/default/";
 
     if (d->themecachedir != "" && fromcache)
     {
Index: programs/mythfrontend/globalsettings.cpp
===================================================================
--- programs/mythfrontend/globalsettings.cpp	(revision 8766)
+++ programs/mythfrontend/globalsettings.cpp	(working copy)
@@ -2495,7 +2498,7 @@
 {
     GlobalLineEdit *be = new GlobalLineEdit("MythFillDatabasePath");
     be->setLabel(QObject::tr("mythfilldatabase Path"));
-    be->setValue(gContext->GetInstallPrefix() + "/bin/mythfilldatabase");
+    be->setValue(gContext->GetAppPath("mythfilldatabase"));
     be->setHelpText(QObject::tr("Path (including executable) of the "
                     "mythfilldatabase program."));
     return be;
Index: programs/mythwelcome/welcomedialog.h
===================================================================
--- programs/mythwelcome/welcomedialog.h	(revision 8766)
+++ programs/mythwelcome/welcomedialog.h	(working copy)
@@ -67,7 +67,7 @@
     QTimer         *m_updateScreenTimer;
     QTimer         *m_timeTimer;
 
-    QString        m_installDir;
+    QString        m_shutdown_app;
     QString        m_timeFormat;
     bool           m_isRecording;
     bool           m_hasConflicts;
Index: programs/mythwelcome/welcomedialog.cpp
===================================================================
--- programs/mythwelcome/welcomedialog.cpp	(revision 8766)
+++ programs/mythwelcome/welcomedialog.cpp	(working copy)
@@ -22,7 +22,8 @@
                                  QString window_name,
                                  QString theme_filename,
                                  const char* name)
-                :MythThemedDialog(parent, window_name, theme_filename, name)
+  : MythThemedDialog(parent, window_name, theme_filename, name)
+    , m_shutdown_app(gContext->GetAppPath("mythshutdown"))
 {
     checkConnectionToServer();
     
@@ -33,7 +34,6 @@
 
     gContext->addListener(this);
         
-    m_installDir = gContext->GetInstallPrefix();
     m_preRollSeconds = gContext->GetNumSetting("RecordPreRoll");
     m_idleWaitForRecordingTime =
                        gContext->GetNumSetting("idleWaitForRecordingTime", 15);
@@ -71,8 +71,9 @@
 {
     gContext->removeListener(this);
 
-    QString startFECmd = gContext->GetSetting("MythWelcomeStartFECmd", 
-                         m_installDir + "/bin/mythfrontend");
+    QString startFECmd = gContext->GetSetting(
+        "MythWelcomeStartFECmd",
+        gContext->GetAppPath("mythfrontend"));
 
     myth_system(startFECmd.ascii());
 
@@ -89,7 +90,7 @@
 {
     // mythshutdown --startup returns 0 for automatic startup
     //                                1 for manual startup 
-    int state = system(m_installDir + "/bin/mythshutdown --startup");
+    int state = system(m_shutdown_app + " --startup");
 
     if (WIFEXITED(state))
         state = WEXITSTATUS(state);
@@ -193,15 +194,15 @@
         }
         else if (action == "0")
         {
-            int statusCode = system(m_installDir + "/bin/mythshutdown --status");
+            int statusCode = system(m_shutdown_app + " --status");
             if (WIFEXITED(statusCode))
                 statusCode = WEXITSTATUS(statusCode);
         
             // is shutdown locked by a user
             if (statusCode & 16)
-                system(m_installDir + "/bin/mythshutdown --unlock");
+                system(m_shutdown_app + " --unlock");
             else    
-                system(m_installDir + "/bin/mythshutdown --lock");
+                system(m_shutdown_app + " --lock");
                     
             updateStatusMessage();
             updateScreen();    
@@ -583,7 +584,7 @@
         m_statusList.append(tr("MythTV is busy recording."));
     }
         
-    int statusCode = system(m_installDir + "/bin/mythshutdown --status");
+    int statusCode = system(m_shutdown_app + " --status");
     if (WIFEXITED(statusCode))
         statusCode = WEXITSTATUS(statusCode);
     
@@ -641,7 +642,7 @@
     QLabel *label = popup->addLabel(tr("Menu"), MythPopupBox::Large, false);
     label->setAlignment(Qt::AlignCenter | Qt::WordBreak);
     
-    int statusCode = system(m_installDir + "/bin/mythshutdown --status");
+    int statusCode = system(m_shutdown_app + " --status");
     if (WIFEXITED(statusCode))
         statusCode = WEXITSTATUS(statusCode);
  
@@ -680,7 +681,7 @@
 void WelcomeDialog::lockShutdown(void)
 {
     cancelPopup();
-    system(m_installDir + "/bin/mythshutdown --lock");
+    system(m_shutdown_app + " --lock");
     updateStatusMessage();
     updateScreen();
 }
@@ -688,7 +689,7 @@
 void WelcomeDialog::unlockShutdown(void)
 {
     cancelPopup();
-    system(m_installDir + "/bin/mythshutdown --unlock");
+    system(m_shutdown_app +" --unlock");
     updateStatusMessage();
     updateScreen();
 }
@@ -737,7 +738,7 @@
     }
 
     // don't shutdown if we are about to start a wakeup/shutdown period
-    int statusCode = system(m_installDir + "/bin/mythshutdown --status");
+    int statusCode = system(m_shutdown_app + " --status");
     if (WIFEXITED(statusCode))
         statusCode = WEXITSTATUS(statusCode);
         
@@ -780,6 +781,6 @@
     }
     
     // run command to set wakeuptime in bios and shutdown the system
-    system("sudo " + m_installDir + "/bin/mythshutdown --shutdown");
+    system("sudo " + m_shutdown_app + " --shutdown");
 }
 
Index: programs/mythwelcome/welcomesettings.cpp
===================================================================
--- programs/mythwelcome/welcomesettings.cpp	(revision 8766)
+++ programs/mythwelcome/welcomesettings.cpp	(working copy)
@@ -154,7 +154,7 @@
 {
     HostLineEdit *gc = new HostLineEdit("MythWelcomeStartFECmd");
     gc->setLabel(QObject::tr("Command to run to start the Frontend"));
-    gc->setValue(gContext->GetInstallPrefix() + "/bin/mythfrontend");
+    gc->setValue(gContext->GetAppPath("mythfrontend"));
     gc->setHelpText(QObject::tr("Command to start mythfrontend.")); 
     return gc;
 };
Index: contrib/osx-packager.pl
===================================================================
--- contrib/osx-packager.pl	(revision 8766)
+++ contrib/osx-packager.pl	(working copy)
@@ -159,7 +162,7 @@
 #   },
   {
     'url'
-    =>  'ftp://ftp.iasi.roedu.net/mirrors/ftp.trolltech.com/qt/sources/qt-mac-free-3.3.4.tar.gz',
+    =>  'ftp://ftp.iasi.roedu.net/mirrors/ftp.trolltech.com/qt/sources/qt-mac-free-3.3.5.tar.gz',
     'conf-cmd'
     =>  'echo yes | ./configure',
     'conf'
@@ -191,7 +194,13 @@
     =>  [
           'sub-src',
           'qmake-install',
-          'moc-install'
+          'moc-install',
+         
+         # we need this.  If the library isn't copied to
+         # $PREFIX/build/lib then it gets its references modified in
+         # place.  That will screw up linking the next time around, as
+         # the references can't be found in the expected location.
+          'src-install'
         ],
   },
   
@@ -211,6 +220,22 @@
     =>  [
           '--disable-nls',
         ],
+    'post-conf' 
+    # correct a bug that prevents compilation.  This patch is already
+    # in the exif developers' CVS repository.  Why they haven't
+    # released a new version with the fix, I don't know.
+    =>  'echo "--- libexif/libexif/libexif/exif-utils.c2005/03/10 20:48:211.10
++++ libexif/libexif/libexif/exif-utils.c2005/03/31 12:24:311.11
+@@ -83,7 +83,7 @@
+ }
+ }
+ 
+-static ExifSShort
++ExifSShort
+ exif_get_sshort (const unsigned char *buf, ExifByteOrder order)
+ {
+ if (!buf) return 0;
+" | patch -u --verbose libexif/exif-utils.c'
   },
   
 );
@@ -702,25 +740,23 @@
 
   chdir $compdir;
   
-  if ($comp eq 'mythtv')
-  {
-    # MythTV has an empty subdirectory 'config' that causes problems for me:
-    &Syscall('touch config/config.pro');
-  }
-
   if ($OPT{'clean'} && -e 'Makefile')
   {
     &Verbose("Cleaning $comp");
@@ -750,13 +788,16 @@
 
   if ($comp eq 'mythtv')
   {
+    # MythTV has an empty subdirectory 'config' that causes problems for me:
+    &Syscall('touch config/config.pro');
+
     # Remove Nigel's frontend speedup hack
     &DoSpeedupHacks('programs/programs.pro', 'mythfrontend');
     &DoSpeedupHacks('mythtv.pro', 'libs filters programs themes i18n');
   }
   
   &Verbose("Making $comp");
   &Syscall([ '/usr/bin/make' ]) or die;
   # install
   # This requires a change from the compiled-in relative
   # PREFIX to our absolute path of the temp install location.
@@ -797,34 +851,14 @@
   # Get a fresh copy of the app
   &Verbose("Building self-contained $target");
   &Syscall([ 'rm', '-fr', $finalTarget ]) or die;
-  &Syscall([ '/bin/cp', '-R',
-             "$PREFIX/bin/$builtTarget.app",
-             $finalTarget ]) or die;
+  &RecursiveCopy("$PREFIX/bin/$builtTarget.app", $finalTarget);
   
   # write a custom Info.plist
   &GeneratePlist($target, $builtTarget, $finalTarget, $VERS);
   
   # Make frameworks from Myth libraries
   &Verbose("Installing frameworks into $target");
-  my $fw_dir = "$finalTarget/Contents/Frameworks";
-  mkdir($fw_dir);
-  my $dephash = &ProcessDependencies("$finalTarget/Contents/MacOS/$builtTarget",
-                                     glob("$PREFIX/lib/mythtv/*/*.dylib"));
-  my @deps = values %$dephash;
-  while (scalar @deps)
-  {
-    my $dep = shift @deps;
-    next if $dep =~ m/executable_path/;
-
-    my $file = &MakeFramework(&FindLibraryFile($dep), $fw_dir);
-    my $newhash = &ProcessDependencies($file);
-    foreach my $base (keys %$newhash)
-    {
-      next if exists $dephash->{$base};
-      $dephash->{$base} = $newhash->{$base};
-      push(@deps, $newhash->{$base});
-    }
-  }
+  &PackagedExecutable($finalTarget, $builtTarget);
   
  if ( $target eq "MythFrontend" or $target eq "MythTV-Setup" )
  {
@@ -832,13 +866,11 @@
   &Verbose("Installing resources into $target");
   mkdir "$finalTarget/Contents/Resources";
   mkdir "$finalTarget/Contents/Resources/lib";
-  &Syscall([ '/bin/cp', '-R',
-             "$PREFIX/lib/mythtv",
-             "$finalTarget/Contents/Resources/lib" ]) or die;
+  &RecursiveCopy("$PREFIX/lib/mythtv",
+                 "$finalTarget/Contents/Resources/lib");
   mkdir "$finalTarget/Contents/Resources/share";
-  &Syscall([ '/bin/cp', '-R',
-             "$PREFIX/share/mythtv",
-             "$finalTarget/Contents/Resources/share" ]) or die;
+  &RecursiveCopy( "$PREFIX/share/mythtv",
+                  "$finalTarget/Contents/Resources/share" );
  }
 }
 
@@ -851,7 +883,8 @@
     if ( -e $SRC )
     {
       &Syscall([ '/bin/cp', $SRC,
-                 "$SCRIPTDIR/MythBackend.app/Contents/MacOS" ]) or die
+                 "$SCRIPTDIR/MythBackend.app/Contents/MacOS" ]) or die;
+      PackagedExecutable("$SCRIPTDIR/MythBackend.app", $binary);
     }
   }
 }
@@ -866,7 +899,10 @@
 
   $SRC  = "$PREFIX/bin/mythtranscode.app/Contents/MacOS/mythtranscode";
   if ( -e $SRC )
-  { &Syscall([ '/bin/cp', $SRC, $DEST ]) or die }
+  { 
+      &Syscall([ '/bin/cp', $SRC, $DEST ]) or die 
+      PackagedExecutable("$SCRIPTDIR/MythJobQueue.app", 'mythcommflag');
+  }
 }
 
 if ($OPT{usehdimage})
@@ -881,8 +917,72 @@
 exit 0;
 
 
+######################################
+## RecursiveCopy copies a directory tree, stripping out .svn
+## directories and properly managing static libraries.
+######################################
 
+sub RecursiveCopy
+{
+    my ($src, $dst) = @_;
+
+    # First copy absolutely everything
+    &Syscall([ '/bin/cp', '-R', "$src", "$dst"]) or die;
+
+    # Then strip out any .svn directories
+    my @files = map { chomp $_; $_ } `find $dst -name .svn`;
+    if (scalar @files)
+    {
+        &Syscall([ '/bin/rm', '-f', '-r', @files ]);
+    }
+
+    # And make sure any static libraries are properly relocated.
+    my @libs = map { chomp $_; $_ } `find $dst -name "lib*.a"`;
+    if (scalar @libs)
+    {
+        &Syscall([ 'ranlib', '-s', @libs ]);
+    }
+}
+
 ######################################
+## Given an application package $finalTarget and an executable
+## $builtTarget that has been copied into it, PackagedExecutable
+## makes sure the package contains all the library dependencies as
+## frameworks and that all the paths internal to the executable have
+## been adjusted appropriately.
+######################################
+
+sub PackagedExecutable
+{
+  my ($finalTarget, $builtTarget) = @_;
+
+  my $fw_dir = "$finalTarget/Contents/Frameworks";
+  mkdir($fw_dir);
+
+  my $dephash = &ProcessDependencies("$finalTarget/Contents/MacOS/$builtTarget",
+                                     glob("$PREFIX/lib/mythtv/*/*.dylib"));
+  my @deps = values %$dephash;
+  while (scalar @deps)
+  {
+    my $dep = shift @deps;
+    next if $dep =~ m/executable_path/;
+
+    my $file = &MakeFramework( &FindLibraryFile($dep), $fw_dir );
+    if ($file)
+    {
+      my $newhash = &ProcessDependencies($file);
+      foreach my $base (keys %$newhash)
+      {
+        next if exists $dephash->{$base};
+        $dephash->{$base} = $newhash->{$base};
+        push(@deps, $newhash->{$base});
+      }
+    }
+  }
+}
+
+
+######################################
 ## MakeFramework copies a dylib into a
 ## framework bundle.
 ######################################
@@ -892,10 +992,13 @@
   my ($dylib, $dest) = @_;
   
   my ($base, $vers) = &BaseVers($dylib);
-  $vers .= '.' . $OPT{'version'} if ($OPT{'version'} && $base =~ /myth/);
+  my $vers .= '.' . $OPT{'version'} if ($OPT{'version'} && $base =~ /myth/);
+  my $fw_dir = $dest . '/' . $base . '.framework';
+  
+  return '' if ( -e $fw_dir );
+
   &Verbose("Building $base framework");
-  
-  my $fw_dir = $dest . '/' . $base . '.framework';
+
   &Syscall([ '/bin/mkdir',
              '-p',
              "$fw_dir/Versions/A/Resources" ]) or die;
@@ -1052,8 +1154,11 @@
       chomp $dep;
       $dep =~ s/\s+(.*) \(.*\)$/$1/;
       
+      # /usr/lib/libstdc++, for example, contains quantifiers that must be escaped
+      $dep =~ s/([+*?])/\\$1/;
+      
       # otool sometimes lists the framework as depending on itself
       next if ($file =~ m,/Versions/A/$dep,);
 
       # Any dependency which is already package relative can be ignored
       next if $dep =~ m/\@executable_path/;
