Blame 0049-Use-pkg-config-for-libkmod-CFLAGS-and-LIBS.patch

Harald Hoyer b38677
From 607fec3e7965e3d38d764008e2b0c29757d90777 Mon Sep 17 00:00:00 2001
Harald Hoyer b38677
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer b38677
Date: Wed, 13 Apr 2016 11:13:32 +0200
Harald Hoyer b38677
Subject: [PATCH] Use pkg-config for libkmod CFLAGS and LIBS
Harald Hoyer b38677
Harald Hoyer b38677
---
Harald Hoyer b38677
 Makefile    | 4 ++--
Harald Hoyer b38677
 configure   | 7 +++++++
Harald Hoyer b38677
 dracut.spec | 9 ++++++---
Harald Hoyer b38677
 3 files changed, 15 insertions(+), 5 deletions(-)
Harald Hoyer b38677
Harald Hoyer b38677
diff --git a/Makefile b/Makefile
Harald Hoyer b38677
index 0a1ae6c..d28e4cf 100644
Harald Hoyer b38677
--- a/Makefile
Harald Hoyer b38677
+++ b/Makefile
Harald Hoyer b38677
@@ -12,7 +12,7 @@ pkglibdir ?= ${libdir}/dracut
Harald Hoyer b38677
 sysconfdir ?= ${prefix}/etc
Harald Hoyer b38677
 bindir ?= ${prefix}/bin
Harald Hoyer b38677
 mandir ?= ${prefix}/share/man
Harald Hoyer b38677
-CFLAGS ?= -O2 -g -Wall
Harald Hoyer b38677
+CFLAGS ?= -O2 -g -Wall $(KMOD_CFLAGS)
Harald Hoyer b38677
 CFLAGS += -std=gnu99 -D_FILE_OFFSET_BITS=64 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
Harald Hoyer b38677
 bashcompletiondir ?= ${datadir}/bash-completion/completions
Harald Hoyer b38677
 pkgconfigdatadir ?= $(datadir)/pkgconfig
Harald Hoyer b38677
@@ -61,7 +61,7 @@ install/util.o: install/util.c install/util.h install/macro.h install/log.h
Harald Hoyer b38677
 install/strv.o: install/strv.c install/strv.h install/util.h install/macro.h install/log.h
Harald Hoyer b38677
 
Harald Hoyer b38677
 install/dracut-install: $(DRACUT_INSTALL_OBJECTS)
Harald Hoyer b38677
-	$(CC) $(LDFLAGS) -o $@ $(DRACUT_INSTALL_OBJECTS) $(LDLIBS) -lkmod
Harald Hoyer b38677
+	$(CC) $(LDFLAGS) -o $@ $(DRACUT_INSTALL_OBJECTS) $(LDLIBS) $(KMOD_LIBS)
Harald Hoyer b38677
 
Harald Hoyer b38677
 dracut-install: install/dracut-install
Harald Hoyer b38677
 	ln -fs $< $@
Harald Hoyer b38677
diff --git a/configure b/configure
Harald Hoyer b38677
index 0bd3d2d..c92cb99 100755
Harald Hoyer b38677
--- a/configure
Harald Hoyer b38677
+++ b/configure
Harald Hoyer b38677
@@ -50,6 +50,11 @@ while (($# > 0)); do
Harald Hoyer b38677
     shift
Harald Hoyer b38677
 done
Harald Hoyer b38677
 
Harald Hoyer b38677
+if ! pkg-config --exists --print-errors " libkmod >= 15 "; then
Harald Hoyer b38677
+    echo "dracut needs pkg-config and libkmod >= 15." >&2
Harald Hoyer b38677
+    exit 1
Harald Hoyer b38677
+fi
Harald Hoyer b38677
+
Harald Hoyer b38677
 cat > Makefile.inc.$$ <
Harald Hoyer b38677
 prefix ?= ${prefix}
Harald Hoyer b38677
 libdir ?= ${libdir:-${prefix}/lib}
Harald Hoyer b38677
@@ -59,6 +64,8 @@ sbindir ?= ${sbindir:-${prefix}/sbin}
Harald Hoyer b38677
 mandir ?= ${mandir:-${prefix}/share/man}
Harald Hoyer b38677
 enable_documentation ?= ${enable_documentation:-yes}
Harald Hoyer b38677
 bindir ?= ${bindir:-${prefix}/bin}
Harald Hoyer b38677
+KMOD_CFLAGS ?= $(pkg-config --cflags " libkmod >= 15 ")
Harald Hoyer b38677
+KMOD_LIBS ?= $(pkg-config --libs " libkmod >= 15 ")
Harald Hoyer b38677
 EOF
Harald Hoyer b38677
 
Harald Hoyer b38677
 {
Harald Hoyer b38677
diff --git a/dracut.spec b/dracut.spec
Harald Hoyer b38677
index 9e19fcc..7b9d675 100644
Harald Hoyer b38677
--- a/dracut.spec
Harald Hoyer b38677
+++ b/dracut.spec
Harald Hoyer b38677
@@ -39,6 +39,7 @@ Source1: https://www.gnu.org/licenses/lgpl-2.1.txt
Harald Hoyer b38677
 
Harald Hoyer b38677
 
Harald Hoyer b38677
 BuildRequires: bash git
Harald Hoyer b38677
+BuildRequires: kmod-devel >= 15
Harald Hoyer b38677
 
Harald Hoyer b38677
 %if 0%{?fedora} || 0%{?rhel}
Harald Hoyer b38677
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Harald Hoyer b38677
@@ -46,7 +47,6 @@ BuildRequires: pkgconfig
Harald Hoyer b38677
 %endif
Harald Hoyer b38677
 %if 0%{?fedora}
Harald Hoyer b38677
 BuildRequires: bash-completion
Harald Hoyer b38677
-BuildRequires: pkgconfig
Harald Hoyer b38677
 %endif
Harald Hoyer b38677
 
Harald Hoyer b38677
 %if 0%{?suse_version}
Harald Hoyer b38677
@@ -223,10 +223,13 @@ This package contains tools to assemble the local initrd and host configuration.
Harald Hoyer b38677
 cp %{SOURCE1} .
Harald Hoyer b38677
 
Harald Hoyer b38677
 %build
Harald Hoyer b38677
-%configure --systemdsystemunitdir=%{_unitdir} --bashcompletiondir=$(pkg-config --variable=completionsdir bash-completion) --libdir=%{_prefix}/lib \
Harald Hoyer b38677
+%configure  --systemdsystemunitdir=%{_unitdir} \
Harald Hoyer b38677
+            --bashcompletiondir=$(pkg-config --variable=completionsdir bash-completion) \
Harald Hoyer b38677
+            --libdir=%{_prefix}/lib \
Harald Hoyer b38677
 %if %{without doc}
Harald Hoyer b38677
-     --disable-documentation
Harald Hoyer b38677
+            --disable-documentation \
Harald Hoyer b38677
 %endif
Harald Hoyer b38677
+            ${NULL}
Harald Hoyer b38677
 
Harald Hoyer b38677
 make %{?_smp_mflags}
Harald Hoyer b38677