#!/bin/sh
#set -x 
base_name=`basename $0`
base_path=`echo $0 | sed s,$base_name,,`

db_dist="${base_path}../db/dist"

rm -f config.cache

# XXX edit CFLAGS= ... out of invocation args ???
ARGS="`echo $* | sed -e 's% [^ ]*CFLAGS=[^ ]*%%' -e 's% -[^-][^ ]*%%g' -e 's% --param=[^ ]*%%g' -e 's%--cache-file=.*$%%'`"

CC="$CC" CFLAGS="$CFLAGS" $db_dist/configure $ARGS \
	--enable-shared --enable-static \
	--with-uniquename=_rpmdb --srcdir=$db_dist

mv Makefile Makefile.orig
cat Makefile.orig | sed -e '/^install[:-]/c\
.PHONY: listobjs\
listobjs:\
\	@echo $(OBJS) $(C_OBJS) \
\
distdir install check installcheck:\
\
db4_install: all install_setip' \
-e '/^uninstall[:-]/c\
uninstall:' \
-e 's/^check depend/\
check: all\
depend/' \
 > Makefile

# Generate manifest for rpmdb.
make -s listobjs > db3lobjs
