Hi

I tried compiling pgadminIII on OSX, and (compared to a few months ago), things were relativly smooth. There were, howevery, a few problems, which the attached patches try to solve.

.) When SSL support is disabled in libpq, pgConn::IsSSLconnected is not included in pgConn, although there other code depends on IsSSLconnected.
The attached pgadmin3-sslfix.diff defined IsSSLconnected even when ssl is disabled in libpq, but it always returns false in this case.

.) I wanted to build a .app bundle for pgadmin, but I found no support
for this in the build system. I added an option --build-bundle that basically overwrites --prefix to $(pwd)tmp, and added a PgAdminIII.app target to Makefile.am. The built bundle includes the pgadmin3 binary (named PgAdminIII, all shared libraries that binary depends on (system libs in /usr/lib and /System are excluded), the documentation and the ui/ folder. This code is in pgadmin3-buildbundle.diff

.) I added code to pgAdmin3.cpp to find the ui and doc folder inside the
bundle, using the SystemPathsCF class from wx (only when __WXMAC__, of course). Using just SystemPaths would be cleaner, as it should default to sensible locations on all plattforms, but as of wxmac 2.5.4, SystemPaths refers to the unix-implemenation, not to the osx implemenation. This code is in pgadmin3-usebundle.diff

Open Problems:
.) The resulting .app is HUGHE - My app currently has 250Mb - but since I compiled wxmac and libpq as shared libs (which therefore are copied to the bundle by my PgAdminIII.app target), and include debug support, this
is not unreasonable. I haven't check how big it gets when it's linked statically, and is stripped...

.) The bundle doesn't include pg_dump and the slony sqls. I plan to fix this - but it's hard since the build system currently doesn't know where to find those.

.) Most dialogs in pgadmin are unuseable on osx, because the window is too small - I believe that pgadmin uses absolute pixel-based positioning in the .xrc files, and unfortunatly ui-controls are much bigger on osx..

.) The help window behaves very strange - it has no titlebar, and is attached to the top of the screen..

I hope this helps - I'd like to see OSX being an supported plattform for pgadmin3, and I'd like to help to get there..

greetings, Florian Pflug
Index: src/pgAdmin3.cpp
===================================================================
RCS file: /projects/pgadmin3/src/pgAdmin3.cpp,v
retrieving revision 1.111
diff -u -r1.111 pgAdmin3.cpp
--- src/pgAdmin3.cpp    2 Mar 2005 23:47:23 -0000       1.111
+++ src/pgAdmin3.cpp    12 Mar 2005 16:21:00 -0000
@@ -20,6 +20,7 @@
 #include <wx/imagjpeg.h>
 #include <wx/imaggif.h>
 #include <wx/imagpng.h>
+#include <wx/stdpaths.h>
 
 // Windows headers
 #ifdef __WXMSW__
@@ -87,6 +88,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")
 
 
@@ -171,7 +174,7 @@
 
     // evaluate all working paths
 
-#ifdef __WXMSW__
+#if defined(__WXMSW__)
 
     backupExecutable  = path.FindValidPath(wxT("pg_dump.exe"));
     restoreExecutable = path.FindValidPath(wxT("pg_restore.exe"));
@@ -186,6 +189,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"));
@@ -200,6 +230,7 @@
         docPath = DATA_DIR DOC_DIR;
     else
         docPath = loadPath + wxT("/..") DOC_DIR;
+
 #endif
 
 
Index: Makefile.am
===================================================================
RCS file: /projects/pgadmin3/Makefile.am,v
retrieving revision 1.34
diff -u -r1.34 Makefile.am
--- Makefile.am 23 Feb 2005 15:32:51 -0000      1.34
+++ Makefile.am 12 Mar 2005 16:20:26 -0000
@@ -27,4 +27,45 @@
                $(top_srcdir)/docs/en_US/*.css 
$(top_srcdir)/docs/en_US/pgadmin3.hh* \
                $(top_srcdir)/docs/en_US/tips.txt
 
-
+PgAdminIII.app: 
+               @echo "Building Bundle PgAdminIII.app"
+               @test -d PgAdminIII.app || $(mkinstalldirs) PgAdminIII.app
+               @test -d PgAdminIII.app/Contents/MacOS || $(mkinstalldirs) 
PgAdminIII.app/Contents/MacOS
+               @test -d PgAdminIII.app/Contents/Resources || $(mkinstalldirs) 
PgAdminIII.app/Contents/Resources
+               @test -d PgAdminIII.app/Contents/SharedSupport || 
$(mkinstalldirs) PgAdminIII.app/Contents/SharedSupport
+               @test -d PgAdminIII.app/Contents/Frameworks || $(mkinstalldirs) 
PgAdminIII.app/Contents/Frameworks
+               @cp pkg/mac/PkgInfo PgAdminIII.app
+               @cp pkg/mac/Info.plist PgAdminIII.app/Contents
+               @cp pkg/mac/PgAdminIII.icns PgAdminIII.app/Contents/Resources
+               @$$(@WX_CONFIG@ --rezflags | sed 's/-t[[:space:]]*APPL//') \
+                       PgAdminIII.app/Contents/Resources/PgAdminIII.rsrc \
+                       -useDF
+               @cp -r $(pkgdatadir)/* PgAdminIII.app/Contents/SharedSupport
+               @cp -r $(bindir)/pgadmin3 
PgAdminIII.app/Contents/MacOS/PgAdminIII
+               @echo "Adding all non-standard shared libraries to 
PgAdminIII.app" ; \
+               cd PgAdminIII.app/Contents ; \
+               todo=MacOS/PgAdminIII ; \
+               while test "$$todo" != ""; do \
+                       todo_old=$$todo ; \
+                       todo="" ; \
+                       for todo_obj in $$todo_old; do \
+                               for lib in $$( \
+                                       otool -L $$todo_obj | \
+                                       sed -n 
's|^.*[[:space:]]\([^[:space:]]*\.dylib\).*$$|\1|p' | \
+                                       egrep -v '^(/usr/lib)|(/System)' \
+                               ); do \
+                                       lib_bn="$$(basename "$$lib")" ;\
+                                       if ! test -f "Frameworks/$$lib_bn"; 
then \
+                                               cp "$$lib" 
"Frameworks/$$lib_bn" ; \
+                                               install_name_tool \
+                                                       -id 
"@executable_path/../Frameworks/$$lib_bn" \
+                                                       "Frameworks/$$lib_bn" ; 
\
+                                               todo="$$todo 
Frameworks/$$lib_bn" ; \
+                                       fi ; \
+                                       install_name_tool -change \
+                                               "$$lib" \
+                                               
"@executable_path/../Frameworks/$$lib_bn" \
+                                               "$$todo_obj" ; \
+                               done ; \
+                       done ; \
+               done ;
Index: acinclude.m4
===================================================================
RCS file: /projects/pgadmin3/acinclude.m4,v
retrieving revision 1.42
diff -u -r1.42 acinclude.m4
--- acinclude.m4        2 Mar 2005 23:47:23 -0000       1.42
+++ acinclude.m4        12 Mar 2005 16:20:27 -0000
@@ -64,6 +64,18 @@
 [pg_static_build=no])
 ])
 
+############################
+# Static build of pgAdmin3 #
+############################
+AC_DEFUN([ENABLE_APPBUNDLE],
+[AC_ARG_ENABLE(appbundle,
+[ --enable-appbundle   Build PgAdminIII.app],
+[pg_appbundle=yes
+prefix=$(pwd)/tmp
+],
+[pg_appbundle=no])
+])
+
 ########################################
 # Check for PostgreSQL library (libpq) #
 ########################################
@@ -486,3 +498,5 @@
     fi
 fi
 ])
+AC_SUBST(WX_CONFIG)
+
Index: configure.ac
===================================================================
RCS file: /projects/pgadmin3/configure.ac,v
retrieving revision 1.33
diff -u -r1.33 configure.ac
--- configure.ac        29 Nov 2004 21:42:20 -0000      1.33
+++ configure.ac        12 Mar 2005 16:20:27 -0000
@@ -30,6 +30,7 @@
 AC_CHECK_FUNCS([gethostbyname inet_ntoa memmove memset strchr])
 
 # Custom checks
+ENABLE_APPBUNDLE
 CHECK_WX_CONFIG_BINARY
 CHECK_PGSQL_INCLUDE
 ENABLE_DEBUG
Index: src/db/pgConn.cpp
===================================================================
RCS file: /projects/pgadmin3/src/db/pgConn.cpp,v
retrieving revision 1.63
diff -u -r1.63 pgConn.cpp
--- src/db/pgConn.cpp   13 Feb 2005 18:07:39 -0000      1.63
+++ src/db/pgConn.cpp   12 Mar 2005 16:21:35 -0000
@@ -225,6 +225,12 @@
 {
     return (conn && PQstatus(conn) == CONNECTION_OK && PQgetssl(conn) != NULL);
 }
+#else
+
+bool pgConn::IsSSLconnected()
+{
+    return false ;
+}
 #endif
 
 
Index: src/include/pgConn.h
===================================================================
RCS file: /projects/pgadmin3/src/include/pgConn.h,v
retrieving revision 1.30
diff -u -r1.30 pgConn.h
--- src/include/pgConn.h        11 Feb 2005 21:48:50 -0000      1.30
+++ src/include/pgConn.h        12 Mar 2005 16:21:35 -0000
@@ -82,9 +82,7 @@
 
     void LogError();
 
-#ifdef SSL
     bool IsSSLconnected();
-#endif
     PGconn *connection() { return conn; }
     void Notice(const char *msg);
 

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



Reply via email to