Skip to contentSkip to conversation

policycoreutils: restorecond: use pkg-config to find dbus-glib-1 files

PATCH Applied Nicolas Iooss 2 participants 2 messages Oct 30, 2016 – Oct 31, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 policycoreutils: restorecond: use pkg-config to find dbus-glib-1 files

On Ubuntu some header files are located in /usr/lib/x86_64-linux-gnu/, not /usr/lib64/:

    $ pkg-config --cflags dbus-glib-1
    -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include
    -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include

Use pkg-config instead of hard-coded paths to find glib and dbus-glib headers and libraries.

This is needed in order to use environments provided for example by
https://travis-ci.org/.

---
 policycoreutils/restorecond/Makefile | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
policycoreutils/restorecond/Makefile +6 -4
index 253246d7b5ea..93050f00d230 100644
@@ -1,3 +1,5 @@
+PKG_CONFIG ?= pkg-config
+
 # Installation directories.
 PREFIX ?= $(DESTDIR)/usr
 SBINDIR ?= $(PREFIX)/sbin
@@ -11,11 +13,11 @@ autostart_DATA = sealertauto.desktop
 INITDIR ?= $(DESTDIR)/etc/rc.d/init.d
 SELINUXDIR = $(DESTDIR)/etc/selinux
 
-DBUSFLAGS = -DHAVE_DBUS -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/lib/dbus-1.0/include
-DBUSLIB = -ldbus-glib-1 -ldbus-1
+DBUSFLAGS = -DHAVE_DBUS $(shell $(PKG_CONFIG) --cflags dbus-glib-1)
+DBUSLIB = $(shell $(PKG_CONFIG) --libs dbus-glib-1)
 
 CFLAGS ?= -g -Werror -Wall -W
-override CFLAGS += -I$(PREFIX)/include $(DBUSFLAGS) -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib/glib-2.0/include
+override CFLAGS += -I$(PREFIX)/include $(DBUSFLAGS)
 
 USE_PCRE2 ?= n
 ifeq ($(USE_PCRE2),y)
@@ -24,7 +26,7 @@ else
 	PCRE_LDFLAGS := -lpcre
 endif
 
-LDLIBS += -lselinux $(PCRE_LDFLAGS) $(DBUSLIB) -lglib-2.0 -L$(LIBDIR)
+LDLIBS += -lselinux $(PCRE_LDFLAGS) $(DBUSLIB) -L$(LIBDIR)
 
 all: restorecond
 
Signature · 1 line
2.10.1
#1 lore raw
Quoted 7 lines · Nicolas Iooss

On Ubuntu some header files are located in /usr/lib/x86_64-linux-gnu/, not /usr/lib64/:

    $ pkg-config --cflags dbus-glib-1
    -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include
    -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
Quoted 5 lines

Use pkg-config instead of hard-coded paths to find glib and dbus-glib headers and libraries.

This is needed in order to use environments provided for example by
https://travis-ci.org/.

Thanks, applied.

Quoted 41 lines
---
 policycoreutils/restorecond/Makefile | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
policycoreutils/restorecond/Makefile +6 -4
index 253246d7b5ea..93050f00d230 100644
@@ -1,3 +1,5 @@
+PKG_CONFIG ?= pkg-config
+
 # Installation directories.
 PREFIX ?= $(DESTDIR)/usr
 SBINDIR ?= $(PREFIX)/sbin
@@ -11,11 +13,11 @@ autostart_DATA = sealertauto.desktop
 INITDIR ?= $(DESTDIR)/etc/rc.d/init.d
 SELINUXDIR = $(DESTDIR)/etc/selinux
 
-DBUSFLAGS = -DHAVE_DBUS -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/lib/dbus-1.0/include
-DBUSLIB = -ldbus-glib-1 -ldbus-1
+DBUSFLAGS = -DHAVE_DBUS $(shell $(PKG_CONFIG) --cflags dbus-glib-1)
+DBUSLIB = $(shell $(PKG_CONFIG) --libs dbus-glib-1)
 
 CFLAGS ?= -g -Werror -Wall -W
-override CFLAGS += -I$(PREFIX)/include $(DBUSFLAGS) -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib/glib-2.0/include
+override CFLAGS += -I$(PREFIX)/include $(DBUSFLAGS)
 
 USE_PCRE2 ?= n
 ifeq ($(USE_PCRE2),y)
@@ -24,7 +26,7 @@ else
 	PCRE_LDFLAGS := -lpcre
 endif
 
-LDLIBS += -lselinux $(PCRE_LDFLAGS) $(DBUSLIB) -lglib-2.0 -L$(LIBDIR)
+LDLIBS += -lselinux $(PCRE_LDFLAGS) $(DBUSLIB) -L$(LIBDIR)
 
 all: restorecond