Hi!

> "Nikolay P. Romanyuk" <[EMAIL PROTECTED]> wrote:
> > P.S. I am very sorry, but letters to '[EMAIL PROTECTED]'
> > without replies.
>
>   I've been a little busy, sorry.  Send the patches to the list, so
> everyone else can see them, too.
>
> >  I have a patches fixing detecting PostgreSQL on
> > FreeBSD-4.X
>
>   Those I won't apply.  From what I recall, you've changed one
> hard-coded path which doesn't work on FreeBSD, to another hard-coded
> path, which does.  This means, of course, that it will break on other
> systems.
>
>   Look at 'src/module/rlm_ldap/configure.in' for a way of detecting
> libraries WITHOUT hard-coding the path.

Here is the yet another PostgreSQL-detection patch for head version. It's
tested on my FreeBSD 4.4-STABLE box with postgresql 7.1.3. I tried to leave
all possible include/libs directories from old aclocal.m4, so detection
_should_ steel work on other platforms. So, here is what does this patch do:

1. removes postgresql checks from radiusd/aclocal.m4
2. removes POSGRESQL_CHECKS call from radiusd/configure.in
3. removes PGROOT, PQ_LIBS and PG_INCLUDE_DIR vars from radiusd/Make.inc.in
4. removes file
radiusd/src/modules/rlm_sql/drivers/rlm_sql_postgresql/Makefile
5. creates
radiusd/src/modules/rlm_sql/drivers/rlm_sql_postgresql/Makefile.in
6. creates
radiusd/src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure.in

Don't forget to run autoconf in radiusd/ and
radiusd/src/modules/rlm_sql/drivers/rlm_sql_postgresql/ directories and to
add into repository
radiusd/src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure.

diff -ruN radiusd/aclocal.m4 radiusd.postgresql/aclocal.m4
--- radiusd/aclocal.m4  Mon Sep 24 18:45:51 2001
+++ radiusd.postgresql/aclocal.m4       Thu Oct 11 13:45:11 2001
@@ -561,79 +561,6 @@
   fi
 ])

-dnl Check the PostgreSQL installation
-
-AC_DEFUN(POSTGRESQL_CHECKS, [
-       AC_SUBST(PGROOT)
-       AC_SUBST(PQ_LIBS)
-       AC_SUBST(PG_INCLUDE_DIR)
-
-AC_CHECKING(for PostgreSQL includes)
-
-dnl First Check for a local install
-if test "x$PGROOT" != "x" ; then
-       IS_LOCAL=1
-else
-       dnl Check common local install paths
-       if test -d /usr/local/pgsql ; then
-               PGROOT="/usr/local/pgsql"
-               ISLOCAL=1
-       elif test -d /usr/local/postgresql ; then
-               PGROOT="/usr/local/postgresql"
-               ISLOCAL=1
-       elif test -d /opt/pgsql ; then
-               PGROOT="/opt/pgsql"
-               ISLOCAL=1
-       elif test -d /opt/postgresql ; then
-               PGROOT="/opt/postgresql"
-               ISLOCAL=1
-       fi
-fi
-dnl If we have a local install path, check for some files
-if test "x$PGROOT" != "x" && test "x$IS_LOCAL" != "x" ; then
-       if test -e $PGROOT/lib/libpq${libltdl_cv_shlibext} ; then
-               if test -e $PGROOT/lib/libpq.a ; then
-                       PQ_LIBS="-L$PGROOT/lib -lpq"
-               fi
-       fi
-       AC_CHECK_HEADERS($PGROOT/include/libpq-fe.h $PGROOT/include/postgres.h,
-               FOUND_PG_HEADERS=1)
-       if test "x$FOUND_PG_HEADERS" != "x" ; then
-               PG_INCLUDE_DIR="$PGROOT/include"
-       fi
-fi
-
-dnl Now check for the two common distribution installation locations
-if test "x$PGROOT" = "x" ; then
-       AC_CHECK_LIB(pq,PQconnectdb,FOUND_PQLIB=1)
-       if test "x$FOUND_PQLIB" != "x" ; then
-               PQ_LIBS="-lpq"
-       fi
-       if test -d /usr/include/pgsql ; then
-               PG_INCLUDE_DIR="/usr/include/pgsql"
-               PG_INCLUDED_DIR="$PG_INCLUDE_DIR/"
-       elif test -d /usr/include/postgresql ; then
-               PG_INCLUDE_DIR="/usr/include/postgresql"
-               PG_INCLUDED_DIR="$PG_INCLUDE_DIR/"
-       fi
-       AC_CHECK_HEADER("${PG_INCLUDED_DIR}libpq-fe.h",AC_DEFINE(HAVE_LIBPQ_FE_H))
-       AC_CHECK_HEADER("${PG_INCLUDED_DIR}postgres.h",AC_DEFINE(HAVE_POSTGRES_H))
-       if test "x$HAVE_HEADER-LIBPQ-FE.H" != "x" ; then
-               PG_INCLUDE_DIR="$PG_INCLUDE_DIR"
-       fi
-       if test -d /usr/lib/pgsql ; then
-               PGROOT="/usr/lib/pgsql"
-       elif test -d /usr/lib/postgresql ; then
-               PGROOT="/usr/lib/postgresql"
-       fi
-fi
-
-if test "x$PGROOT" != "x" && test "x$PQ_LIBS" != "x" && test
"x$PG_INCLUDE_DIR" != "x"; then
-       echo Postgresql found in $PGROOT.
-fi
-
-])
-
 dnl #######################################################################
 dnl #
 dnl #  Look for ODBC in a variety of places.
diff -ruN radiusd/configure.in radiusd.postgresql/configure.in
--- radiusd/configure.in        Wed Oct 10 21:09:26 2001
+++ radiusd.postgresql/configure.in     Thu Oct 11 13:33:39 2001
@@ -630,7 +630,6 @@
   fi
 fi

-POSTGRESQL_CHECKS
 ODBC_CHECKS

 dnl #############################################################
diff -ruN radiusd/Make.inc.in radiusd.postgresql/Make.inc.in
--- radiusd/Make.inc.in Sat Jun  2 05:01:23 2001
+++ radiusd.postgresql/Make.inc.in  Thu Oct 11 14:46:12 2001
@@ -57,10 +57,6 @@
 #
 #  SQL driver defines
 #
-PGROOT         = @PGROOT@
-PQ_LIBS                = @PQ_LIBS@
-PG_INCLUDE_DIR = @PG_INCLUDE_DIR@
-
 SQL_MYSQL_LIBS = @MYSQL_LIBS@
 SQL_MYSQL_INCLUDE = @MYSQL_INCLUDE@
diff -ruN radiusd/src/modules/rlm_sql/drivers/rlm_sql_postgresql/Makefile
radiusd.postgresql/src/modules/rlm_sql/drivers/rlm_sql_postgresql/Makefile
--- radiusd/src/modules/rlm_sql/drivers/rlm_sql_postgresql/Makefile     Thu Mar
15 19:56:45 2001
+++
radiusd.postgresql/src/modules/rlm_sql/drivers/rlm_sql_postgresql/Makefile
Thu Jan  1 03:00:00 1970
@@ -1,17 +0,0 @@
-include ../../../../../Make.inc
-
-TARGET         = rlm_sql_postgresql
-SRCS           = sql_postgresql.c
-HEADERS                = sql_postgresql.h
-RLM_SQL_CFLAGS = -I$(PG_INCLUDE_DIR) $(INCLTDL)
-RLM_SQL_LIBS   = $(PQ_LIBS)
-
-$(DYNAMIC_OBJS): $(HEADERS)
-
-###
-# over-ride the previous assignment if we're not building anything
-ifeq ($(PQ_LIBS),)
-TARGET        =
-endif
-
-include ../rules.mak
diff -ruN radiusd/src/modules/rlm_sql/drivers/rlm_sql_postgresql/Makefile.in
radiusd.postgresql/src/modules/rlm_sql/drivers/rlm_sql_postgresql/Makefile.i
n
--- radiusd/src/modules/rlm_sql/drivers/rlm_sql_postgresql/Makefile.in  Thu
Jan  1 03:00:00 1970
+++
radiusd.postgresql/src/modules/rlm_sql/drivers/rlm_sql_postgresql/Makefile.i
n       Thu Oct 11 13:30:15 2001
@@ -0,0 +1,11 @@
+include ../../../../../Make.inc
+
+TARGET         = @targetname@
+SRCS           = sql_postgresql.c
+HEADERS        = sql_postgresql.h
+RLM_SQL_CFLAGS = @sql_postgresql_cflags@ $(INCLTDL)
+RLM_SQL_LIBS   = @sql_postgresql_ldflags@
+
+include ../rules.mak
+
+$(DYNAMIC_OBJS): $(HEADERS)
diff -ruN
radiusd/src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure.in
radiusd.postgresql/src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure.
in
--- radiusd/src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure.in Thu
Jan  1 03:00:00 1970
+++
radiusd.postgresql/src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure.
in      Thu Oct 11 13:38:33 2001
@@ -0,0 +1,107 @@
+AC_INIT(sql_postgresql.c)
+AC_REVISION($Revision: 1.6 $)
+AC_DEFUN(modname,[rlm_sql_postgresql])
+
+AC_PROG_CC
+AC_PROG_CPP
+
+AC_ARG_WITH(postgresql-include-dir,
+[  --with-postgresql-include-dir=DIR       Directory where the PostgreSQL
includes may be found ],
+[ postgresql_include_dir="$withval" ]
+)
+
+AC_ARG_WITH(postgresql-lib-dir,
+[  --with-postgresql-lib-dir=DIR       Directory where the PostgreSQL
libraries may be found ],
+[ postgresql_lib_dir="$withval" ]
+)
+
+AC_ARG_WITH(postgresql-dir,
+[  --with-postgresql-dir=DIR       Base directory where PostgreSQL is
installed ],
+[ postgresql_lib_dir="$withval/lib"
+  postgresql_include_dir="$withval/include"
+]
+)
+
+if test x$with_[]modname != xno; then
+
+       targetname=modname   # we might change this later.
+
+       AC_CHECK_LIB(z, compress, LIBS="$LIBS -lz")
+
+       AC_MSG_CHECKING([for libpq-fe.h postgres.h])
+
+       AC_TRY_COMPILE([#include <libpq-fe.h>], [int a = 1;],
+               POSTGRESQL_INCLUDE=" ",
+               POSTGRESQL_INCLUDE=
+       )
+
+       if test "x$POSTGRESQL_INCLUDE" = "x"; then
+               old_CFLAGS="$CFLAGS"
+
+               for try in $postgresql_include_dir /usr/local/pgsql/include
/usr/local/postgresql/include /opt/pgsql/include /opt/postgresql/include
/usr/include/pgsql /usr/include/postgresql /usr/local/include; do
+                       CFLAGS="$old_CFLAGS -I$try"
+                       AC_TRY_COMPILE([#include <libpq-fe.h>], [int a = 1;],
+                               POSTGRESQL_INCLUDE="-I$try",
+                               POSTGRESQL_INCLUDE=
+                       )
+                       if test "x$POSTGRESQL_INCLUDE" != "x"; then
+                               break;
+                       fi
+               done
+               CFLAGS="$old_CFLAGS"
+       fi
+
+       if test "x$POSTGRESQL_INCLUDE" = "x"; then
+               AC_MSG_RESULT(no)
+               AC_MSG_WARN([postgresql headers not found.
 Use --with-postgresql-include-dir=<path>.])
+               targetname=   # disabled module
+       else
+               sql_postgresql_cflags="${sql_postgresql_cflags} ${POSTGRESQL_INCLUDE}"
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_LIBPQ_FE_H)
+
+
+               AC_MSG_CHECKING([for PQconnectdb in -lpq])
+
+               old_LIBS="$LIBS"
+
+               for try in $postgresql_lib_dir /usr/local/pgsql/lib
/usr/local/postgresql/lib /opt/pgsql/lib /opt/postgresql/lib /usr/lib/pgsql
/usr/lib/postgresql /usr/local/lib; do
+                       LIBS="$old_LIBS -L$try -lpq"
+                       AC_TRY_LINK([extern char PQconnectdb();], [PQconnectdb()],
+                               POSTGRESQL_LIBS="-L$try -lpq",
+                               POSTGRESQL_LIBS=
+                       )
+                       if test "x$POSTGRESQL_LIBS" != "x"; then
+                               break;
+                       fi
+               done
+               LIBS="$old_LIBS"
+
+               dnl #  If one or the other isn't found, disable them both..
+               dnl #  If both are found, enable them both.
+               if test "x$POSTGRESQL_LIBS" = "x"; then
+                       AC_MSG_RESULT(no)
+                       POSTGRESQL_INCLUDE=
+                       AC_MSG_WARN([postgresql libraries not found.
 Use --with-postgresql-lib-dir=<path>.])
+                       targetname=   # disabled module
+               else
+                       AC_MSG_RESULT(yes)
+                       sql_postgresql_ldflags="$sql_postgresql_ldflags 
+$POSTGRESQL_LIBS"
+               fi
+       fi
+
+       sql_postgresql_ldflags="$sql_postgresql_ldflags $LIBS"
+
+       if test "x$targetname" = "x"; then
+               AC_MSG_WARN([sql submodule 'postgresql' disabled])
+       fi
+
+else
+       targetname=
+       echo \*\*\* module modname is disabled.
+fi
+
+AC_SUBST(sql_postgresql_ldflags)
+AC_SUBST(sql_postgresql_cflags)
+AC_SUBST(targetname)
+AC_OUTPUT(Makefile)


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to