I have a FreeBSD system with DB 4.2 installed on it. FreeBSD's ports system carefully segregates various versions of Berkeley DB so that multiple versions can be installed simultaneously without interfering with each other. It does this by putting the various headers into /usr/local/include/dbXX (XX=42 for DB 4.2, XX=45 for DB 4.5, etc.), and the libraries into /usr/local/lib/libdb-XX.* (Again, XX indicating version number).
It is a simple matter run pagc's configure to find these things:
./configure LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include/db42"
This locates the DB headers and libraries:
[...]
checking for db.h... 4.2.52
checking for library containing Berkeley DB 4.2.52... -ldb-4.2
configure: using Berkeley DB version
checking for db.h... 4.2.52
checking for library containing Berkeley DB 4.2.52... -ldb-4.2
configure: using Berkeley DB version
[...]
and configure exits cleanly. However, when trying to build, it is clear that configure has placed "-ldb" into the LIBS variable instead of the "-ldb-4.2" it so carefully located, as a "make" builds all the .o files and fails in the link phase:
gcc -g -O2 -L/usr/local/lib -o pagc main.o standard.o alpharef.o beta_ref.o analyze.o approx.o build.o export.o gamma.o index.o initial.o lexicon.o match.o shapepos.o tokenize.o util.o shpopen.o dbfopen.o -ldb -lm
/usr/bin/ld: cannot find -ldb
*** Error code 1
Configure should not unconditionally place "-ldb" into the LIBS variable, it should place what the configure macro finds, which is obviously printed out by "checking for library containing Berkeley DB 4.2.52... -ldb-4.2" and somehow overridden later. Note also that where it's printing out BDB_VERSION, it gets a blank, so something is amiss there, too.
I tried to end-run this by forcing "-ldb-4.2" into the LIBS variable:
./configure LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include/db42" LIBS="-ldb-4.2"
which configures just fine:
[...]
checking for db.h... 4.2.52
checking for library containing Berkeley DB 4.2.52... none required
configure: using Berkeley DB version
checking for db.h... 4.2.52
checking for library containing Berkeley DB 4.2.52... none required
configure: using Berkeley DB version
[...]
but still fails in link because configure has stuffed a "-ldb" in anyway:
gcc -g -O2 -L/usr/local/lib -o pagc main.o standard.o alpharef.o beta_ref.o analyze.o approx.o build.o export.o gamma.o index.o initial.o lexicon.o match.o shapepos.o tokenize.o util.o shpopen.o dbfopen.o -ldb -lm -ldb-4.2
/usr/bin/ld: cannot find -ldb
*** Error code 1
WHen I edit makefile by hand to remove it, I get other issues related to "rpl_malloc" because apparently FreeBSD doesn't have a "GNU libc compatible malloc" as far as configure is concerned, and pagc doesn't provide the "rpl_malloc" and "rpl_realloc" functions that AC_FUNC_MALLOC and AC_FUNC_REALLOC map "malloc" and "realloc" to. Those autoconf macros require that the package provide the replacement malloc and realloc. If pagc doesn't actually depend on malloc and realloc returning non-null pointers when asked for a 0 size array, then AC_FUNC_MALLOC and AC_FUNC_REALLOC could be removed from configure.in. When I do that, do an "autoreconf", reconfigure, and edit makefile by hand (to remove "-ldb" from LIBS), pagc compiles and links on FreeBSD.
I have not yet checked to see if it *works*, though.
Logged In: YES
user_id=607718
Originator: YES
I should note that while I reported this after trying only the 0.1.2 tarball, it still fails with SVN trunk, which I tried shortly after reporting. Removing AC_FUNC_MALLOC and AC_FUNC_REALLOC from configure.in, autoreconfing, reconfiguring, and hand-editing makefile to remove the incorrect "-ldb" lets the build finish. Again, I haven't actually *run* the resulting binary, but as long as pagc isn't counting on malloc(0) being non-null always, removing AC_FUNC_MALLOC shouldn't have hurt anything.