f4e464
From f2fe2c648454bc5885366c93d4075ca5777ddbda Mon Sep 17 00:00:00 2001
f4e464
From: Neal Gompa <ngompa13@gmail.com>
f4e464
Date: Sun, 29 Apr 2018 15:52:26 -0400
f4e464
Subject: [PATCH] Fix TDNF build configuration to use pkgconfig data to find
f4e464
 dependencies
f4e464
f4e464
With the notable exception of identifying that we're using rpm.org rpm,
f4e464
all the configuration of how to use dependencies to compile and link
f4e464
TDNF and its libraries should come from pkgconfig. That way, TDNF
f4e464
will reliably build across more platforms.
f4e464
f4e464
In addition, trivial changes to drop -Werror and specify that -std=gnu99
f4e464
is required for the build are included so that it will compile properly
f4e464
on compilers that do not default to newer C standards and not make
f4e464
assumptions about what is coerced from a warning to an error by default.
f4e464
---
f4e464
 client/Makefile.am  |  5 ++---
f4e464
 configure.ac        | 25 +++++++++++++------------
f4e464
 solv/Makefile.am    |  4 ++--
f4e464
 tdnf-cli-libs.pc.in |  2 +-
f4e464
 tdnf.pc.in          |  2 +-
f4e464
 5 files changed, 19 insertions(+), 19 deletions(-)
f4e464
f4e464
diff --git a/client/Makefile.am b/client/Makefile.am
f4e464
index 9bd3deb..6857c3f 100644
f4e464
--- a/client/Makefile.am
f4e464
+++ b/client/Makefile.am
f4e464
@@ -26,6 +26,5 @@ libtdnf_la_LIBADD =  \
f4e464
     @top_builddir@/solv/libtdnfsolv.la \
f4e464
     $(top_builddir)/common/libcommon.la \
f4e464
     @LIBCURL_LIBS@ \
f4e464
-    -lrpm  \
f4e464
-    -lsolv \
f4e464
-    -lsolvext
f4e464
+    @RPM_LIBS@ \
f4e464
+    @LIBSOLVEXT_LIBS@
f4e464
diff --git a/configure.ac b/configure.ac
f4e464
index d78bb8c..d5c4a51 100644
f4e464
--- a/configure.ac
f4e464
+++ b/configure.ac
f4e464
@@ -2,7 +2,7 @@ AC_INIT(tdnf, 2.0.0)
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 AC_MSG_NOTICE([tdnf configuration])
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 AC_CANONICAL_SYSTEM
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
-AM_INIT_AUTOMAKE([-Wall -Werror foreign])
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
+AM_INIT_AUTOMAKE([-Wall foreign])
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 AC_CONFIG_TESTDIR(tests)
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 
f4e464
@@ -15,29 +15,30 @@ AC_PROG_LIBTOOL
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_GNU_SOURCE -fPIC"
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 AM_CPPFLAGS="$AM_CPPFLAGS -I${top_srcdir}/include"
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
-AM_CFLAGS="$AM_CFLAGS -Wall -Werror -fno-strict-aliasing"
f4e464
+AM_CFLAGS="$AM_CFLAGS -std=gnu99 -Wall -fno-strict-aliasing"
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_GNU_SOURCE -fPIC"
Lucio Andrés Illanes Albornoz (arab, vxp) ced636
 AC_SUBST(AM_CPPFLAGS)
f4e464
 AC_SUBST(AM_CFLAGS)
f4e464
 
f4e464
 #libsolv
f4e464
-echo "Looking for libsolv headers"
f4e464
-AC_CHECK_HEADERS(solv/pool.h)
f4e464
+PKG_CHECK_MODULES([LIBSOLV], [libsolv], [have_libsolv=yes], [have_libsolv=no])
f4e464
+PKG_CHECK_MODULES([LIBSOLVEXT], [libsolvext], [have_libsolvext=yes], [have_libsolvext=no])
f4e464
+AM_CONDITIONAL([LIBSOLV],  [test "$have_libsolv" = "yes"])
f4e464
+AM_CONDITIONAL([LIBSOLVEXT],  [test "$have_libsolvext" = "yes"])
f4e464
 
f4e464
-echo "Looking for libsolv libs"
f4e464
-AC_CHECK_LIB(solv, pool_create)
f4e464
-
f4e464
-#licurl
f4e464
+#libcurl
f4e464
 PKG_CHECK_MODULES([LIBCURL], [libcurl], [have_libcurl=yes], [have_libcurl=no])
f4e464
 AM_CONDITIONAL([LIBCURL],  [test "$have_libcurl" = "yes"])
f4e464
 
f4e464
 #rpm
f4e464
-echo "Looking for librpm headers"
f4e464
-AC_CHECK_HEADERS(rpm/rpmlib.h)
f4e464
+PKG_CHECK_MODULES([RPM], [rpm], [have_rpm=yes], [have_rpm=no])
f4e464
+AM_CONDITIONAL([RPM], [test "$have_rpm" = "yes"])
f4e464
+
f4e464
+# test to prove rpm.org rpm
f4e464
+echo "Looking for rpm.org librpm headers"
f4e464
+AC_CHECK_HEADERS(rpm/header.h)
f4e464
 
f4e464
-echo "Looking for librpm libs"
f4e464
-AC_CHECK_LIB(rpm, rpmtsCreate)
f4e464
 
f4e464
 #makefiles
f4e464
 AC_CONFIG_FILES([Makefile
f4e464
diff --git a/solv/Makefile.am b/solv/Makefile.am
f4e464
index 6625b3b..ef546a9 100644
f4e464
--- a/solv/Makefile.am
f4e464
+++ b/solv/Makefile.am
f4e464
@@ -10,5 +10,5 @@ libtdnfsolv_la_SOURCES = \
f4e464
     
f4e464
 libtdnfsolv_la_LDFLAGS =  \
f4e464
     -static \
f4e464
-    -lrpm  \
f4e464
-    -lsolv
f4e464
+    @RPM_LIBS@ \
f4e464
+    @LIBSOLV_LIBS@
f4e464
diff --git a/tdnf-cli-libs.pc.in b/tdnf-cli-libs.pc.in
f4e464
index 0912b68..4523e4d 100644
f4e464
--- a/tdnf-cli-libs.pc.in
f4e464
+++ b/tdnf-cli-libs.pc.in
f4e464
@@ -6,6 +6,6 @@ includedir=@includedir@/tdnf
f4e464
 Name: tdnf-cli-libs
f4e464
 Description: tdnf cli libs
f4e464
 Version: @VERSION@
f4e464
-Requires:
f4e464
+Requires: tdnf
f4e464
 Libs: -L${libdir} -ltdnfcli
f4e464
 Cflags: -I${includedir}
f4e464
diff --git a/tdnf.pc.in b/tdnf.pc.in
f4e464
index 811568d..4ad7a07 100644
f4e464
--- a/tdnf.pc.in
f4e464
+++ b/tdnf.pc.in
f4e464
@@ -6,6 +6,6 @@ includedir=@includedir@/tdnf
f4e464
 Name: tdnf
f4e464
 Description: tiny dandified yum
f4e464
 Version: @VERSION@
f4e464
-Requires:libsolv rpm
f4e464
+Requires: libsolv libsolvext rpm libcurl
f4e464
 Libs: -L${libdir} -ltdnf
f4e464
 Cflags: -I${includedir}
f4e464
-- 
f4e464
2.17.0
f4e464