Steve Singer ssinger at ca.afilias.info
Thu Sep 22 08:24:33 PDT 2011
Some distributions don't include pgport, if you compile with pgport support set to
no (a configure option/check) then this will be disabled.
---
 Makefile.global.in   |    3 +++
 config/acx_libpq.m4  |    6 ++++++
 configure.ac         |    6 +++---
 src/slonik/Makefile  |    2 ++
 src/slonik/slonik.c  |   18 +++++++++++++++++-
 src/slonik/win32.mak |    2 +-
 6 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/Makefile.global.in b/Makefile.global.in
index 3f82d7d..2aa484d 100644
--- a/Makefile.global.in
+++ b/Makefile.global.in
@@ -53,6 +53,9 @@ enable_rpath=		@enable_rpath@
 
 #libs
 PTHREAD_LIBS=		@PTHREAD_LIBS@
+ifeq (@HAVE_PGPORT@,1)
+HAVE_PGPORT=		@HAVE_PGPORT@
+endif
 
 # Documentation
 JADE=			@JADE@
diff --git a/config/acx_libpq.m4 b/config/acx_libpq.m4
index 0055536..d142ef2 100644
--- a/config/acx_libpq.m4
+++ b/config/acx_libpq.m4
@@ -475,6 +475,12 @@ AC_CHECK_DECLS([GetTopTransactionId],[],[],[
 
 AC_SUBST(NLSLIB)
 
+if test "$with_pgport" != "no"; then
+   AC_MSG_CHECKING(for pgport)
+   LIBS="$LIBS -lpgport"
+   AC_TRY_LINK_FUNC(find_my_exec,HAVE_PGPORT=1, AC_MSG_ERROR("pgport was not found. bulid with --with-pgport=no to disable"))
+fi
+
 AC_LANG_RESTORE
 ])dnl ACX_LIBPQ
 
diff --git a/configure.ac b/configure.ac
index 3af8eb5..c9b930d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-# ----------
+2# ----------
 # configure.ac
 #
 #	Autoconf configuration file for Slony-I
@@ -211,7 +211,7 @@ AC_ARG_WITH(docs,		[  --with-docs=<yes|no>             Build the sgml documentat
 AC_ARG_WITH(docdir,		[  --with-docdir=<dir>              Location to install all the documentation. Default is $PREFIX/doc. ])
 AC_ARG_WITH(d2mdir,		[  --with-d2mdir=<dir>              Location of docbook2man-spec.pl (Manpages will be skipped if not specified)])
 AC_ARG_WITH(mandir,		[  --with-mandir=<dir>              Location to install the manpages. Default is $PREFIX/man.])
-
+AC_ARG_WITH(pgport, 		[  --with-pgport=<yes|no>	    Link with pgport [default=yes]])
 
 SLON_AC_ARG_BOOL(enable, engine, yes,
               [  --disable-engine     Don't build slony1-engine source. (Used when building documentation only)])
@@ -249,7 +249,7 @@ AC_SUBST(TOOLSBIN, $TOOLSBIN)
 AC_SUBST(SLONYPATH)
 AC_SUBST(HOST_OS,$host_os)
 AC_SUBST(PORTNAME,$template)
-
+AC_SUBST(HAVE_PGPORT,$HAVE_PGPORT)
 if test ${prefix} = "NONE"; then
   SLONBINDIR="${PG_BINDIR}"
 else
diff --git a/src/slonik/Makefile b/src/slonik/Makefile
index d8c9564..b5fc630 100644
--- a/src/slonik/Makefile
+++ b/src/slonik/Makefile
@@ -26,6 +26,8 @@ endif
 ifeq ($(PORTNAME), win32)
 PROG            = slonik.exe
 LDFLAGS += -lpgport
+else ifdef HAVE_PGPORT
+LDFLAGS += -lpgport
 endif
 
 OBJS		= 			\
diff --git a/src/slonik/slonik.c b/src/slonik/slonik.c
index 4b39848..90e8e74 100644
--- a/src/slonik/slonik.c
+++ b/src/slonik/slonik.c
@@ -32,7 +32,9 @@
 #include "types.h"
 #include "libpq-fe.h"
 #include "slonik.h"
-
+#ifdef HAVE_PGPORT
+#include "port.h"
+#endif
 
 #ifdef MSVC
 #include "config_msvc.h"
@@ -55,6 +57,9 @@ int last_event_node=-1;
 int auto_wait_disabled=0;
 
 static char share_path[MAXPGPATH];
+#if HAVE_PGPORT
+static char myfull_path[MAXPGPATH];
+#endif
 
 /*
  * Local functions
@@ -150,10 +155,21 @@ main(int argc, const char *argv[])
 	if (parser_errors)
 		usage();
 
+#ifdef HAVE_PGPORT
 	/*
 	 * We need to find a share directory like PostgreSQL. 
 	 */
+ 	if (find_my_exec(argv[0],myfull_path) < 0)
+	{
+		strcpy(share_path, PGSHARE);
+	}
+	else
+	{
+		get_share_path(myfull_path, share_path);
+	}
+#else
 	strcpy(share_path, PGSHARE);
+#endif
 
 	if (optind < argc)
 	{
diff --git a/src/slonik/win32.mak b/src/slonik/win32.mak
index b973c5b..7e489e7 100644
--- a/src/slonik/win32.mak
+++ b/src/slonik/win32.mak
@@ -9,7 +9,7 @@ OBJS = slonik.obj \
 
 
 
-CPP_FLAGS=/c /D MSVC /D WIN32 /D PGSHARE=\"$(PGSHARE)\" /D YY_NO_UNISTD_H /I..\..\ /I$(PG_INC)  /MD
+CPP_FLAGS=/c /D MSVC /D WIN32 /D PGSHARE=\"$(PGSHARE)\" /D YY_NO_UNISTD_H /I..\..\ /D HAVE_PGPORT /I$(PG_INC)  /MD
 
 slonik.obj: slonik.c
 	$(CPP)$(CPP_FLAGS)  slonik.c
-- 
1.7.0.4


--------------010705000007040409030509--


More information about the Slony1-hackers mailing list