[PATCH] Appbundle-Support for 1.2 - Mailing list pgadmin-hackers

From Florian G. Pflug
Subject [PATCH] Appbundle-Support for 1.2
Date
Msg-id 428477F8.1040403@phlo.org
Whole thread Raw
List pgadmin-hackers
Hi

Here is the appbundle-support for 1.2
Attach is a patch against the current 1.2 branch.
It works the same as the trunk-appbundle-support did
before the Big Reorganization.

At www.phlo.org/pgadmin3-1.2-appbundle.tar.bz2
you'll find a tar.bz which contains pkg/Makefile.am and
pkg/mac/*. Please extract this into the src_root,
and apply the patch there too..

This additionally contains a few fixed for wx 2.6 detection,
because it didn't compile sucessfully - at least on osx.

greetings, Florian Pflug
Index: src/pgAdmin3.cpp
===================================================================
--- src/pgAdmin3.cpp    (revision 4178)
+++ src/pgAdmin3.cpp    (working copy)
@@ -20,6 +20,7 @@
 #include <wx/imagjpeg.h>
 #include <wx/imaggif.h>
 #include <wx/imagpng.h>
+#include <wx/stdpaths.h>


 // Windows headers
@@ -75,6 +76,8 @@
 #define DOC_DIR     wxT("/docs")
 #define UI_DIR      wxT("/ui")
 #define COMMON_DIR  wxT("/common")
+#define SCRIPT_DIR  wxT("/scripts")
+#define HELPER_DIR  wxT("/helper")
 #define LANG_FILE   wxT("pgadmin3.lng")


@@ -133,7 +136,7 @@

     // evaluate all working paths

-#ifdef __WIN32__
+#if defined(__WIN32__)

     backupExecutable  = path.FindValidPath(wxT("pg_dump.exe"));
     restoreExecutable = path.FindValidPath(wxT("pg_restore.exe"));
@@ -148,6 +151,33 @@
     else
         docPath = loadPath + wxT("/../..") DOC_DIR;

+#elif defined(__WXMAC__)
+
+    //When using wxStandardPaths on OSX, wx defaults to the unix,
+    //not to the mac variants. Therefor, we request wxStandardPathsCF
+    //directly.
+    wxStandardPathsCF stdPaths ;
+    wxString dataDir = stdPaths.GetDataDir() ;
+    if (dataDir) {
+        wxFprintf(stderr, wxT("DataDir: ") + dataDir + wxT("\n")) ;
+    if (wxDir::Exists(dataDir + HELPER_DIR))
+            path.Add(dataDir + HELPER_DIR) ;
+        if (wxDir::Exists(dataDir + SCRIPT_DIR))
+            path.Add(dataDir + SCRIPT_DIR) ;
+        if (wxDir::Exists(dataDir + UI_DIR))
+          uiPath = dataDir + UI_DIR ;
+        if (wxDir::Exists(dataDir + DOC_DIR))
+          docPath = dataDir + DOC_DIR ;
+    }
+
+    if (uiPath.IsEmpty())
+        uiPath = loadPath + UI_DIR ;
+    if (docPath.IsEmpty())
+        docPath = loadPath + wxT("/..") DOC_DIR ;
+
+    backupExecutable  = path.FindValidPath(wxT("pg_dump"));
+    restoreExecutable = path.FindValidPath(wxT("pg_restore"));
+
 #else

     backupExecutable  = path.FindValidPath(wxT("pg_dump"));
@@ -162,6 +192,7 @@
         docPath = DATA_DIR DOC_DIR;
     else
         docPath = loadPath + wxT("/..") DOC_DIR;
+
 #endif


Index: src/Makefile.am
===================================================================
--- src/Makefile.am    (revision 4178)
+++ src/Makefile.am    (working copy)
@@ -130,7 +130,7 @@
 #
 ##############################################################################

-nobase_dist_pkgdata_DATA = ui/common/*.xrc \
+TMP_ui = ui/common/*.xrc \
 ui/wxstd.mo \
 ui/pgadmin3.lng \
 ui/af_ZA/pgadmin3.mo \
@@ -177,6 +177,30 @@
 ui/zh_CN/wxstd.mo \
 ui/zh_TW/wxstd.mo

+if !APPBUNDLE
+
+nobase_dist_pkgdata_DATA = $(TMP_ui)
 AM_CXXFLAGS = -DDATA_DIR=\"$(pkgdatadir)/\" -Wall -g -I$(top_srcdir)/src/include -I$(top_srcdir)/src/agent/include
 AM_CPPFLAGS = -DDATA_DIR=\"$(pkgdatadir)/\" -Wall -g -I$(top_srcdir)/src/include -I$(top_srcdir)/src/agent/include
 AM_CFLAGS = -DDATA_DIR=\"$(pkgdatadir)/\" -Wall -g -I$(top_srcdir)/src/include -I$(top_srcdir)/src/agent/include
+
+# Automake trys to execute install-exec-hook if it appears anywhere in the file, so we need a dummy
+# for non-APPBUNDLE cases.
+install-exec-hook:
+
+else
+
+nobase_dist_data_DATA = $(TMP_ui)
+AM_CXXFLAGS = -Wall -g -I$(top_srcdir)/src/include -I$(top_srcdir)/src/agent/include
+AM_CPPFLAGS = -Wall -g -I$(top_srcdir)/src/include -I$(top_srcdir)/src/agent/include
+AM_CFLAGS = -Wall -g -I$(top_srcdir)/src/include -I$(top_srcdir)/src/agent/include
+
+install-exec-hook:
+    cd $(bindir) ;\
+    mv pgadmin3 tmp ;\
+    mv tmp pgAdmin3 ;\
+    if test "$(pg_debug_build)" = "no"; then \
+        strip pgAdmin3 ;\
+    fi
+
+endif
Index: src/ui/frmMain.cpp
===================================================================
--- src/ui/frmMain.cpp    (revision 4178)
+++ src/ui/frmMain.cpp    (working copy)
@@ -164,6 +164,9 @@
 #endif
     fileMenu->AppendSeparator();
     fileMenu->Append(MNU_EXIT, _("E&xit\tAlt-F4"),                _("Quit this program."));
+#ifdef __WXMAC__
+    wxApp::s_macExitMenuItemId = MNU_EXIT;
+#endif
     menuBar->Append(fileMenu, _("&File"));

     // Edit Menu
Index: configure.ac
===================================================================
--- configure.ac    (revision 4178)
+++ configure.ac    (working copy)
@@ -30,6 +30,8 @@
 AC_CHECK_FUNCS([gethostbyname inet_ntoa memmove memset strchr])

 # Custom checks
+ENABLE_APPBUNDLE
+AM_CONDITIONAL([APPBUNDLE], [test x$pg_appbundle = xyes])
 CHECK_WX_CONFIG_BINARY
 CHECK_PGSQL_INCLUDE
 ENABLE_DEBUG
@@ -38,5 +40,7 @@
 CHECK_WXWINDOWS

 AC_CONFIG_FILES([Makefile
-                 src/Makefile])
+                 src/Makefile
+         pkg/Makefile
+         pkg/mac/Makefile])
 AC_OUTPUT
Index: acinclude.m4
===================================================================
--- acinclude.m4    (revision 4178)
+++ acinclude.m4    (working copy)
@@ -53,6 +53,7 @@
 CXXFLAGS="-Wall -g -O0"],
 [pg_debug_build=no])
 ])
+AC_SUBST(pg_debug_build)

 ############################
 # Static build of pgAdmin3 #
@@ -64,6 +65,22 @@
 [pg_static_build=no])
 ])

+############################
+# Build an pgAdmin III.app  #
+############################
+AC_DEFUN([ENABLE_APPBUNDLE],
+[AC_ARG_ENABLE(appbundle,
+[ --enable-appbundle   Build pgAdmin3.app],
+[pg_appbundle=yes
+prefix=$(pwd)/tmp
+bundledir="$(pwd)/pgAdmin3.app"
+bindir="$bundledir/Contents/MacOS"
+datadir="$bundledir/Contents/SharedSupport"
+AC_SUBST(bundledir)
+],
+[pg_appbundle=no])
+])
+
 ########################################
 # Check for PostgreSQL library (libpq) #
 ########################################
@@ -115,7 +132,18 @@
     AC_LANG_SAVE
     AC_LANG_C
     AC_CHECK_LIB(pq, PQexec, [pgsql_cv_libpq=yes], [pgsql_cv_libpq=no])
-    AC_CHECK_LIB(pq, SSL_connect, [pgsql_ssl_libpq=yes], [pgsql_ssl_libpq=no])
+    if test "$build_cpu-$build_vendor" = "powerpc-apple"; then
+        echo -n "Checking if libpq links against libssl: "
+        if test "$(otool -L ${LIBPQ_HOME}/lib/libpq.?.dylib | grep -c libssl)" -gt 0
+        then
+            pgsql_ssl_libpq="yes"
+        else
+            pgsql_ssl_libpq="no"
+        fi
+        echo $pgsql_ssl_libpq
+    else
+        AC_CHECK_LIB(pq, SSL_connect, [pgsql_ssl_libpq=yes], [pgsql_ssl_libpq=no])
+    fi
     AC_LANG_RESTORE

     if test "$pgsql_include" != ""
@@ -127,11 +155,18 @@

     if test "$pg_static_build" = "yes"
     then
+        if test "$build_cpu-$build_vendor" = "powerpc-apple"
+        then
+            CRYPT_LIB=""
+        else
+            CRYPT_LIB="-lcrypt"
+        fi
+
         if test "$pgsql_ssl_libpq" = "yes"
         then
-            LIBS="${LIBPQ_HOME}/lib/libpq.a -lcrypt $LIBS -lssl -lcrypto"
+            LIBS="${LIBPQ_HOME}/lib/libpq.a $CRYPT_LIB $LIBS -lssl -lcrypto"
         else
-            LIBS="${LIBPQ_HOME}/lib/libpq.a -lcrypt $LIBS -lcrypto"
+            LIBS="${LIBPQ_HOME}/lib/libpq.a $CRYPT_LIB $LIBS -lcrypto"
         fi
     else
         if test "$pgsql_ssl_libpq" = "yes"
@@ -184,10 +219,10 @@
 fi], [
     AC_MSG_RESULT(yes)
     WX_HOME=/usr/local/wx2
-    if test ! -f "${WX_HOME}/include/wx-2.5/wx/wx.h"
+    if test ! -f "${WX_HOME}/include/wx-2.5/wx/wx.h" -a ! -f "${WX_HOME}/include/wx-2.6/wx/wx.h"
     then
         WX_HOME=/usr/local
-        if test ! -f "${WX_HOME}/include/wx-2.5/wx/wx.h"
+        if test ! -f "${WX_HOME}/include/wx-2.5/wx/wx.h" -a ! -f "${WX_HOME}/include/wx-2.6/wx/wx.h"
         then
             WX_HOME=/usr
         fi
@@ -237,12 +272,12 @@
     # Which version of wxWindows is this?
     WX_VERSION=`${WX_CONFIG} --version`
     case "${WX_VERSION}" in
+        2.6*)
+            WX_VERSION="2.6"
+            ;;
         2.5*)
             WX_VERSION="2.5"
             ;;
-        2.4*)
-            WX_VERSION="2.4"
-            ;;
         *)
             ;;
     esac
@@ -295,6 +330,14 @@
                 LIBS="$LIBS ${WX_HOME}/lib/libwx_mac_stc-${WX_VERSION}.a"
                 LIBS="$LIBS $WX_NEW_LDFLAGS"
                 ;;
+            *libwx_macu-*)
+                LIBS="$LIBS ${WX_HOME}/lib/libwx_macu_stc-${WX_VERSION}.a
${WX_HOME}/lib/libwx_macu_ogl-${WX_VERSION}.a"
+                LIBS="$LIBS $WX_NEW_LDFLAGS"
+                ;;
+            *libwx_macu_core*)
+                LIBS="$LIBS ${WX_HOME}/lib/libwx_macu_stc-${WX_VERSION}.a
${WX_HOME}/lib/libwx_macu_ogl-${WX_VERSION}.a"
+                LIBS="$LIBS $WX_NEW_LDFLAGS"
+                ;;
             *libwx_gtk2ud-*)
                 LIBS="$LIBS ${WX_HOME}/lib/libwx_gtk2ud_stc-${WX_VERSION}.a"
                 LIBS="$LIBS $WX_NEW_LDFLAGS"
@@ -392,6 +435,14 @@
                 LIBS="$LIBS -lwx_mac_stc-${WX_VERSION}"
                 LIBS="$LIBS $WX_NEW_LDFLAGS"
                 ;;
+            *wx_macu-*)
+                LIBS="$LIBS -lwx_macu_stc-${WX_VERSION} -lwx_macu_ogl-${WX_VERSION}"
+                LIBS="$LIBS $WX_NEW_LDFLAGS"
+                ;;
+            *wx_macu_core*)
+                LIBS="$LIBS -lwx_macu_stc-${WX_VERSION} -lwx_macu_ogl-${WX_VERSION}"
+                LIBS="$LIBS $WX_NEW_LDFLAGS"
+                ;;
             *wx_gtk2ud-*)
                 LIBS="$LIBS -lwx_gtk2ud_stc-${WX_VERSION}"
                 LIBS="$LIBS $WX_NEW_LDFLAGS"
@@ -450,7 +501,7 @@
     fi

     WX_NEW_CPPFLAGS=`${WX_CONFIG} --cxxflags`
-    CPPFLAGS="$CPPFLAGS $WX_NEW_CPPFLAGS -I${WX_HOME}/include/wx-2.5"
+    CPPFLAGS="$CPPFLAGS $WX_NEW_CPPFLAGS -I${WX_HOME}/include/wx-${WX_VERSION}"
     case "${host}" in
         *-apple-darwin*)
             CPPFLAGS="$CPPFLAGS -no-cpp-precomp -fno-rtti"
@@ -459,11 +510,11 @@
             ;;
     esac
     wx_wx_h="yes"
-    if test ! -f "${WX_HOME}/include/wx-2.5/wx/version.h"
+    if test ! -f "${WX_HOME}/include/wx-${WX_VERSION}/wx/version.h"
     then
         wx_wx_h="no"
     fi
-    if test ! -f "${WX_HOME}/include/wx-2.5/wx/stc/stc.h"
+    if test ! -f "${WX_HOME}/include/wx-${WX_VERSION}/wx/stc/stc.h"
     then
         AC_MSG_ERROR([you need to install the stc package from wxWindows/contrib/src/stc])
         wx_wx_h="no"
@@ -481,3 +532,4 @@
     fi
 fi
 ])
+AC_SUBST(WX_CONFIG)
Index: Makefile.am
===================================================================
--- Makefile.am    (revision 4178)
+++ Makefile.am    (working copy)
@@ -3,7 +3,7 @@
 # This software is released under the Artistic Licence
 #
 # Makefile - Makefile for *nix systems
-SUBDIRS = src
+SUBDIRS = src pkg
 EXTRA_DIST = \
         README.txt \
         BUGS.txt \
@@ -35,7 +35,7 @@
         pkg/win32/licence.rtf \
         pkg/win32/pgadmin3.wsi

-nobase_dist_pkgdata_DATA = \
+TMP_docs = \
         docs/en_US/pg/*.html \
         docs/en_US/pg/*.css \
         docs/en_US/images/*.png \
@@ -44,3 +44,8 @@
         docs/en_US/pgadmin3.hh* \
         docs/en_US/tips.txt

+if !APPBUNDLE
+nobase_dist_pkgdata_DATA = $(TMP_docs)
+else
+nobase_dist_data_DATA = $(TMP_docs)
+endif

pgadmin-hackers by date:

Previous
From: "Florian G. Pflug"
Date:
Subject: [PATCH] Repair OSX Port after i18n reorganization
Next
From: "Dave Page"
Date:
Subject: Re: i18n Makefile for 1.3.0 does not handle DESTDIR correctly