busybox-1.20.2-pkg-config-selinux.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From b1cec5003b73080a8aa7ea277621bf1c71c3e8d6 Mon Sep 17 00:00:00 2001
  2. From: Mike Frysinger <vapier@gentoo.org>
  3. Date: Sat, 20 Oct 2012 15:01:26 -0400
  4. Subject: [PATCH] build system: use pkg-config to look up selinux libs
  5. Newer versions of libselinux has started linking against more libs.
  6. Rather than continuing hardcoding things, switch to using pkg-config
  7. to query for its dependencies.
  8. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
  9. ---
  10. Makefile | 1 +
  11. Makefile.flags | 12 +++++++++++-
  12. 2 files changed, 12 insertions(+), 1 deletion(-)
  13. diff --git a/Makefile b/Makefile
  14. index fccde4a..3a0a5e1 100644
  15. --- a/Makefile
  16. +++ b/Makefile
  17. @@ -297,6 +297,7 @@ NM = $(CROSS_COMPILE)nm
  18. STRIP = $(CROSS_COMPILE)strip
  19. OBJCOPY = $(CROSS_COMPILE)objcopy
  20. OBJDUMP = $(CROSS_COMPILE)objdump
  21. +PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
  22. AWK = awk
  23. GENKSYMS = scripts/genksyms/genksyms
  24. DEPMOD = /sbin/depmod
  25. diff --git a/Makefile.flags b/Makefile.flags
  26. index c43c8dc..15dcc1f 100644
  27. --- a/Makefile.flags
  28. +++ b/Makefile.flags
  29. @@ -74,6 +74,12 @@ ARCH_FPIC ?= -fpic
  30. ARCH_FPIE ?= -fpie
  31. ARCH_PIE ?= -pie
  32. +# Usage: $(eval $(call pkg_check_modules,VARIABLE-PREFIX,MODULES))
  33. +define pkg_check_modules
  34. +$(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2))
  35. +$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2))
  36. +endef
  37. +
  38. ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
  39. # on i386: 14% smaller libbusybox.so
  40. # (code itself is 9% bigger, we save on relocs/PLT/GOT)
  41. @@ -85,6 +91,7 @@ endif
  42. ifeq ($(CONFIG_STATIC),y)
  43. CFLAGS_busybox += -static
  44. +PKG_CONFIG_FLAGS += --static
  45. endif
  46. ifeq ($(CONFIG_PIE),y)
  47. @@ -127,7 +134,10 @@ LDLIBS += pam pam_misc pthread
  48. endif
  49. ifeq ($(CONFIG_SELINUX),y)
  50. -LDLIBS += selinux sepol
  51. +SELINUX_PC_MODULES = libselinux libsepol
  52. +$(eval $(call pkg_check_modules,SELINUX,$(SELINUX_PC_MODULES)))
  53. +CPPFLAGS += $(SELINUX_CFLAGS)
  54. +LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%))
  55. endif
  56. ifeq ($(CONFIG_EFENCE),y)
  57. --
  58. 1.7.12