libcap-2.25-build-system-fixes.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. From d5a0c023a7f3deefd471d7b97ef4fa40ed374645 Mon Sep 17 00:00:00 2001
  2. From: Mike Frysinger <vapier@gentoo.org>
  3. Date: Wed, 10 Feb 2016 09:47:27 +0100
  4. Subject: [PATCH] build system fixes
  5. This touches up the homebrewed build system to work much better "out of the
  6. box" for people. Specifically:
  7. - allow toolchain vars to be set via environment
  8. - CC / BUILD_CC / AR / RANLIB
  9. - CFLAGS / CPPFLAGS / LDFLAGS
  10. - split CPPFLAGS out of CFLAGS
  11. - break -fPIC out of global CFLAGS and only use where needed
  12. - use LDLIBS for libraries, not LDFLAGS
  13. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
  14. Forward ported from libcap-2.24 to libcap-2.25
  15. Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
  16. ---
  17. Make.Rules | 26 ++++++++++++++------------
  18. libcap/Makefile | 7 ++++---
  19. pam_cap/Makefile | 8 +++++---
  20. progs/Makefile | 2 +-
  21. 4 files changed, 24 insertions(+), 19 deletions(-)
  22. diff --git a/Make.Rules b/Make.Rules
  23. index 8347b26..d7196ef 100644
  24. --- a/Make.Rules
  25. +++ b/Make.Rules
  26. @@ -45,28 +45,30 @@ MINOR=25
  27. # Compilation specifics
  28. -KERNEL_HEADERS := $(topdir)/libcap/include/uapi
  29. -IPATH += -fPIC -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include
  30. -
  31. -CC := gcc
  32. -CFLAGS := -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
  33. -BUILD_CC := $(CC)
  34. -BUILD_CFLAGS := $(CFLAGS) $(IPATH)
  35. -AR := ar
  36. -RANLIB := ranlib
  37. +CC ?= gcc
  38. +CFLAGS ?= -O2
  39. +BUILD_CC ?= $(CC)
  40. +BUILD_CFLAGS ?= $(CFLAGS)
  41. +AR ?= ar
  42. +RANLIB ?= ranlib
  43. DEBUG = -g #-DDEBUG
  44. WARNINGS=-Wall -Wwrite-strings \
  45. -Wpointer-arith -Wcast-qual -Wcast-align \
  46. -Wstrict-prototypes -Wmissing-prototypes \
  47. -Wnested-externs -Winline -Wshadow
  48. LD=$(CC) -Wl,-x -shared
  49. -LDFLAGS := #-g
  50. +LDFLAGS ?= #-g
  51. BUILD_GPERF := $(shell which gperf >/dev/null 2>/dev/null && echo yes)
  52. -SYSTEM_HEADERS = /usr/include
  53. +KERNEL_HEADERS = $(topdir)/libcap/include/uapi
  54. +LIBCAP_CPPFLAGS = -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include
  55. +LIBCAP_CPPFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
  56. +CPPFLAGS += $(LIBCAP_CPPFLAGS)
  57. +BUILD_CPPFLAGS += $(LIBCAP_CPPFLAGS)
  58. INCS=$(topdir)/libcap/include/sys/capability.h
  59. LDFLAGS += -L$(topdir)/libcap
  60. -CFLAGS += -Dlinux $(WARNINGS) $(DEBUG)
  61. +CPPFLAGS += -Dlinux
  62. +CFLAGS += $(WARNINGS) $(DEBUG)
  63. PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
  64. INDENT := $(shell if [ -n "$$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
  65. DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi)
  66. diff --git a/libcap/Makefile b/libcap/Makefile
  67. index d189777..b99740f 100644
  68. --- a/libcap/Makefile
  69. +++ b/libcap/Makefile
  70. @@ -17,6 +17,7 @@ OBJS=$(addsuffix .o, $(FILES))
  71. MAJLIBNAME=$(LIBNAME).$(VERSION)
  72. MINLIBNAME=$(MAJLIBNAME).$(MINOR)
  73. GPERF_OUTPUT = _caps_output.gperf
  74. +CFLAGS += -fPIC
  75. all: $(MINLIBNAME) $(STALIBNAME) libcap.pc
  76. @@ -35,7 +36,7 @@ libcap.pc: libcap.pc.in
  77. $< >$@
  78. _makenames: _makenames.c cap_names.list.h
  79. - $(BUILD_CC) $(BUILD_CFLAGS) $< -o $@
  80. + $(BUILD_CC) $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< -o $@
  81. cap_names.h: _makenames
  82. ./_makenames > cap_names.h
  83. @@ -57,10 +58,10 @@ $(MINLIBNAME): $(OBJS)
  84. ln -sf $(MAJLIBNAME) $(LIBNAME)
  85. %.o: %.c $(INCLS)
  86. - $(CC) $(CFLAGS) $(IPATH) -c $< -o $@
  87. + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
  88. cap_text.o: cap_text.c $(USE_GPERF_OUTPUT) $(INCLS)
  89. - $(CC) $(CFLAGS) $(IPATH) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@
  90. + $(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@
  91. install: all
  92. mkdir -p -m 0755 $(FAKEROOT)$(INCDIR)/sys
  93. diff --git a/pam_cap/Makefile b/pam_cap/Makefile
  94. index cc32fb6..6f07b6b 100644
  95. --- a/pam_cap/Makefile
  96. +++ b/pam_cap/Makefile
  97. @@ -9,6 +9,8 @@ include ../Make.Rules
  98. # written (and you know why it fails), email me and explain why. Thanks!
  99. LDLIBS += -L../libcap -lcap
  100. +CFLAGS += -fPIC
  101. +
  102. all: pam_cap.so
  103. $(MAKE) testcompile
  104. @@ -17,13 +19,13 @@ install: all
  105. install -m 0755 pam_cap.so $(FAKEROOT)$(LIBDIR)/security
  106. pam_cap.so: pam_cap.o
  107. - $(LD) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS)
  108. + $(LD) $(CFLAGS) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS)
  109. pam_cap.o: pam_cap.c
  110. - $(CC) $(CFLAGS) $(IPATH) -c $< -o $@
  111. + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
  112. testcompile: test.c pam_cap.o
  113. - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS)
  114. + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS)
  115. clean:
  116. rm -f *.o *.so testcompile *~
  117. diff --git a/progs/Makefile b/progs/Makefile
  118. index c094a24..b9f0d3f 100644
  119. --- a/progs/Makefile
  120. +++ b/progs/Makefile
  121. @@ -19,7 +19,7 @@ $(BUILD): %: %.o
  122. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
  123. %.o: %.c $(INCS)
  124. - $(CC) $(IPATH) $(CFLAGS) -c $< -o $@
  125. + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
  126. install: all
  127. mkdir -p -m 0755 $(FAKEROOT)$(SBINDIR)
  128. --
  129. 2.7.1