Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 May 2006 12:28:15 -0400 (EDT)
From:      Rong-En Fan <rafan@infor.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        kcwu@csie.org
Subject:   ports/96606: [PATCH] chiense/{xcin25,libtabe} USE_BDB 
Message-ID:  <200605011628.k41GSFTb051259@woodstock.rafan.org>
Resent-Message-ID: <200605011630.k41GUKAb050878@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         96606
>Category:       ports
>Synopsis:       [PATCH] chiense/{xcin25,libtabe} USE_BDB
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 01 16:30:19 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Rong-En Fan
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
NTU CSIE 
>Environment:
System: FreeBSD woodstock.rafan.org 7.0-CURRENT FreeBSD 7.0-CURRENT #31: Sun Apr 30 08:10:00 EDT 2006 root@woodstock.rafan.org:/home/admin/usr/obj/home/admin/usr/src/sys/WOODSTOCK i386


	
>Description:
	chinese/xcin25 is updated to use USE_BDB, and supports db4+.
	A warning message is printed if user defines WITH_BDB_VER.
	The db version used for xcin25 and libtabe *MUST* match.

	USE_BDB exists in libtabe, but it may find the wrong version
	if one has more than one bdb version  installed. Thus, configure
	and two source files are patched to use the correct bdb version
	specified in WITH_BDB_VER. 

	Due to the db version must match between libtabe and xcin25,
	hope these can be committed together.

	Both ports are tested WITH_BDB_VER from 2 to 44, pass compilation
	on i386 7-CURRENT as of few days ago.

	I think we traditionally put make targets below bsd.port.pre.mk,
	so I changed Makefile.

	
>How-To-Repeat:
	
>Fix:

	


===> Generating patch
===> Viewing diff with less
diff -ruN --exclude=CVS /usr/ports/chinese/libtabe/Makefile /home/rafan/tmp/ports/a/libtabe/Makefile
--- /usr/ports/chinese/libtabe/Makefile	Sat Apr  8 22:51:28 2006
+++ /home/rafan/tmp/ports/a/libtabe/Makefile	Mon May  1 12:16:36 2006
@@ -25,18 +25,34 @@
 DOCSDIR=	${PREFIX}/share/doc/tabe
 CONFIGURE_ARGS=	--prefix=${PREFIX} \
 		--includedir=${PREFIX}/include/tabe \
+		--with-db-name=${BDB_LIB_NAME} \
 		--with-db-inc=${BDB_INCLUDE_DIR} \
 		--with-db-lib=${BDB_LIB_DIR} \
 		--with-db-bin=${LOCALBASE}/bin \
 		--enable-shared
 
 .if !defined(WITHOUT_X11)
-PLIST_SUB+=	X11=""
 USE_XLIB=	yes
+PLIST_SUB+=	X11=""
 .else
 CONFIGURE_ARGS+=--without-x
 PLIST_SUB+=	X11="@comment "
+.endif
+
+.include <bsd.port.pre.mk>
+
+pre-everything::
+.if defined(WITH_BDB_VER)
+	@${ECHO} ""
+	@${ECHO} "WARNING:"
+	@${ECHO} "	You have defined WITH_BDB_VER. Make sure you use the same"
+	@${ECHO} "	db version for all ports that use libtabe, such as xcin."
+	@${ECHO} "	Otherwise, ports that use libtabe may not work correctly."
+	@${ECHO} ""
+.endif
+
 post-patch:
+.if defined(WITHOUT_X11)
 	${REINPLACE_CMD} -e '/all:/s/ bims//; /bims/d' ${WRKSRC}/src/Makefile.in
 .endif
 
@@ -55,4 +71,4 @@
 	${MKDIR} ${DATADIR}
 	${TOUCH} ${DATADIR}/${PORTNAME}-${PORTVERSION}
 
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff -ruN --exclude=CVS /usr/ports/chinese/libtabe/files/patch-configure /home/rafan/tmp/ports/a/libtabe/files/patch-configure
--- /usr/ports/chinese/libtabe/files/patch-configure	Sat Apr  8 14:31:48 2006
+++ /home/rafan/tmp/ports/a/libtabe/files/patch-configure	Mon May  1 10:53:25 2006
@@ -1,36 +1,69 @@
---- configure.orig	Sat Oct 20 20:03:29 2001
-+++ configure	Wed Apr  5 13:26:48 2006
-@@ -5315,18 +5315,15 @@
+--- configure.orig	Sat Oct 20 07:03:29 2001
++++ configure	Mon May  1 10:53:24 2006
+@@ -22,6 +22,8 @@
+ ac_help="$ac_help
+   --with-db-bin=PATH      set the binary dir of Berkeley DB2/3."
+ ac_help="$ac_help
++  --with-db-name=NAME     set the library name of Berkeley DB."
++ac_help="$ac_help
+   --enable-shared[=PKGS]  build shared libraries [default=yes]"
+ ac_help="$ac_help
+   --enable-static[=PKGS]  build static libraries [default=yes]"
+@@ -790,6 +792,14 @@
+   :
+ fi
+ 
++# Check whether --with-db_name or --without-db_name was given.
++if test "${with_db_name+set}" = set; then
++  withval="$with_db_name"
++    test x$withval != x && with_db_name="$withval"
++else
++    with_db_name='db'
++fi;
++
+ 
+ if test "$program_prefix" != NONE; then
+     program_prefix="$program_prefix/"
+@@ -5315,18 +5325,22 @@
    cat conftest.$ac_ext >&5
  fi
  rm -f conftest*
 -test "$ac_cv_search_db_create" = "no" && for i in db db3; do
-+test "$ac_cv_search_db_create" = "no" && for i in db db3 db4 db41 db-4.2 db-4.3 db-4.4; do
++test "$ac_cv_search_db_create" = "no" && for i in $with_db_name; do
  LIBS="-l$i  $ac_func_search_save_LIBS"
++__db_create="db_create"
++if [ "$i" = "db-4.2" ]; then
++  __db_create="db_create_4002"
++fi
  cat > conftest.$ac_ext <<EOF
  #line 5322 "configure"
  #include "confdefs.h"
--/* Override any gcc2 internal prototype to avoid an error.  */
--/* We use char because int might match the return type of a gcc2
--    builtin and then its argument prototype would still apply.  */
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+     builtin and then its argument prototype would still apply.  */
 -char db_create();
-+#include "db.h"
++char $__db_create();
  
  int main() {
 -db_create()
-+db_create(0,0,0)
++$__db_create()
  ; return 0; }
  EOF
  if { (eval echo configure:5333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-@@ -5726,11 +5723,6 @@
-   echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6
+@@ -5385,7 +5399,7 @@
+   cat conftest.$ac_ext >&5
  fi
- 
--if test x$no_x = xyes; then
--    echo "$ac_t""You need X11R6 header files to compile libtabe." 1>&6
--    echo "$ac_t""Please use --x-includes to configure." 1>&6
--    exit 1
--fi
- 
- 
- 
+ rm -f conftest*
+-test "$ac_cv_search_db_open" = "no" && for i in db db2; do
++test "$ac_cv_search_db_open" = "no" && for i in $with_db_name; do
+ LIBS="-l$i  $ac_func_search_save_LIBS"
+ cat > conftest.$ac_ext <<EOF
+ #line 5392 "configure"
+@@ -6219,6 +6233,7 @@
+ s%@with_db_inc@%$with_db_inc%g
+ s%@with_db_lib@%$with_db_lib%g
+ s%@with_db_bin@%$with_db_bin%g
++s%@with_db_name@%$with_db_name%g
+ s%@USE_DB@%$USE_DB%g
+ s%@x_includes@%$x_includes%g
+ s%@x_libraries@%$x_libraries%g
diff -ruN --exclude=CVS /usr/ports/chinese/libtabe/files/patch-src::tabe_tsidbint.c /home/rafan/tmp/ports/a/libtabe/files/patch-src::tabe_tsidbint.c
--- /usr/ports/chinese/libtabe/files/patch-src::tabe_tsidbint.c	Sat Apr  8 22:51:28 2006
+++ /home/rafan/tmp/ports/a/libtabe/files/patch-src::tabe_tsidbint.c	Mon May  1 00:49:36 2006
@@ -1,50 +1,113 @@
---- src/tabe_tsidbint.c.orig	Sun Nov 11 20:33:07 2001
-+++ src/tabe_tsidbint.c	Wed Apr  5 13:40:32 2006
-@@ -84,8 +84,10 @@
+--- src/tabe_tsidbint.c.orig	Sun Nov 11 07:33:07 2001
++++ src/tabe_tsidbint.c	Mon May  1 00:47:55 2006
+@@ -27,6 +27,7 @@
+ #endif
+ 
+ #include "tabe.h"
++#define DB_VERSION (DB_VERSION_MAJOR*100000+DB_VERSION_MINOR*1000+DB_VERSION_PATCH)
+ 
+ static void tabeTsiDBClose(struct TsiDB *tsidb);
+ static int  tabeTsiDBRecordNumber(struct TsiDB *tsidb);
+@@ -69,7 +70,7 @@
+ {
+   DB *dbp=NULL;
+ 
+-#ifdef HAVE_DB3
++#if DB_VERSION >= 300000
+   /* create a db handler */
+   if ((errno = db_create(&dbp, NULL, 0)) != 0) {
+     fprintf(stderr, "db_create: %s\n", db_strerror(errno));
+@@ -82,26 +83,32 @@
+       return(NULL);
+     }
      else {
- #ifndef HAVE_DB3
-       errno = db_open(db_name, DB_BTREE, DB_CREATE, 0644, NULL, NULL, &dbp);
+-#ifndef HAVE_DB3
+-      errno = db_open(db_name, DB_BTREE, DB_CREATE, 0644, NULL, NULL, &dbp);
 -#else
-+#elif (DB_VERSION_MAJOR == 3 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 0))
++#if DB_VERSION >= 401025
++      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, DB_CREATE, 0644);
++#elif DB_VERSION >= 300000
        errno = dbp->open(dbp, db_name, NULL, DB_BTREE, DB_CREATE, 0644);
 +#else
-+      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, DB_CREATE, 0644);
++      errno = db_open(db_name, DB_BTREE, DB_CREATE, 0644, NULL, NULL, &dbp);
  #endif
      }
    }
-@@ -93,15 +95,19 @@
+   else {
      if (flags & DB_FLAG_READONLY) {
- #ifndef HAVE_DB3
-       errno = db_open(db_name, DB_BTREE, DB_RDONLY, 0444, NULL, NULL, &dbp);
+-#ifndef HAVE_DB3
+-      errno = db_open(db_name, DB_BTREE, DB_RDONLY, 0444, NULL, NULL, &dbp);
 -#else
-+#elif (DB_VERSION_MAJOR == 3 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 0))
++#if DB_VERSION >= 401025
++      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, DB_RDONLY, 0444);
++#elif DB_VERSION >= 300000
        errno = dbp->open(dbp, db_name, NULL, DB_BTREE, DB_RDONLY, 0444);
 +#else
-+      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, DB_RDONLY, 0444);
++      errno = db_open(db_name, DB_BTREE, DB_RDONLY, 0444, NULL, NULL, &dbp);
  #endif
      }
      else {
- #ifndef HAVE_DB3
-       errno = db_open(db_name, DB_BTREE, 0, 0644, NULL, NULL, &dbp);
+-#ifndef HAVE_DB3
+-      errno = db_open(db_name, DB_BTREE, 0, 0644, NULL, NULL, &dbp);
 -#else
-+#elif (DB_VERSION_MAJOR == 3 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 0))
++#if DB_VERSION >= 401025
++      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, 0, 0644);
++#elif DB_VERSION >= 300000
        errno = dbp->open(dbp, db_name, NULL, DB_BTREE, 0, 0644);
 +#else
-+      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, 0, 0644);
++      errno = db_open(db_name, DB_BTREE, 0, 0644, NULL, NULL, &dbp);
  #endif
      }
    }
-@@ -265,7 +271,13 @@
+@@ -112,10 +119,10 @@
+   }
+   if (errno < 0) {
+     /* DB specific errno */
+-#ifndef HAVE_DB3
+-    fprintf(stderr, "tabeTsiDBOpen(): DB error opening DB File %s.\n", db_name);
+-#else
++#if DB_VERSION >= 300000
+     fprintf(stderr, "tabeTsiDBOpen(): %s.\n", db_strerror(errno));
++#else
++    fprintf(stderr, "tabeTsiDBOpen(): DB error opening DB File %s.\n", db_name);
+ #endif
+     return(NULL);
+   }
+@@ -265,12 +272,18 @@
    switch(tsidb->type) {
    case DB_TYPE_DB:
      dbp = (DB *)tsidb->dbp;
-+#ifndef HAVE_DB3
-     errno = dbp->stat(dbp, &sp, NULL, 0);
-+#elif (DB_VERSION_MAJOR == 3 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 2))
++#if DB_VERSION >= 403000
++    errno = dbp->stat(dbp, NULL, &sp, 0);
++#elif DB_VERSION >= 303011
 +    errno = dbp->stat(dbp, &sp, 0);
 +#else
-+    errno = dbp->stat(dbp, NULL, &sp, 0);
+     errno = dbp->stat(dbp, &sp, NULL, 0);
 +#endif
      if (!errno) {
- #ifndef HAVE_DB3
-       return(sp->bt_nrecs);
+-#ifndef HAVE_DB3
+-      return(sp->bt_nrecs);
+-#else
++#if DB_VERSION >= 300000
+       return(sp->bt_ndata);  /* or sp->bt_nkeys? */
++#else
++      return(sp->bt_nrecs);
+ #endif
+     }
+     break;
+@@ -502,14 +515,10 @@
+     dbcp->c_close(dbcp);
+   }
+ 
+-#ifndef HAVE_DB3
+-#if DB_VERSION_MINOR > 6 || (DB_VERSION_MINOR == 6 && DB_VERSION_PATCH > 4)
++#if DB_VERSION >= 206004
+   dbp->cursor(dbp, NULL, &dbcp, 0);
+ #else
+   dbp->cursor(dbp, NULL, &dbcp);
+-#endif
+-#else
+-  dbp->cursor(dbp, NULL, &dbcp, 0);
+ #endif
+   tsidb->dbcp = dbcp;
+ 
diff -ruN --exclude=CVS /usr/ports/chinese/libtabe/files/patch-src::tabe_tsiyindbint.c /home/rafan/tmp/ports/a/libtabe/files/patch-src::tabe_tsiyindbint.c
--- /usr/ports/chinese/libtabe/files/patch-src::tabe_tsiyindbint.c	Sat Apr  8 22:51:28 2006
+++ /home/rafan/tmp/ports/a/libtabe/files/patch-src::tabe_tsiyindbint.c	Mon May  1 00:50:17 2006
@@ -1,50 +1,114 @@
---- src/tabe_tsiyindbint.c.orig	Sun Nov 11 20:33:08 2001
-+++ src/tabe_tsiyindbint.c	Wed Apr  5 14:30:18 2006
-@@ -87,8 +87,10 @@
+--- src/tabe_tsiyindbint.c.orig	Mon May  1 00:49:54 2006
++++ src/tabe_tsiyindbint.c	Mon May  1 00:50:03 2006
+@@ -27,6 +27,7 @@
+ #endif
+ 
+ #include "tabe.h"
++#define DB_VERSION (DB_VERSION_MAJOR*100000+DB_VERSION_MINOR*1000+DB_VERSION_PATCH)
+ 
+ static void tabeTsiYinDBClose(struct TsiYinDB *tsiyindb);
+ static int  tabeTsiYinDBRecordNumber(struct TsiYinDB *tsiyindb);
+@@ -72,7 +73,7 @@
+ {
+   DB *dbp=NULL;
+ 
+-#ifdef HAVE_DB3
++#if DB_VERSION >= 300000
+   /* create a db handler */
+   if ((errno = db_create(&dbp, NULL, 0)) != 0) {
+     fprintf(stderr, "db_create: %s\n", db_strerror(errno));
+@@ -85,26 +86,32 @@
+       return(NULL);
+     }
      else {
- #ifndef HAVE_DB3
-       errno = db_open(db_name, DB_BTREE, DB_CREATE, 0644, NULL, NULL, &dbp);
+-#ifndef HAVE_DB3
+-      errno = db_open(db_name, DB_BTREE, DB_CREATE, 0644, NULL, NULL, &dbp);
 -#else
-+#elif (DB_VERSION_MAJOR == 3 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 0))
++#if DB_VERSION >= 401025
++      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, DB_CREATE, 0644);
++#elif DB_VERSION >= 300000
        errno = dbp->open(dbp, db_name, NULL, DB_BTREE, DB_CREATE, 0644);
 +#else
-+      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, DB_CREATE, 0644);
++      errno = db_open(db_name, DB_BTREE, DB_CREATE, 0644, NULL, NULL, &dbp);
  #endif
      }
    }
-@@ -96,15 +98,19 @@
+   else {
      if (flags & DB_FLAG_READONLY) {
- #ifndef HAVE_DB3
-       errno = db_open(db_name, DB_BTREE, DB_RDONLY, 0444, NULL, NULL, &dbp);
+-#ifndef HAVE_DB3
+-      errno = db_open(db_name, DB_BTREE, DB_RDONLY, 0444, NULL, NULL, &dbp);
 -#else
-+#elif (DB_VERSION_MAJOR == 3 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 0))
++#if DB_VERSION >= 401025
++      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, DB_RDONLY, 0444);
++#elif DB_VERSION >= 300000
        errno = dbp->open(dbp, db_name, NULL, DB_BTREE, DB_RDONLY, 0444);
 +#else
-+      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, DB_RDONLY, 0444);
++      errno = db_open(db_name, DB_BTREE, DB_RDONLY, 0444, NULL, NULL, &dbp);
  #endif
      }
      else {
- #ifndef HAVE_DB3
-       errno = db_open(db_name, DB_BTREE, 0, 0644, NULL, NULL, &dbp);
+-#ifndef HAVE_DB3
+-      errno = db_open(db_name, DB_BTREE, 0, 0644, NULL, NULL, &dbp);
 -#else
-+#elif (DB_VERSION_MAJOR == 3 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 0))
++#if DB_VERSION >= 401025
++      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, 0, 0644);
++#elif DB_VERSION >= 300000
        errno = dbp->open(dbp, db_name, NULL, DB_BTREE, 0, 0644);
 +#else
-+      errno = dbp->open(dbp, NULL, db_name, NULL, DB_BTREE, 0, 0644);
++      errno = db_open(db_name, DB_BTREE, 0, 0644, NULL, NULL, &dbp);
  #endif
      }
    }
-@@ -268,7 +274,13 @@
+@@ -115,11 +122,11 @@
+   }
+   if (errno < 0) {
+     /* DB specific errno */
+-#ifndef HAVE_DB3
++#if DB_VERSION >= 300000
++    fprintf(stderr, "tabeTsiYinDBOpen(): %s.\n", db_strerror(errno));
++#else
+     fprintf(stderr, "tabeTsiYinDBOpen(): DB error opening DB File %s.\n",
+ 	    db_name);
+-#else
+-    fprintf(stderr, "tabeTsiYinDBOpen(): %s.\n", db_strerror(errno));
+ #endif
+     return(NULL);
+   }
+@@ -268,12 +275,18 @@
    switch(tsiyindb->type) {
    case DB_TYPE_DB:
      dbp = (DB *)tsiyindb->dbp;
-+#ifndef HAVE_DB3
-     errno = dbp->stat(dbp, &sp, NULL, 0);
-+#elif (DB_VERSION_MAJOR == 3 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 2))
++#if DB_VERSION >= 403000
++    errno = dbp->stat(dbp, NULL, &sp, 0);
++#elif DB_VERSION >= 303011
 +    errno = dbp->stat(dbp, &sp, 0);
 +#else
-+    errno = dbp->stat(dbp, NULL, &sp, 0);
+     errno = dbp->stat(dbp, &sp, NULL, 0);
 +#endif
      if (!errno) {
- #ifndef HAVE_DB3
-       return(sp->bt_nrecs);
+-#ifndef HAVE_DB3
+-      return(sp->bt_nrecs);
+-#else
++#if DB_VERSION >= 300000
+       return(sp->bt_ndata);  /* or sp->bt_nkeys? */
++#else
++      return(sp->bt_nrecs);
+ #endif
+     }
+     break;
+@@ -481,14 +494,10 @@
+     dbcp->c_close(dbcp);
+   }
+ 
+-#ifndef HAVE_DB3
+-#if DB_VERSION_MINOR > 6 || (DB_VERSION_MINOR == 6 && DB_VERSION_PATCH > 4)
++#if DB_VERSION >= 206004
+   dbp->cursor(dbp, NULL, &dbcp, 0);
+ #else
+   dbp->cursor(dbp, NULL, &dbcp);
+-#endif
+-#else
+-  dbp->cursor(dbp, NULL, &dbcp, 0);
+ #endif
+   tsiyindb->dbcp = dbcp;
+ 
diff -ruN --exclude=CVS /usr/ports/chinese/libtabe/files/patch-util-tsipackdb.in /home/rafan/tmp/ports/a/libtabe/files/patch-util-tsipackdb.in
--- /usr/ports/chinese/libtabe/files/patch-util-tsipackdb.in	Wed Dec 31 19:00:00 1969
+++ /home/rafan/tmp/ports/a/libtabe/files/patch-util-tsipackdb.in	Mon May  1 10:20:31 2006
@@ -0,0 +1,63 @@
+--- util/tsipackdb.in.orig	Sun Nov 11 07:33:09 2001
++++ util/tsipackdb.in	Mon May  1 10:19:51 2006
+@@ -29,31 +29,37 @@
+ }
+ 
+ pack_db_file () {
+-    db_stat=`mywhich ${1}_stat`
+-    db_dump=`mywhich ${1}_dump`
+-    db_load=`mywhich ${1}_load`
+-    test x$db_stat != x && test x$db_dump != x && test x$db_load != x && \
+-	$db_stat -d $2 2>&1 | (
+-	    read line
+-	    read line
+-	    test "$line" = "$3" && \
+-		echo "Using $db_dump and $db_load to pack $2 ...." && \
+-		${1}_dump $2 | ${1}_load $2.new && \
+-		mv $2.new $2 && \
+-		return 0
+-	    return -1 \
+-	)
+-}
++    case "${1}" in
++    db|db3|db4|db41) 
++        db_dump=`mywhich ${1}_dump`
++        db_load=`mywhich ${1}_load`
++        ;;
++    db-4.[234])
++        db_name=${1#db-}
++        db_dump=`mywhich db_dump-${db_name}`
++        db_load=`mywhich db_load-${db_name}`
++        ;;
++    *)
++        echo "unsupportted Berkyley version: ${1}"
++        return 1
++    esac
++    if [ -x "$db_dump" ] && [ -x "$db_load" ]; then
++
++	echo "Try using $db_dump and $db_load to pack $2 ...."
+ 
++	$db_dump $2 > $2.tmp && \
++	$db_load $2.new < $2.tmp && \
++	mv $2.new $2 && \
++	return 0
+ 
+-if [ "$USE_DB" = "DB2" ]; then
+-    pack_db_file db  $1 "$DB2_VER" && exit 0
+-    pack_db_file db2 $1 "$DB2_VER" && exit 0
+-fi
++    fi
++
++    return 1
++}
+ 
+-if [ "$USE_DB" = "DB3" ]; then
+-    pack_db_file db  $1 "$DB3_VER" && exit 0
+-    pack_db_file db3 $1 "$DB3_VER" && exit 0
+-fi
++for dbname in @with_db_name@ db db2 db3 db4
++do
++    pack_db_file $dbname $1 && exit 0
++done
+ 
+ exit 0
===> Done



===> Generating patch
===> Viewing diff with less
diff -ruN --exclude=CVS /usr/ports/chinese/xcin/Makefile /home/rafan/tmp/ports/a/xcin25/Makefile
--- /usr/ports/chinese/xcin/Makefile	Mon May  1 00:30:16 2006
+++ /home/rafan/tmp/ports/a/xcin25/Makefile	Mon May  1 11:30:26 2006
@@ -19,46 +19,41 @@
 COMMENT=	Chinese input method server under X
 
 LIB_DEPENDS=	tabe.2:${PORTSDIR}/chinese/libtabe
-
-.if !defined(USE_DB2)
-LIB_DEPENDS+=	db3.3:${PORTSDIR}/databases/db3
-.else
-LIB_DEPENDS+=	db2.0:${PORTSDIR}/databases/db2
-.endif
-RUN_DEPENDS=	${X11BASE}/lib/X11/fonts/local/kc15f.pcf.gz:${PORTSDIR}/chinese/kcfonts \
-		${LOCALBASE}/share/tabe/libtabe-0.2.5:${PORTSDIR}/chinese/libtabe
+RUN_DEPENDS=	${X11BASE}/lib/X11/fonts/local/kc15f.pcf.gz:${PORTSDIR}/chinese/kcfonts
 
 WRKSRC=		${WRKDIR}/xcin
+USE_BDB=	yes
+OBSOLETE_BDB_VAR=	USE_DB2
 USE_GETTEXT=	yes
 USE_ICONV=	yes
 USE_X_PREFIX=	yes
 GNU_CONFIGURE=	yes
 INSTALLS_SHLIB=	yes
-USE_REINPLACE=	yes
 CONFIGURE_ARGS=	--prefix=${PREFIX} \
 		--x-libraries=${X11BASE}/lib \
 		--with-xcin-dir=${PREFIX}/lib/X11/xcin25 \
-		--with-db-lib=${LOCALBASE}/lib \
+		--with-db-name=${BDB_LIB_NAME} \
+		--with-db-inc=${BDB_INCLUDE_DIR} \
+		--with-db-lib=${BDB_LIB_DIR} \
 		--with-tabe-inc=${LOCALBASE}/include/tabe \
 		--with-tabe-lib=${LOCALBASE}/lib \
 		--with-intl-inc=${LOCALBASE}/include \
 		--with-intl-lib=${LOCALBASE}/lib \
 		--with-iconv-inc=${LOCALBASE}/include \
 		--with-iconv-lib=${LOCALBASE}/lib
-.if !defined(USE_DB2)
-CONFIGURE_ARGS+= --with-db-inc=${LOCALBASE}/include/db3
-.else
-CONFIGURE_ARGS+= --with-db-inc=${LOCALBASE}/include/db2
-.endif
 
 MAN1=		xcin.1
 
-pre-fetch:
-.if !defined(USE_DB2)
-	@${ECHO} --
-	@${ECHO} "Type \"make -DUSE_DB2\" if you want use DB2."
-	@${ECHO} "Otherwise, xcin2.5 will use DB3."
-	@${ECHO} --
+.include <bsd.port.pre.mk>
+
+pre-everything::
+.if defined(WITH_BDB_VER)
+	@${ECHO} ""
+	@${ECHO} "WARNING:"
+	@${ECHO} "	You have defined WITH_BDB_VER. Make sure you use the same"
+	@${ECHO} "	db version that libtabe uses. Otherwise, this port may"
+	@${ECHO} "	not work correctly."
+	@${ECHO} ""
 .endif
 
 post-extract:
@@ -102,4 +97,4 @@
 .endfor
 .endif
 
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff -ruN --exclude=CVS /usr/ports/chinese/xcin/files/patch-configure /home/rafan/tmp/ports/a/xcin25/files/patch-configure
--- /usr/ports/chinese/xcin/files/patch-configure	Wed Dec 31 19:00:00 1969
+++ /home/rafan/tmp/ports/a/xcin25/files/patch-configure	Mon May  1 11:16:24 2006
@@ -0,0 +1,68 @@
+--- configure.orig	Tue Nov 27 09:21:17 2001
++++ configure	Sat Apr 22 01:24:08 2006
+@@ -32,6 +32,8 @@
+ ac_help="$ac_help
+   --with-db-lib=PATH        set the library dir of Berkeley DB2/3."
+ ac_help="$ac_help
++  --with-db-name=NAME       set the library name of Berkeley DB."
++ac_help="$ac_help
+   --with-tabe-inc=PATH      set the include dir of libtabe."
+ ac_help="$ac_help
+   --with-tabe-lib=PATH      set the library dir of libtabe."
+@@ -869,6 +871,15 @@
+ fi
+ 
+ 
++# Check whether --with-db_name or --without-db_name was given.
++if test "${with_db_name+set}" = set; then
++  withval="$with_db_name"
++    test x$withval != x && with_db_name="$withval"
++else
++    with_db_name='db'
++fi;
++
++
+ # Check whether --with-tabe_inc or --without-tabe_inc was given.
+ if test "${with_tabe_inc+set}" = set; then
+   withval="$with_tabe_inc"
+@@ -7869,7 +7880,7 @@
+ fi
+ 
+ LIBS="$OLD_LIBS"
+-for f in db db3; do
++for f in $with_db_name; do
+     echo $ac_n "checking for db_create in -l$f""... $ac_c" 1>&6
+ echo "configure:7875: checking for db_create in -l$f" >&5
+ ac_lib_var=`echo $f'_'db_create | sed 'y%./+-%__p_%'`
+@@ -7878,16 +7889,20 @@
+ else
+   ac_save_LIBS="$LIBS"
+ LIBS="-l$f  $LIBS"
++__db_create="db_create"
++if [ "$f" = "db-4.2" ]; then
++  __db_create="db_create_4002"
++fi
+ cat > conftest.$ac_ext <<EOF
+ #line 7883 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+     builtin and then its argument prototype would still apply.  */
+-char db_create();
++char $__db_create();
+ 
+ int main() {
+-db_create()
++$__db_create()
+ ; return 0; }
+ EOF
+ if { (eval echo configure:7894: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+@@ -7914,7 +7929,7 @@
+     test $found = y && break
+ done
+ if test $found = n; then
+-    for f in db db2; do
++    for f in $with_db_name; do
+ 	echo $ac_n "checking for db_open in -l$f""... $ac_c" 1>&6
+ echo "configure:7920: checking for db_open in -l$f" >&5
+ ac_lib_var=`echo $f'_'db_open | sed 'y%./+-%__p_%'`
===> Done
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605011628.k41GSFTb051259>