Make rpmlib an optional dependency
authorJ. Ali Harlow <ali@juiblex.co.uk>
Tue Jan 06 14:06:00 2009 +0000 (2009-01-06)
changeset 32053e1185e2366
parent 319 ed8155380e45
child 321 6f804141872c
Make rpmlib an optional dependency

Use configure --without-rpm to avoid the dependency (default is unchanged).
configure.ac
src/Makefile.am
src/main.c
     1.1 --- a/configure.ac	Mon Jan 05 17:39:05 2009 +0000
     1.2 +++ b/configure.ac	Tue Jan 06 14:06:00 2009 +0000
     1.3 @@ -154,19 +154,21 @@
     1.4  	     [AC_MSG_ERROR([Can't find expat library. Please install expat.])])
     1.5  AC_SUBST(EXPAT_LIBS)
     1.6  
     1.7 -RPM_LIB=""
     1.8 -AC_ARG_WITH(rpm, [  --with-rpm=<dir>      Use rpm from here],
     1.9 -                      [
    1.10 -                      rpm=$withval
    1.11 -                      CPPFLAGS="$CPPFLAGS -I$withval/include"
    1.12 -                      LDFLAGS="$LDFLAGS -L$withval/lib"
    1.13 -                      ]
    1.14 -                      )
    1.15 -AC_CHECK_HEADERS(rpm/rpmlib.h, [], 
    1.16 -		 [AC_MSG_ERROR([Can't find rpm/rpmlib.h. Please install rpm-devel.])])
    1.17 -AC_CHECK_LIB(rpm,rpmdbOpen,[RPM_LIBS="-lrpm"],
    1.18 -	     [AC_MSG_ERROR([Can't find rpm library. Please install rpm-devel.])])
    1.19 +RPM_LIBS=""
    1.20 +AC_ARG_WITH(rpm, [  --with-rpm=<dir>      Use rpm from here])
    1.21 +
    1.22 +AS_IF([test "$with_rpm" != no],
    1.23 +      [if test "$with_rpm" != yes; then
    1.24 +	    CPPFLAGS="$CPPFLAGS -I$with_rpm/include"
    1.25 +            LDFLAGS="$LDFLAGS -L$with_rpm/lib"
    1.26 +       fi
    1.27 +       AC_CHECK_HEADERS(rpm/rpmlib.h, [], 
    1.28 +		 [AC_MSG_ERROR([Can't find rpm/rpmlib.h. Please install rpm-devel or use --without-rpm.])])
    1.29 +       AC_CHECK_LIB(rpm,rpmdbOpen,[RPM_LIBS="-lrpm"],
    1.30 +	     [AC_MSG_ERROR([Can't find rpm library. Please install rpm-devel or use --without-rpm.])])
    1.31 +       AC_DEFINE([HAVE_RPMLIB], [1], [Define if you have librpm])])
    1.32  AC_SUBST(RPM_LIBS)
    1.33 +AM_CONDITIONAL([HAVE_RPMLIB], [test -n "$RPM_LIBS"])
    1.34  
    1.35  if test "x$GCC" = "xyes"; then
    1.36    LDFLAGS="-Wl,--as-needed $LDFLAGS"
     2.1 --- a/src/Makefile.am	Mon Jan 05 17:39:05 2009 +0000
     2.2 +++ b/src/Makefile.am	Tue Jan 06 14:06:00 2009 +0000
     2.3 @@ -17,7 +17,10 @@
     2.4  noinst_PROGRAMS = rpm
     2.5  check_PROGRAMS = test-driver
     2.6  
     2.7 -razor_SOURCES = main.c import-rpmdb.c import-yum.c
     2.8 +razor_SOURCES = main.c import-yum.c
     2.9 +if HAVE_RPMLIB
    2.10 +razor_SOURCES += import-rpmdb.c
    2.11 +endif
    2.12  razor_LDADD = $(RPM_LIBS) $(EXPAT_LIBS) $(CURL_LIBS) $(top_builddir)/librazor/librazor.la
    2.13  
    2.14  rpm_SOURCES = rpm.c
     3.1 --- a/src/main.c	Mon Jan 05 17:39:05 2009 +0000
     3.2 +++ b/src/main.c	Tue Jan 06 14:06:00 2009 +0000
     3.3 @@ -431,6 +431,7 @@
     3.4  	return 0;
     3.5  }
     3.6  
     3.7 +#if HAVE_RPMLIB
     3.8  static int
     3.9  command_import_rpmdb(int argc, const char *argv[])
    3.10  {
    3.11 @@ -449,6 +450,7 @@
    3.12  
    3.13  	return razor_root_commit(root);
    3.14  }
    3.15 +#endif
    3.16  
    3.17  static int
    3.18  mark_packages_for_update(struct razor_transaction *trans,
    3.19 @@ -1001,7 +1003,9 @@
    3.20  	{ "what-requires", "list the packages that have the given requires", command_what_requires },
    3.21  	{ "what-provides", "list the packages that have the given provides", command_what_provides },
    3.22  	{ "import-yum", "import yum metadata files", command_import_yum },
    3.23 +#if HAVE_RPMLIB
    3.24  	{ "import-rpmdb", "import the system rpm database", command_import_rpmdb },
    3.25 +#endif
    3.26  	{ "import-rpms", "import rpms from the given directory", command_import_rpms },
    3.27  	{ "update", "update all or specified packages", command_update },
    3.28  	{ "remove", "remove specified packages", command_remove },