From 6f73c2804023a6ff2152cf65459ec4c5db2f66eb Mon Sep 17 00:00:00 2001 From: J. Ali Harlow Date: Tue, 6 Jan 2009 14:06:00 +0000 Subject: [PATCH] Make rpmlib an optional dependency Use configure --without-rpm to avoid the dependency (default is unchanged). --- configure.ac | 26 ++++++++++++++------------ src/Makefile.am | 5 ++++- src/main.c | 4 ++++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 81192e6..dd40a0b 100644 --- a/configure.ac +++ b/configure.ac @@ -154,19 +154,21 @@ AC_CHECK_LIB(expat, XML_ParserCreate, [EXPAT_LIBS="-lexpat"], [AC_MSG_ERROR([Can't find expat library. Please install expat.])]) AC_SUBST(EXPAT_LIBS) -RPM_LIB="" -AC_ARG_WITH(rpm, [ --with-rpm= Use rpm from here], - [ - rpm=$withval - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - ] - ) -AC_CHECK_HEADERS(rpm/rpmlib.h, [], - [AC_MSG_ERROR([Can't find rpm/rpmlib.h. Please install rpm-devel.])]) -AC_CHECK_LIB(rpm,rpmdbOpen,[RPM_LIBS="-lrpm"], - [AC_MSG_ERROR([Can't find rpm library. Please install rpm-devel.])]) +RPM_LIBS="" +AC_ARG_WITH(rpm, [ --with-rpm= Use rpm from here]) + +AS_IF([test "$with_rpm" != no], + [if test "$with_rpm" != yes; then + CPPFLAGS="$CPPFLAGS -I$with_rpm/include" + LDFLAGS="$LDFLAGS -L$with_rpm/lib" + fi + AC_CHECK_HEADERS(rpm/rpmlib.h, [], + [AC_MSG_ERROR([Can't find rpm/rpmlib.h. Please install rpm-devel or use --without-rpm.])]) + AC_CHECK_LIB(rpm,rpmdbOpen,[RPM_LIBS="-lrpm"], + [AC_MSG_ERROR([Can't find rpm library. Please install rpm-devel or use --without-rpm.])]) + AC_DEFINE([HAVE_RPMLIB], [1], [Define if you have librpm])]) AC_SUBST(RPM_LIBS) +AM_CONDITIONAL([HAVE_RPMLIB], [test -n "$RPM_LIBS"]) if test "x$GCC" = "xyes"; then LDFLAGS="-Wl,--as-needed $LDFLAGS" diff --git a/src/Makefile.am b/src/Makefile.am index 0a932a1..19dab3f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,7 +17,10 @@ bin_PROGRAMS = razor noinst_PROGRAMS = rpm check_PROGRAMS = test-driver -razor_SOURCES = main.c import-rpmdb.c import-yum.c +razor_SOURCES = main.c import-yum.c +if HAVE_RPMLIB +razor_SOURCES += import-rpmdb.c +endif razor_LDADD = $(RPM_LIBS) $(EXPAT_LIBS) $(CURL_LIBS) $(top_builddir)/librazor/librazor.la rpm_SOURCES = rpm.c diff --git a/src/main.c b/src/main.c index 71cb24e..9ee2023 100644 --- a/src/main.c +++ b/src/main.c @@ -431,6 +431,7 @@ command_import_yum(int argc, const char *argv[]) return 0; } +#if HAVE_RPMLIB static int command_import_rpmdb(int argc, const char *argv[]) { @@ -449,6 +450,7 @@ command_import_rpmdb(int argc, const char *argv[]) return razor_root_commit(root); } +#endif static int mark_packages_for_update(struct razor_transaction *trans, @@ -1001,7 +1003,9 @@ static struct { { "what-requires", "list the packages that have the given requires", command_what_requires }, { "what-provides", "list the packages that have the given provides", command_what_provides }, { "import-yum", "import yum metadata files", command_import_yum }, +#if HAVE_RPMLIB { "import-rpmdb", "import the system rpm database", command_import_rpmdb }, +#endif { "import-rpms", "import rpms from the given directory", command_import_rpms }, { "update", "update all or specified packages", command_update }, { "remove", "remove specified packages", command_remove }, -- 1.7.1