[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Patches for configure.in
From: |
Katsuhiro Kondou |
Subject: |
Re: Patches for configure.in |
Date: |
Mon, 28 May 2001 23:18:15 +0900 (JST) |
In article <address@hidden>,
address@hidden wrote;
} I seem to have deleted the mail I received recently from Japan
} with some patches for configure 2.0.aX. I wonder if I could
} ask you to send them once more.
}
} Sorry about this, I just had a huge tidy up of my mail box.
Attached. And it also drops '#ifdef HAVE_*DB*' stuff since
BerkeleyDB is mandatory for 2.0.aX.
--
Katsuhiro Kondou
--- cfengine-2.0.a7/configure.in Mon May 7 18:25:09 2001
+++ cfengine-2.0.a7.ok/configure.in Mon May 21 18:59:01 2001
@@ -21,8 +21,8 @@
# Add to the default list of places in LDFLAGS to compensate for
# ... the configure default value of LIBS on some systems
#
-for x in /usr/local/ssl/lib /usr/local/BerkeleyDB/lib /usr/local/gnu/lib \
- /usr/local/gnulib /usr/local/lib /opt/dce/lib
+for x in /usr/local/ssl/lib /usr/local/gnu/lib /usr/local/gnulib \
+ /usr/local/lib /opt/dce/lib
do
if test -d "$x"; then
y=`expr " $LDFLAGS " : ".* -L$x "`
@@ -35,8 +35,8 @@
#
# Add to the default list of places in CPPFLAGS to match LDFLAGS above
#
-for x in /usr/local/ssl/include /usr/local/BerkeleyDB/include \
- /usr/local/include /usr/local/gnu/include /opt/dce/include
+for x in /usr/local/ssl/include /usr/local/include /usr/local/gnu/include \
+ /opt/dce/include
do
if test -d "$x"; then
y=`expr " $CPPFLAGS " : ".* -I$x "`
@@ -81,8 +81,65 @@
dnl AC_CHECK_FUNC(yp_get_default_domain, , AC_CHECK_LIB(nsl,
yp_get_default_domain))
AC_SEARCH_LIBS(socket, socket, ,
[AC_CHECK_LIB(nsl, socket, LIBS="$LIBS -lsocket -lnsl", , -lsocket)])
-dnl AC_CHECK_FUNC(db_create, AC_DEFINE(HAVE_DB_CREATE), AC_CHECK_LIB(db,
db_create))
-AC_CHECK_LIB(db, db_create)
+
+dnl Check for whether the user wants to compile with BerkeleyDB, and if so
+dnl what the path to the various components of it is.
+AC_DEFUN([CFENGINE_LIB_BERKELEYDB],
+[AC_ARG_WITH(berkeleydb,
+ [ --with-berkeleydb[=PATH]directory where BerkeleyDB exists],
+ BERKELEY_DB_DIR=$with_berkeleydb,
+ BERKELEY_DB_DIR=yes)
+AC_MSG_CHECKING(if BerkeleyDB is desired)
+if test x"$BERKELEY_DB_DIR" = xno ; then
+ AC_MSG_RESULT(no)
+ BERKELEY_DB_LDFLAGS=
+ BERKELEY_DB_CFLAGS=
+ BERKELEY_DB_LIB=
+else
+ AC_MSG_RESULT(yes)
+ AC_MSG_CHECKING(for BerkeleyDB location)
+ if test x"$BERKELEY_DB_DIR" = xyes ; then
+ for v in BerkeleyDB BerkeleyDB.3.0 BerkeleyDB.3.1 BerkeleyDB.3.2 ; do
+ for d in /usr /opt /usr/local ; do
+ test -d "$d/$v" && BERKELEY_DB_DIR="$d/$v"
+ done
+ done
+ fi
+ if test x"$BERKELEY_DB_DIR" = xyes ; then
+ for v in db3 db2 ; do
+ if test -d "/usr/local/include/$v" ; then
+ BERKELEY_DB_LDFLAGS="-L/usr/local/lib"
+ BERKELEY_DB_CFLAGS="-I/usr/local/include/$v"
+ BERKELEY_DB_LIB="-l$v"
+ AC_MSG_RESULT(FreeBSD locations)
+ break
+ fi
+ done
+ if test x"$BERKELEY_DB_LIB" = x ; then
+ for v in db3 db2 ; do
+ if test -d "/usr/include/$v" ; then
+ BERKELEY_DB_CFLAGS="-I/usr/include/$v"
+ BERKELEY_DB_LIB="-l$v"
+ AC_MSG_RESULT(Linux locations)
+ break
+ fi
+ done
+ if test x"$BERKELEY_DB_LIB" = x ; then
+ AC_MSG_ERROR(Cannot find BerkeleyDB)
+ fi
+ fi
+ else
+ BERKELEY_DB_LDFLAGS="-L$BERKELEY_DB_DIR/lib"
+ BERKELEY_DB_CFLAGS="-I$BERKELEY_DB_DIR/include"
+ BERKELEY_DB_LIB="-ldb"
+ AC_MSG_RESULT($BERKELEY_DB_DIR)
+ fi
+ AC_DEFINE(USE_BERKELEY_DB, 1, [Define if BerkeleyDB is available.])
+fi
+AC_SUBST(BERKELEY_DB_LDFLAGS)
+AC_SUBST(BERKELEY_DB_CFLAGS)
+AC_SUBST(BERKELEY_DB_LIB)])
+CFENGINE_LIB_BERKELEYDB
AC_CHECK_LIB(rx, main) dnl GNU regex lib if you have regcomp in libc you
shouldn't have this
AC_CHECK_LIB(crypto,main)
@@ -413,8 +470,8 @@
dnl Now make the Makefiles
dnl ######################################################################
-AC_OUTPUT(pub/Makefile doc/Makefile src/Makefile bin/Makefile
- contrib/Makefile inputs/Makefile Makefile doc/cfengine.8
+AC_OUTPUT(pub/Makefile src/Makefile bin/Makefile
+ contrib/Makefile inputs/Makefile Makefile
bin/cfdaily src/cflex.l contrib/cfcron contrib/vicf)
chmod 0755 bin/cfmail bin/cfdaily bin/cfwrap contrib/cfdoc \
--- cfengine-2.0.a7/src/Makefile.in Tue May 15 22:22:04 2001
+++ cfengine-2.0.a7.ok/src/Makefile.in Mon May 21 20:05:17 2001
@@ -77,7 +77,7 @@
VERSION = @VERSION@
YACC = @YACC@
-CFLAGS = @CFLAGS@ #-Wreturn-type -Wmissing-prototypes -Wstrict-prototypes
-Wuninitialized
+CFLAGS = @BERKELEY_DB_CFLAGS@ @CFLAGS@ #-Wreturn-type -Wmissing-prototypes
-Wstrict-prototypes -Wuninitialized
YFLAGS = -d
LEXLIB = @LEXLIB@
LDADD = -L../pub -lpub
@@ -87,12 +87,12 @@
cfengine_SOURCES = cfengine.c
do.c
wrapper.c
report.c
client.c
process.c
ifconf.c image.c
item.c
item-ext.c
item-file.c
2Dlist.c
globals.c
classes.c
misc.c
parse.c
edittools.c
patches.c
install.c link.c
tidy.c
filedir.c
eval.c
modes.c
chflags.c
locks.c
mount.c
macro.c
filenames.c
varstring.c
wildcard.c
cfparse.y
comparray.c read.c
checksums.c
proto.c
filters.c
copy.c
repository.c
rotate.c
errors.c
cflex.l
net.c df.c
log.c
e!
nc!
rypt.c popen.c
sensible.c
acl.c
dce_acl.c
nameinfo.c
strategies.c
-cfengine_LDADD = -L../pub -lpub $(LEXLIB)
+cfengine_LDADD = -L../pub -lpub $(LEXLIB) @BERKELEY_DB_LIB@
cfd_SOURCES = cfd.c
parse.c
install.c
cfparse.c
chflags.c cflex.l
item.c
item-ext.c
varstring.c
popen.c
globals.c
filenames.c
macro.c
eval.c
read.c
classes.c misc.c
2Dlist.c
modes.c
locks.c
wildcard.c
copy.c
rotate.c
net.c
acl.c
dce_acl.c log.c
errors.c
encrypt.c
filters.c
patches.c
nameinfo.c
strategies.c
-cfd_LDADD = -L../pub -lpub $(LEXLIB)
+cfd_LDADD = -L../pub -lpub $(LEXLIB) @BERKELEY_DB_LIB@
cfrun_SOURCES = cfrun.c
item.c
filenames.c
proto.c popen.c
net.c
read.c
log.c
patches.c
globals.c
@@ -154,19 +154,19 @@
cflex.o net.o df.o log.o encrypt.o popen.o sensible.o acl.o dce_acl.o \
nameinfo.o strategies.o
cfengine_DEPENDENCIES =
-cfengine_LDFLAGS =
+cfengine_LDFLAGS = @BERKELEY_DB_LDFLAGS@
cfd_OBJECTS = cfd.o parse.o install.o cfparse.o chflags.o cflex.o \
item.o item-ext.o varstring.o popen.o globals.o filenames.o macro.o \
eval.o read.o classes.o misc.o 2Dlist.o modes.o locks.o wildcard.o \
copy.o rotate.o net.o acl.o dce_acl.o log.o errors.o encrypt.o \
filters.o patches.o nameinfo.o strategies.o
cfd_DEPENDENCIES =
-cfd_LDFLAGS =
+cfd_LDFLAGS = @BERKELEY_DB_LDFLAGS@
cfrun_OBJECTS = cfrun.o item.o filenames.o proto.o popen.o net.o read.o \
log.o patches.o globals.o
-cfrun_LDADD = $(LDADD)
+cfrun_LDADD = $(LDADD) @BERKELEY_DB_LIB@
cfrun_DEPENDENCIES =
-cfrun_LDFLAGS =
+cfrun_LDFLAGS = @BERKELEY_DB_LDFLAGS@
cfkey_OBJECTS = cfkey.o encrypt.o popen.o globals.o read.o classes.o \
errors.o patches.o log.o
cfkey_LDADD = $(LDADD)
@@ -175,13 +175,13 @@
cfenvd_OBJECTS = cfenvd.o globals.o filenames.o nameinfo.o classes.o \
item.o item-ext.o eval.o wildcard.o df.o read.o log.o popen.o patches.o \
locks.o
-cfenvd_LDADD = $(LDADD)
+cfenvd_LDADD = $(LDADD) @BERKELEY_DB_LIB@
cfenvd_DEPENDENCIES =
-cfenvd_LDFLAGS =
+cfenvd_LDFLAGS = @BERKELEY_DB_LDFLAGS@
cfenvgraph_OBJECTS = cfenvgraph.o
-cfenvgraph_LDADD = $(LDADD)
+cfenvgraph_LDADD = $(LDADD) @BERKELEY_DB_LIB@
cfenvgraph_DEPENDENCIES =
-cfenvgraph_LDFLAGS =
+cfenvgraph_LDFLAGS = @BERKELEY_DB_LDFLAGS@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
$(CFLAGS)
CCLD = $(CC)
--- cfengine-2.0.a7/src/cfenvd.c Tue May 15 15:56:59 2001
+++ cfengine-2.0.a7.ok/src/cfenvd.c Mon May 21 18:59:01 2001
@@ -35,9 +35,7 @@
#include "../pub/getopt.h"
#include <math.h>
-#ifdef HAVE_DB_H
# include <db.h>
-#endif
#define AVDB "/var/cfengine/av.db"
#define STATELOG "/var/cfengine/state_log"
--- cfengine-2.0.a7/src/cfenvgraph.c Tue May 15 07:16:14 2001
+++ cfengine-2.0.a7.ok/src/cfenvgraph.c Mon May 21 18:59:01 2001
@@ -42,7 +42,6 @@
#include "../pub/getopt.h"
#include <math.h>
-#ifdef HAVE_DB_H
# include <db.h>
/*****************************************************************************/
@@ -582,7 +581,3 @@
return timekey;
}
-
-
-
-#endif
--- cfengine-2.0.a7/src/conf.h.in Tue Apr 3 23:02:54 2001
+++ cfengine-2.0.a7.ok/src/conf.h.in Mon May 21 19:01:54 2001
@@ -193,9 +193,6 @@
/* Define if you have the waitpid function. */
#undef HAVE_WAITPID
-/* Define if you have the <db.h> header file. */
-#undef HAVE_DB_H
-
/* Define if you have the <dce/daclif.h> header file. */
#undef HAVE_DCE_DACLIF_H
@@ -288,9 +285,6 @@
/* Define if you have the crypto library (-lcrypto). */
#undef HAVE_LIBCRYPTO
-
-/* Define if you have the db library (-ldb). */
-#undef HAVE_LIBDB
/* Define if you have the dce library (-ldce). */
#undef HAVE_LIBDCE
--- cfengine-2.0.a7/src/locks.c Tue May 15 18:13:36 2001
+++ cfengine-2.0.a7.ok/src/locks.c Mon May 21 19:06:27 2001
@@ -65,11 +65,9 @@
#include "cf.defs.h"
#include "cf.extern.h"
-#ifdef HAVE_DB_H
# include <db.h>
DB *DBP;
-#endif
/* The locks need these in case of signals */
@@ -122,8 +120,6 @@
return;
}
-#ifdef HAVE_LIBDB
-
sprintf(LOCKDB,"%s/cfengine_lock_db",VLOCKDIR);
if ((errno = db_create(&DBP,NULL,0)) != 0)
@@ -139,8 +135,6 @@
CfLog(cferror,OUTPUT,"db_open");
return;
}
-
-#endif
}
/************************************************************************/
@@ -153,15 +147,11 @@
return;
}
-#ifdef HAVE_LIBDB
DBP->close(DBP,0);
-#endif
}
/************************************************************************/
-#ifdef HAVE_LIBDB
-
int GetLock(operator,operand,ifelapsed,expireafter,host,now)
char *operator, *operand, *host;
@@ -585,301 +575,6 @@
}
/************************************************************************/
-/************************************************************************/
-
-#else
-
-/************************************************************************/
-/* For any old-timers this old implementation still works, but leads to
- problems for some filesystems, handling many inodes quickly ... */
-/************************************************************************/
-
-int GetLock(operator,operand,ifelapsed,expireafter,host,now)
-
-char *operator, *operand, *host;
-int ifelapsed, expireafter;
-time_t now;
-
-{ struct stat statbuf;
- unsigned int pid;
- time_t lastcompleted = 0, elapsedtime;
-
-if (IGNORELOCK)
- {
- return true;
- }
-
-if (now == 0)
- {
- if ((now = time((time_t *)NULL)) == -1)
- {
- printf("Couldn't read system clock\n");
- }
- return true;
- }
-
-Debug("GetLock(%s,%s,time=%d), ExpireAfter=%d,
IfElapsed=%d\n",operator,operand,now,expireafter,ifelapsed);
-
-sprintf(CFLOG,"%s/cfengine.%s.runlog",VLOGDIR,host);
-sprintf(CFLOCK,"%s/lock.%s.%s.%s.%s",VLOCKDIR,VCANONICALFILE,host,operator,operand);
-sprintf(CFLAST,"%s/last.%s.%s.%s.%s",VLOCKDIR,VCANONICALFILE,host,operator,operand);
-
-if (strlen(CFLOCK) > MAX_FILENAME)
- {
- CFLOCK[MAX_FILENAME] = '\0'; /* most nodenames are 255 chars or less */
- }
-
-if (strlen(CFLAST) > MAX_FILENAME)
- {
- CFLAST[MAX_FILENAME] = '\0'; /* most nodenames are 255 chars or less */
- }
-
-/* Look for non-existent (old) processes */
-
-lastcompleted = GetLastLock();
-elapsedtime = (time_t)(now-lastcompleted) / 60;
-
-if (elapsedtime < 0)
- {
- sprintf(OUTPUT,"Another cfengine seems to have done %s.%s since I
started\n",operator, operand);
- CfLog(cfverbose,OUTPUT,"");
- return false;
- }
-
-if (elapsedtime < ifelapsed)
- {
- sprintf(OUTPUT,"Too soon since last run with %s.%s (%u/%u
minutes)\n",operator,operand,elapsedtime,ifelapsed);
- CfLog(cfverbose,OUTPUT,"");
- return false;
- }
-
-/* Look for existing (current) processes */
-
-lastcompleted = CheckOldLock();
-elapsedtime = (time_t)(now-lastcompleted) / 60;
-
-if (lastcompleted != 0)
- {
- if (elapsedtime >= expireafter)
- {
- sprintf(OUTPUT,"Lock %s expired...(after %u/%u
minutes)\n",CFLOCK,elapsedtime,expireafter);
- CfLog(cfinform,OUTPUT,"");
-
- pid = GetLockPid(CFLOCK);
-
- if (pid == -1)
- {
- sprintf(OUTPUT,"Illegal pid in corrupt lock %s - ignoring
lock\n",CFLOCK);
- CfLog(cferror,OUTPUT,"");
- }
- else
- {
- Verbose("Trying to kill expired cfengine\n");
- kill(pid,SIGCONT);
- sleep(3);
- kill(pid,SIGINT);
- sleep(1);
- kill(pid,SIGTERM);
- sleep(5);
- kill(pid,SIGKILL);
- sleep(1);
-
- if (kill(pid,SIGTERM) == ESRCH)
- {
- sprintf(OUTPUT,"Unable to kill expired process %d, exiting this
time..\n",pid);
- CfLog(cferror,OUTPUT,"");
- FatalError("");;
- }
-
- LockLog(pid,"Lock expired, process killed",operator,operand);
- }
-
- unlink(CFLOCK);
- }
- else
- {
- Verbose("Couldn't obtain lock for %s (already running!)\n",CFLOCK);
- return false;
- }
- }
-
-SetLock();
-return true;
-}
-
-/************************************************************************/
-
-void ReleaseCurrentLock()
-
-{ int fd;
-
-if (IGNORELOCK)
- {
- return;
- }
-
-Debug("ReleaseCurrentLock(%s)\n",CFLOCK);
-
- if (strlen(CFLOCK) == 0) /* Happens in fatal errors */
- {
- return;
- }
-
-if (unlink(CFLOCK) == -1)
- {
- sprintf(OUTPUT,"Unable to remove lock %s\n",CFLOCK);
- CfLog(cflogonly,OUTPUT,"unlink");
- return;
- }
-
-if ((fd = creat(CFLAST,0644)) == -1)
- {
- sprintf(OUTPUT,"Unable to create %s\n",CFLAST);
- CfLog(cferror,OUTPUT,"creat");
- return;
- }
-else
- {
- close(fd);
- }
-
-LockLog(getpid(),"Lock removed normally ",CFLOCK,"");
-}
-
-
-/************************************************************************/
-
-int CountActiveLocks()
-
- /* Count the number of active locks == number of cfengines running */
-
-{ DIR *dirh;
- struct dirent *dirp;
- int count = 0;
-
-if ((dirh = opendir(VLOCKDIR)) == NULL)
- {
- sprintf(OUTPUT,"Can't open directory %s\n",VLOCKDIR);
- CfLog(cferror,OUTPUT,"opendir");
- return 0;
- }
-
-for (dirp = readdir(dirh); dirp != NULL; dirp = readdir(dirh))
- {
- if (strncmp(dirp->d_name,"lock",4) == 0)
- {
- count++;
- }
- }
-
-closedir(dirh);
-
-return count;
-}
-
-/************************************************************************/
-/* Level 2 */
-/************************************************************************/
-
-time_t GetLastLock()
-
-{ struct stat statbuf;
- int fd;
-
-bzero(&statbuf,sizeof(statbuf));
-
-Debug("GetLastLock()\n");
-
-if (stat(CFLAST,&statbuf) == -1)
- {
-
- /* Do this to prevent deadlock loops from surviving if IfElapsed > T_sched
*/
-
- if ((fd = creat(CFLAST,0644)) == -1)
- {
- sprintf(OUTPUT,"Unable to create %s\n",CFLAST);
- CfLog(cferror,OUTPUT,"creat");
- return 0;
- }
- else
- {
- close(fd);
- }
- return 0;
- }
-else
- {
- return statbuf.st_mtime;
- }
-}
-
-/************************************************************************/
-
-time_t CheckOldLock()
-
-{ struct stat statbuf;
-
-bzero(&statbuf,sizeof(statbuf));
-
-Debug("CheckOldLock()\n");
-
-if (stat(CFLOCK,&statbuf) == -1)
- {
- return 0;
- }
-else
- {
- return statbuf.st_mtime;
- }
-}
-
-/************************************************************************/
-
-pid_t GetLockPid(name)
-
-char *name;
-
-{ FILE *fp;
- pid_t pid = (pid_t)-1;
-
-if ((fp = fopen(CFLOCK,"r")) == NULL)
- {
- CfLog(cferror,"GetLock weird error, lock disappeared!\n","fopen");
- FatalError("");
- }
-
-fscanf(fp,"%d",&pid);
-
-fclose(fp);
-
-return pid;
-}
-
-/************************************************************************/
-
-void SetLock()
-
-{ FILE *fp;
-
-Debug("SetLock(%s)\n",CFLOCK);
-
-if ((fp = fopen(CFLOCK,"w")) == NULL)
- {
- sprintf(OUTPUT,"GetLock: can't open new lock file %s\n",CFLOCK);
- CfLog(cferror,OUTPUT,"fopen");
- FatalError("");;
- }
-
-fprintf(fp,"%d\n",getpid());
-
-fclose(fp);
-chmod(CFLOCK,0644);
-}
-
-
-#endif
-
-
/************************************************************************/
void LockLog(pid,str,operator,operand)
--- cfengine-2.0.a7/src/misc.c Wed May 9 15:02:05 2001
+++ cfengine-2.0.a7.ok/src/misc.c Mon May 21 18:59:02 2001
@@ -35,9 +35,7 @@
#include "../pub/global.h"
#include "../pub/md5.h"
-#ifdef HAVE_DB_H
# include <db.h>
-#endif
/*********************************************************************/
/* TOOLKIT : files/directories */
@@ -120,7 +118,6 @@
int i, matched, needupdate = false;
char dbvalue[17],dbdigest[17];
time_t tloc;
-#if defined HAVE_LIBDB
DBT key,value;
DB *dbp;
DB_ENV *dbenv = NULL;
@@ -318,26 +315,6 @@
return true;
}
}
-
-#else
-Verbose("No Berkeley DB3 database support available.\n");
-
-if (!ISCFENGINE)
- {
- Debug("Direct comparison (no db)\n");
- cfMDFile(filename,dbdigest);
- for (i = 0; i < 16; i++)
- {
- if (digest[i] != dbdigest[i])
- {
- return true;
- }
- }
- return false;
- }
-
-return false;
-#endif
}
/*************************************************************************/