dnl Autoconfigure input file for 
dnl Jim Lowe <jhlowe@acm.org>
dnl
dnl Process this file with autoconf to produce a configure script.
dnl


AC_INIT(swbis, 0.74-support)
AM_CONFIG_HEADER(config.h)

dnl XFLEX=flex
dnl XBISON=bison
XFLEX=_
XBISON=_

dnl 20050909 usewithselfrpm is now on by default, see below
usewithrpm=no
usewithselfrpm=yes  
usewithoutrpm=no  
AC_ARG_WITH(rpm, --with-rpm   compile RPM decoding and translating program, usewithrpm=yes, usewithrpm=no)
AC_ARG_WITH(tests, --with-tests  compile test programs, compile_test_pgms=yes, compile_test_pgms=no)
AC_ARG_WITH(self-rpm, --with-self-rpm   compile RPM decoding and translating program, usewithselfrpm=yes, usewithselfrpm=yes)
AC_ARG_WITH(no-rpm, --with-no-rpm   do not compile RPM decoding and translating program, usewithrpm=no; usewithselfrpm=no; usewithoutrpm=yes, usewithoutrpm=no)
AC_ARG_WITH(no-flex,  --with-no-flex  dont use flex, usewithoutflex=yes, usewithoutflex=no)
AC_ARG_WITH(no-bison,  --with-no-bison  dont use bison, usewithoutbison=yes, usewithoutbison=no)
dnl AC_ARG_WITH(flex,  --with-flex  use flex, usewithoutflex=no, usewithoutflex=yes)
dnl AC_ARG_WITH(bison,  --with-bison  use bison, usewithoutbison=no, usewithoutbison=yes)

if test $usewithoutrpm = yes; then
	usewithselfrpm=no
fi

dnl AC_CHECK_FUNCS(tcsetattr stty setsid geteuid seteuid  \
dnl   snprintf vprintf vsnprintf vsyslog getopt_long openpty)

AC_DEFUN(jm_MACROS,
[ 
AC_REQUIRE([jm_FUNC_FPENDING])
])

dnl From Jim Meyering
dnl Using code from emacs, based on suggestions from Paul Eggert
dnl and Ulrich Drepper.

dnl Find out how to determine the number of pending output bytes on a stream.
dnl glibc (2.1.93 and newer) and Solaris provide __fpending.  On other systems,
dnl we have to grub around in the FILE struct.

AC_DEFUN(jm_FUNC_FPENDING,
[
  AC_CHECK_HEADERS(stdio_ext.h)
  AC_REPLACE_FUNCS([__fpending])
  fp_headers='
#     if HAVE_STDIO_EXT_H
#      include <stdio_ext.h>
#     endif
'
  AC_CHECK_DECLS([__fpending], , , $fp_headers)
  if test $ac_cv_func___fpending = no; then
    AC_CACHE_CHECK(
	      [how to determine the number of pending output bytes on a stream],
		   ac_cv_sys_pending_output_n_bytes,
      [
        fp_save_DEFS=$DEFS
	for ac_expr in						\
								\
	    '# glibc2'						\
	    'fp->_IO_write_ptr - fp->_IO_write_base'		\
								\
	    '# traditional Unix'				\
	    'fp->_ptr - fp->_base'				\
								\
	    '# BSD'						\
	    'fp->_p - fp->_bf._base'				\
								\
	    '# SCO, Unixware'					\
	    'fp->__ptr - fp->__base'				\
								\
	    '# old glibc?'					\
	    'fp->__bufp - fp->__buffer'				\
								\
	    '# old glibc iostream?'				\
	    'fp->_pptr - fp->_pbase'				\
								\
	    '# VMS'						\
	    '(*fp)->_ptr - (*fp)->_base'			\
								\
	    '# e.g., DGUX R4.11; the info is not available'	\
	    1							\
	    ; do

	  # Skip each embedded comment.
	  case "$ac_expr" in '#'*) continue;; esac

	  DEFS="$DEFS -DPENDING_OUTPUT_N_BYTES=$ac_expr"
	  AC_TRY_COMPILE(
	    [#include <stdio.h>
	    ],
	    [FILE *fp = stdin; (void) ($ac_expr);],
	    fp_done=yes
	  )
	  DEFS=$fp_save_DEFS
	  test "$fp_done" = yes && break
	done

	ac_cv_sys_pending_output_n_bytes=$ac_expr
      ]
    )
    AC_DEFINE_UNQUOTED(PENDING_OUTPUT_N_BYTES,
      $ac_cv_sys_pending_output_n_bytes,
      [the number of pending output bytes on stream `fp'])
  fi
])

AC_CANONICAL_HOST
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_CPP			dnl Later checks need this.
AC_PROG_CC_C_O
AC_PROG_LEX
AC_PROG_YACC
AC_PROG_AWK
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_AIX
AC_ISC_POSIX
AC_MINIX
AC_HEADER_STDC
AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_TYPE_SIGNAL

case "$usewithoutflex" in
	"yes")
		XFLEX=_
		;;
	*)
		XFLEX=flex
		;;
esac

case "$usewithoutbison" in
	"yes")
		XBISON=_
		;;
	*)
		XBISON=bison
		;;
esac

# Checks for system/compiler characteristics.
AC_C_BIGENDIAN
AC_C_CONST

ac_rpm_version=unknown
dnl RedHat 9.0
case "$ac_rpm_version" in
	unknown)
dnl Lie about the RPM version
	AC_EGREP_HEADER(RPMTAG_SOURCEPKGID.*1146, /usr/include/rpm/rpmlib.h, ac_rpm_version=4.1, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 8.0
case "$ac_rpm_version" in
	unknown)
	AC_EGREP_HEADER(RPMTAG_CACHEPKGMTIME.*1139, /usr/include/rpm/rpmlib.h, ac_rpm_version=4.1, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 7.3
case "$ac_rpm_version" in
	unknown)
	AC_EGREP_HEADER(RPMTAG_PLATFORM.*1132, /usr/include/rpm/rpmlib.h, ac_rpm_version=4.0.4, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 7.2
case "$ac_rpm_version" in
	unknown)
	AC_EGREP_HEADER(RPMTAG_SHA1RHN.*1130, /usr/include/rpm/rpmlib.h, ac_rpm_version=4.0.3, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 7.1
case "$ac_rpm_version" in
	unknown)
	AC_EGREP_HEADER(RPMTAG_REMOVETID.*1129, /usr/include/rpm/rpmlib.h, ac_rpm_version=4.0.2, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 7.0
case "$ac_rpm_version" in
	unknown)
dnl	AC_EGREP_CPP(RPMTAG_FIRSTFREE_TAG.*1128, /usr/include/rpm/rpmlib.h, ac_rpm_version=4.0, ac_rpm_version=unknown)
	egrep 'RPMTAG_FIRSTFREE_TAG.*1128' /usr/include/rpm/rpmlib.h 1>/dev/null
	if test $? -eq 0; then
		ac_rpm_version=4.0
	else
		ac_rpm_version=unknown
	fi
	;;
esac

case "$ac_rpm_version" in
	unknown)
dnl	AC_EGREP_CPP(RPMTAG_FIRSTFREE_TAG.*1127, /usr/include/rpm/rpmlib.h, ac_rpm_version=3.0.5, ac_rpm_version=unknown)
	egrep 'RPMTAG_FIRSTFREE_TAG.*1127' /usr/include/rpm/rpmlib.h 1>/dev/null
	if test $? -eq 0; then
		ac_rpm_version=3.0.5
	else
		ac_rpm_version=unknown
	fi
	;;
esac

dnl RedHat 6.2
case "$ac_rpm_version" in
	unknown)
	AC_EGREP_CPP(RPMTAG_FIRSTFREE_TAG.*1122, /usr/include/rpm/rpmlib.h, ac_rpm_version=3.0.4, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 6.1
case "$ac_rpm_version" in
	unknown)
	AC_EGREP_CPP(RPMTAG_FIRSTFREE_TAG.*1116, /usr/include/rpm/rpmlib.h, ac_rpm_version=3.0.3, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 6.0
case "$ac_rpm_version" in
	unknown)
dnl	AC_EGREP_HEADER(RPMTAG_BUILDPREREQ.*1108, /usr/include/rpm/rpmlib.h, ac_rpm_version=3.0, ac_rpm_version=unknown)
	AC_EGREP_CPP(yes,
	[#include <rpm/rpmlib.h>
	#ifdef RPMTAG_BUILDPREREQ
	yes
	#endif
	], ac_rpm_version=3.0, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 5.2
case "$ac_rpm_version" in
	unknown)
dnl	AC_EGREP_HEADER(RPMTAG_CAPABILITY.*1105, /usr/include/rpm/rpmlib.h, ac_rpm_version=2.5.5, ac_rpm_version=unknown)
	AC_EGREP_CPP(yes,
	[#include <rpm/rpmlib.h>
	#ifdef RPMTAG_CAPABILITY
	yes
	#endif
	], ac_rpm_version=2.5.5, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 5.1
case "$ac_rpm_version" in
	unknown)
dnl	AC_EGREP_HEADER(RPMTAG_AUTOPROV.*1104, /usr/include/rpm/rpmlib.h, ac_rpm_version=2.5.1, ac_rpm_version=unknown)
	AC_EGREP_CPP(yes,
	[#include <rpm/rpmlib.h>
	#ifdef RPMTAG_AUTOPROV
	yes
	#endif
	], ac_rpm_version=2.5.1, ac_rpm_version=unknown)
	;;
esac

case "$ac_rpm_version" in
	unknown)
dnl	AC_EGREP_HEADER(RPMTAG_FILELANGS.*1097, /usr/include/rpm/rpmlib.h, ac_rpm_version=2.4.12, ac_rpm_version=unknown)
	AC_EGREP_CPP(yes,
	[#include <rpm/rpmlib.h>
	#ifdef RPMTAG_FILELANGS
	yes
	#endif
	], ac_rpm_version=2.4.12, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 5.0
case "$ac_rpm_version" in
	unknown)
dnl	AC_EGREP_HEADER(RPMTAG_COOKIE.*1094, /usr/include/rpm/rpmlib.h, ac_rpm_version=2.4.10, ac_rpm_version=unknown)
	AC_EGREP_CPP(yes,
	[#include <rpm/rpmlib.h>
	#ifdef RPMTAG_COOKIE
	yes
	#endif
	], ac_rpm_version=2.4.10, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 4.2
case "$ac_rpm_version" in
	unknown)
dnl	AC_EGREP_HEADER(RPMTAG_BROKENMD5.*1083, /usr/include/rpm/rpmlib.h, ac_rpm_version=2.3.11, ac_rpm_version=unknown)
	AC_EGREP_CPP(yes,
	[#include <rpm/rpmlib.h>
	#ifdef RPMTAG_BROKENMD5
	yes
	#endif
	], ac_rpm_version=2.3.11, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 4.1
case "$ac_rpm_version" in
	unknown)
dnl	AC_EGREP_HEADER(RPMTAG_TRIGGERINDEX.*1069, /usr/include/rpm/rpmlib.h, ac_rpm_version=2.3.1, ac_rpm_version=unknown)
	AC_EGREP_CPP(yes,
	[#include <rpm/rpmlib.h>
	#ifdef RPMTAG_TRIGGERINDEX
	yes
	#endif
	], ac_rpm_version=2.3.1, ac_rpm_version=unknown)
	;;
esac

dnl RedHat 4.0
case "$ac_rpm_version" in
	unknown)
dnl	AC_EGREP_HEADER(RPMTAG_RPMVERSION.*1064, /usr/include/rpm/rpmlib.h, ac_rpm_version=2.2.7, ac_rpm_version=unknown)
	AC_EGREP_CPP(yes,
	[#include <rpm/rpmlib.h>
	#ifdef RPMTAG_RPMVERSION
	yes
	#endif
	], ac_rpm_version=2.2.7, ac_rpm_version=unknown)
	;;
esac

case "$ac_rpm_version" in
	unknown)
	echo "RPM Version not determined, defaulting to 3.0"
	ac_rpm_version=3.0
	;;
	*)
	echo "RPM Version determined to be $ac_rpm_version"
	;;
esac

case "$usewithselfrpm" in
	"yes")
		echo "Setting RPM version to the self contained version which is 3.0.5"
		ac_rpm_version=3.0.5
		;;
esac

AC_EGREP_HEADER(RPMTAG_PAYLOADCOMPRESSOR.*1125, /usr/include/rpm/rpmlib.h, ac_rpm_payloadcompressor=yes, ac_rpm_payloadcompressor=no)
AC_EGREP_HEADER(RPMTAG_FILELANGS.*1097, /usr/include/rpm/rpmlib.h, ac_rpm_filelangs=yes, ac_rpm_filelangs=no)

AC_EGREP_HEADER(RPMTAG_BASENAMES.*1117, rpm/rpmlib.h, ac_rpm_basenames=yes, ac_rpm_basenames=no)
case "$ac_rpm_basenames" in
	no)
AC_EGREP_CPP(yes,
[#include <rpm/rpmlib.h>
#ifdef RPMTAG_BASENAMES
yes
#endif
], ac_rpm_basenames=yes, ac_rpm_basenames=no)
	;;
esac

AC_EGREP_CPP(yes,
[#include <rpm/rpmio.h>
#ifdef fdNew
yes
#endif
], ac_rpm_new_fdnew=yes, ac_rpm_new_fdnew=no)

case "$usewithselfrpm" in
	"yes")
		ac_rpm_basenames=yes
		ac_rpm_new_fdnew=yes
		ac_rpm_payloadcompressor=yes
		ac_rpm_filelangs=yes
		;;
esac

case "$ac_rpm_basenames" in
	yes) AC_DEFINE(USE_RPMTAG_BASENAMES) ;;
esac
echo "fdNew evaluation $ac_rpm_new_fdnew"
echo "ac_rpm_version is [$ac_rpm_version]"

case "$ac_rpm_new_fdnew" in
	yes)   case "$ac_rpm_version" in
			4.2)
				echo "Setting USE_NEW_FDNEW72"
				AC_DEFINE(USE_NEW_FDNEW72) 
				;;
			4.1.?)
				echo "Setting USE_NEW_FDNEW72"
				AC_DEFINE(USE_NEW_FDNEW72) 
				;;
			4.1)
				echo "Setting USE_NEW_FDNEW72"
				AC_DEFINE(USE_NEW_FDNEW72) 
				;;
			4.0.4)
				echo "Setting USE_NEW_FDNEW72"
				AC_DEFINE(USE_NEW_FDNEW72) 
				;;
			4.0.3)
				echo "Setting USE_NEW_FDNEW72"
				AC_DEFINE(USE_NEW_FDNEW72) 
				;;
			*)
				echo "Setting USE_NEW_FDNEW62"
				AC_DEFINE(USE_NEW_FDNEW62) 
				;;
		esac
		;;
esac

case "$SWBISNEEDDEBUG" in
	0) /bin/true
		;;
	"") /bin/true
		;;
	*)  AC_DEFINE(SWBISNEEDDEBUG) 
		;;
esac

case "$SWBISNEEDFAIL" in
	0) /bin/true
		;;
	"") AC_DEFINE(SWBISNEEDFAIL) 
		;;
	*) AC_DEFINE(SWBISNEEDFAIL) 
		;;
esac

case "$usewithrpm" in
	"yes")
		AC_DEFINE(USE_WITH_RPM)
		;;
esac

case "$usewithselfrpm" in
	"yes")
		AC_DEFINE(USE_WITH_SELF_RPM)
		;;
esac

case "$ac_rpm_filelangs" in
	"yes")
		AC_DEFINE(RPMPSF_RPM_HAS_FILELANGS)
		;;
esac

case "$ac_rpm_payloadcompressor" in
	"yes")
		AC_DEFINE(RPMPSF_RPM_HAS_PAYLOADCOMPRESSOR)
		;;
esac

case "$ac_rpm_version" in
	4.2) AC_DEFINE(RPMPSF_RPM_VERSION_42)
		;;	
	4.1) AC_DEFINE(RPMPSF_RPM_VERSION_41)
		;;	
	4.0.4) AC_DEFINE(RPMPSF_RPM_VERSION_404) 
		;;	
	4.0.3) AC_DEFINE(RPMPSF_RPM_VERSION_403) 
		;;
	4.0.2) AC_DEFINE(RPMPSF_RPM_VERSION_402) 
		;;
	4.0) AC_DEFINE(RPMPSF_RPM_VERSION_40) 
		;;
	3.0.5) AC_DEFINE(RPMPSF_RPM_VERSION_305) 
		;;
	3.0.4) AC_DEFINE(RPMPSF_RPM_VERSION_304) 
		;;
	3.0.3) AC_DEFINE(RPMPSF_RPM_VERSION_303) 
		;;
	3.0) AC_DEFINE(RPMPSF_RPM_VERSION_30) 
		;;
	2.5.5) AC_DEFINE(RPMPSF_RPM_VERSION_255) 
		;;
	2.5.1) AC_DEFINE(RPMPSF_RPM_VERSION_251) 
		;;
	2.4.12) AC_DEFINE(RPMPSF_RPM_VERSION_2412) 
		;;
	2.4.10) AC_DEFINE(RPMPSF_RPM_VERSION_2410) 
		;;
	2.3.11) AC_DEFINE(RPMPSF_RPM_VERSION_2311) 
		;;
	2.3.1) AC_DEFINE(RPMPSF_RPM_VERSION_231) 
		;;
	2.2.7) AC_DEFINE(RPMPSF_RPM_VERSION_227) 
		;;
	*) AC_DEFINE(RPMPSF_RPM_VERSION_30) 
		;;
esac

echo "checking compiler for -Wno-unused-parameter"
gcc -Wno-unused-parameter ../var/try.c -o /dev/null 2>/dev/null
if test $? -eq 0; then
nounusedparameter=no-unused-parameter
else
nounusedparameter=no-unused
fi
AC_SUBST(nounusedparameter)

topincdir=`(cd .. && pwd)`/include
topdir=`pwd`
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_LIB(bz2, main)
dnl AC_CHECK_LIB(popt, poptParseArgvString)
dnl AC_CHECK_LIB(rpmio, fdOpen)
AC_CHECK_LIB(db, main)
AC_CHECK_LIB(db1, main)
AC_CHECK_LIB(z, main)
AC_CHECK_HEADERS(limits.h locale.h)

AC_CHECK_HEADERS( \
        libutil.h \
        getopt.h \
        sys/ioctl.h \
        sgtty.h \
        stdarg.h \
        termio.h \
        termios.h \
        sys/types.h \
        unistd.h \
        )

AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(unsigned short)
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long)

if test -f /usr/include/inttypes.h; then 
AC_DEFINE(HAVE_INTTYPES_H)
fi

if test -f /usr/include/sys/sysmacros.h; then 
AC_DEFINE(HAVE_SYSMACROS_H)
fi

if test -f /usr/include/sys/mkdev.h; then 
AC_DEFINE(HAVE_SYSMKDEV_H)
fi

if test -f /usr/include/sys/select.h; then 
AC_DEFINE(HAVE_SYSSELECT_H)
fi

RPMINCPATH=/tmp/no
case "$usewithselfrpm" in
	"yes")
		RPMINCPATH=um_rpm/rpm-3.0.5/lib
		;;
esac

RPMINCOPT=
case "$usewithrpm" in
	"yes")
RPMINCOPT="-I/usr/include/rpm"
RPMINCPATH=/usr/include/rpm
if test -f $RPMINCPATH/header.h; then 
AC_DEFINE(HAVE_RPM_HEADER_H)
fi
if test -f $RPMINCPATH/rpmdb.h; then
AC_DEFINE(HAVE_RPM_RPMDB_H)
fi
if test -f $RPMINCPATH/rpmlib.h; then
AC_DEFINE(HAVE_RPM_RPMLIB_H)
fi
if test -f $RPMINCPATH/rpmio.h; then
AC_DEFINE(HAVE_RPM_RPMIO_H)
fi
	;;
esac

case "$usewithselfrpm" in
	"yes")
AC_DEFINE(HAVE_RPM_HEADER_H)
AC_DEFINE(HAVE_RPM_RPMLIB_H)
AC_DEFINE(HAVE_RPM_RPMIO_H)
	;;
esac

echo "checking for --with-debugdump configure option"
if test $usewithdbdump = "yes"; then
AC_DEFINE(HAVE_WITH_DEBUGDUMP)
DO_DEBUG=yes
else
DO_DEBUG=""
fi

RPMLIBS=""
RPMLIBPATH=/usr/lib
RPMLIBPATH1=/lib
LIBPATHLIST="/lib /usr/lib /usr/local/lib /opt/lib"

case "$usewithselfrpm" in
	"yes")
		RPMLIBPATHLIST=""
		;;
esac

case "$usewithrpm" in
	"yes")
		RPMLIBPATHLIST="/lib /usr/lib /usr/local/lib /opt/lib"
		;;
esac

for RPMLIBPATH in $RPMLIBPATHLIST; do
if test -f $RPMLIBPATH/libpopt.a -a "$usewithrpm" = "yes"; then 
RPMLIBS="$RPMLIBS -lpopt"
break;
fi
done

for RPMLIBPATH in $RPMLIBPATHLIST; do
if test -f $RPMLIBPATH/librpm.a -a "$usewithrpm" = "yes"; then 
RPMLIBS="$RPMLIBS -lrpm"
break;
fi
done

for RPMLIBPATH in $RPMLIBPATHLIST; do
if test -f $RPMLIBPATH/librpmio.a -a "$usewithrpm" = "yes"; then 
RPMLIBS="$RPMLIBS -lrpmio"
break;
fi
done

for RPMLIBPATH in $RPMLIBPATHLIST; do
if test -f $RPMLIBPATH/librpmdb.so -a "$usewithrpm" = "yes"; then 
RPMLIBS="$RPMLIBS -lrpmdb"
break;
fi
done

for xLIBPATH in $LIBPATHLIST; do
if test -f $xLIBPATH/librt.so -o -h $xLIBPATH/librt.so; then 
LIBS="$LIBS -lrt"
break;
fi
done

for xLIBPATH in $LIBPATHLIST; do
if test -f $xLIBPATH/libutil.so -o -h $xLIBPATH/libutil.so; then 
LIBS="$LIBS -lutil"
break;
fi
done

case "$usewithselfrpm" in
	"yes")
		RPMLIBS=../um_rpm/um_librpm.a
		;;
esac

for xLIBPATH in $LIBPATHLIST; do
if test -f $xLIBPATH/libnsl.so -o -h $xLIBPATH/libnsl.so; then 
RPMLIBS="$RPMLIBS -lnsl"
break;
fi
done

for xLIBPATH in $LIBPATHLIST; do
if test -f $xLIBPATH/libsocket.so -o -h $xLIBPATH/libsocket.so; then 
RPMLIBS="$RPMLIBS -lsocket"
break;
fi
done

RPMPROGS=""
if test "$usewithoutrpm" = "yes"; then 
RPMLIBOBJECTS_="RPMLIBOBJECTS="
AC_SUBST(RPMLIBOBJECTS_)
fi

if test "$compile_test_pgms" != "yes"; then 
TESTPROGS_="TESTPROGS="
AC_SUBST(TESTPROGS_)
if test "$usewithoutrpm" = "yes"; then 
TESTRPMPROGS_="TESTRPMPROGS="
AC_SUBST(TESTRPMPROGS_)
fi
fi

if test "$usewithoutrpm" != "yes"; then 
case "$usewithrpm" in
	"yes")
		RPMPROGS="rpmheaderdump rpm2swpsf list2tar rpmarchivedump lxpsf"
		;;
esac

case "$usewithselfrpm" in
	"yes")
		RPMPROGS="rpmheaderdump rpm2swpsf list2tar rpmarchivedump lxpsf"
		;;
esac
else
RPMPROGS_="RPMPROGS="
AC_SUBST(RPMPROGS_)
fi

case "$usewithselfrpm" in
	"yes")
		DO_UM_RPM="um_rpm"
		;;	
	*)
		DO_UM_RPM=""
		;;
esac

if test "$GCC" = yes
then
   CFLAGS="-pedantic -W -Wall -Wstrict-prototypes -Wno-unused $CFLAGS"
else
   CFLAGS="$CFLAGS"
fi

AC_CHECK_FUNCS(tcsetattr stty setsid geteuid seteuid  \
  snprintf vprintf vsnprintf vsyslog getopt_long openpty)

AC_CHECK_TYPE(major_t, int)
AC_CHECK_TYPE(minor_t, int)
AC_CHECK_TYPE(minor_t, int)

jm_MACROS

AC_SUBST(INCPATH)
AC_SUBST(LIBMISC)
AC_SUBST(LIBINTL)
AC_SUBST(varprefix)
AC_SUBST(tmpdir)
AC_SUBST(topincdir)
AC_SUBST(topdir)
AC_SUBST(INTLDEF)
AC_SUBST(XGETTEXT)
AC_SUBST(LIBINTL)
AC_SUBST(RPMLIBS)
AC_SUBST(RPMINCOPT)
AC_SUBST(DO_DEBUG)
AC_SUBST(DO_UM_RPM)
AC_SUBST(RPMPROGS)
AC_SUBST(LIBS)
AC_SUBST(PO)
AC_SUBST(GETTEXTSTUB)
AC_SUBST(FIXPERMS)
AC_SUBST(nounusedparameters)
SWBISDEFS="-DSWBISLIBEXECDIR=\\\"${libexecdir}\\\" -DSWBISLIBDIR=\\\"${libdir}\\\""
AC_SUBST(SWBISDEFS)
AC_SUBST(XFLEX)
AC_SUBST(XBISON)

case "$usewithselfrpm" in
	yes)
AC_CONFIG_SUBDIRS(um_rpm/rpm-3.0.5)
		;;
	*)
		;;
esac

AC_OUTPUT(Makefile Makefile.inc \
		taru/Makefile \
		uxfio/Makefile \
		misc/Makefile \
		strob/Makefile \
		uinfile/Makefile \
		sw_parse/Makefile \
		cplob/Makefile \
		progs/Makefile \
		getopt/Makefile \
		progressmeter/Makefile \
		ls_list/Makefile \
		um_rpm/Makefile \
		compression/Makefile \
		shell_lib/Makefile \
		swi/Makefile \
		rpmbis/Makefile \
		tests/Makefile)


if test "$usewithselfrpm" = "yes"; then 
echo "You are using the self contained rpmlib and header files."
fi

if test "$usewithrpm" = "yes"; then 
echo "You are using the system rpmlib and header files."
fi

if test "$usewithrpm" = "yes" -o "$usewithselfrpm" = "yes"; then 
echo "You are compiling rpm dependent utilities."
else 
echo "You are NOT compiling rpm dependent utilities."
fi

if test "$compile_test_pgms" = "yes"; then 
echo "You are compiling the test programs."
else 
echo "You are NOT compiling the test programs."
fi
