Make rpmlib an optional dependency
authorJ. Ali Harlow <ali@juiblex.co.uk>
Tue, 6 Jan 2009 14:06:00 +0000 (14:06 +0000)
committerJ. Ali Harlow <ali@juiblex.co.uk>
Tue, 6 Jan 2009 14:06:00 +0000 (14:06 +0000)
Use configure --without-rpm to avoid the dependency (default is unchanged).

configure.ac
src/Makefile.am
src/main.c

index 81192e6..dd40a0b 100644 (file)
@@ -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=<dir>      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=<dir>      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"
index 0a932a1..19dab3f 100644 (file)
@@ -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
index 71cb24e..9ee2023 100644 (file)
@@ -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 },