build system: use pkg-config to look up selinux libs

Newer versions of libselinux has started linking against more libs.
Rather than continuing hardcoding things, switch to using pkg-config
to query for its dependencies.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
Mike Frysinger 2012-10-20 15:01:26 -04:00
parent 67dc7b21ca
commit 5694afd72a
2 changed files with 12 additions and 1 deletions

View File

@ -297,6 +297,7 @@ NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump OBJDUMP = $(CROSS_COMPILE)objdump
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
AWK = awk AWK = awk
GENKSYMS = scripts/genksyms/genksyms GENKSYMS = scripts/genksyms/genksyms
DEPMOD = /sbin/depmod DEPMOD = /sbin/depmod

View File

@ -78,6 +78,12 @@ ARCH_FPIC ?= -fpic
ARCH_FPIE ?= -fpie ARCH_FPIE ?= -fpie
ARCH_PIE ?= -pie ARCH_PIE ?= -pie
# Usage: $(eval $(call pkg_check_modules,VARIABLE-PREFIX,MODULES))
define pkg_check_modules
$(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2))
$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2))
endef
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y) ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
# on i386: 14% smaller libbusybox.so # on i386: 14% smaller libbusybox.so
# (code itself is 9% bigger, we save on relocs/PLT/GOT) # (code itself is 9% bigger, we save on relocs/PLT/GOT)
@ -89,6 +95,7 @@ endif
ifeq ($(CONFIG_STATIC),y) ifeq ($(CONFIG_STATIC),y)
CFLAGS_busybox += -static CFLAGS_busybox += -static
PKG_CONFIG_FLAGS += --static
endif endif
ifeq ($(CONFIG_PIE),y) ifeq ($(CONFIG_PIE),y)
@ -131,7 +138,10 @@ LDLIBS += pam pam_misc pthread
endif endif
ifeq ($(CONFIG_SELINUX),y) ifeq ($(CONFIG_SELINUX),y)
LDLIBS += selinux sepol SELINUX_PC_MODULES = libselinux libsepol
$(eval $(call pkg_check_modules,SELINUX,$(SELINUX_PC_MODULES)))
CPPFLAGS += $(SELINUX_CFLAGS)
LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%))
endif endif
ifeq ($(CONFIG_EFENCE),y) ifeq ($(CONFIG_EFENCE),y)