libcap-2.24-build-system-fixes.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. From 0485ff3e7f62a331aa4f1e8ec4c2fdcee400e324 Mon Sep 17 00:00:00 2001
  2. From: Mike Frysinger <vapier@gentoo.org>
  3. Date: Sun, 16 Nov 2008 09:10:31 -0500
  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. ---
  15. Make.Rules | 26 ++++++++++++++------------
  16. libcap/Makefile | 11 ++++++-----
  17. pam_cap/Makefile | 8 +++++---
  18. progs/Makefile | 2 +-
  19. 4 files changed, 26 insertions(+), 21 deletions(-)
  20. diff --git a/Make.Rules b/Make.Rules
  21. index 18b7cf7..5364c46 100644
  22. --- a/Make.Rules
  23. +++ b/Make.Rules
  24. @@ -45,27 +45,29 @@ MINOR=24
  25. # Compilation specifics
  26. -KERNEL_HEADERS := $(topdir)/libcap/include/uapi
  27. -IPATH += -fPIC -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include
  28. -
  29. -CC := gcc
  30. -CFLAGS := -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
  31. -BUILD_CC := $(CC)
  32. -BUILD_CFLAGS := $(CFLAGS) $(IPATH)
  33. -AR := ar
  34. -RANLIB := ranlib
  35. +CC ?= gcc
  36. +CFLAGS ?= -O2
  37. +BUILD_CC ?= $(CC)
  38. +BUILD_CFLAGS ?= $(CFLAGS)
  39. +AR ?= ar
  40. +RANLIB ?= ranlib
  41. DEBUG = -g #-DDEBUG
  42. WARNINGS=-Wall -Wwrite-strings \
  43. -Wpointer-arith -Wcast-qual -Wcast-align \
  44. -Wstrict-prototypes -Wmissing-prototypes \
  45. -Wnested-externs -Winline -Wshadow
  46. LD=$(CC) -Wl,-x -shared
  47. -LDFLAGS := #-g
  48. +LDFLAGS ?= #-g
  49. -SYSTEM_HEADERS = /usr/include
  50. +KERNEL_HEADERS = $(topdir)/libcap/include/uapi
  51. +LIBCAP_CPPFLAGS = -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include
  52. +LIBCAP_CPPFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
  53. +CPPFLAGS += $(LIBCAP_CPPFLAGS)
  54. +BUILD_CPPFLAGS += $(LIBCAP_CPPFLAGS)
  55. INCS=$(topdir)/libcap/include/sys/capability.h
  56. LDFLAGS += -L$(topdir)/libcap
  57. -CFLAGS += -Dlinux $(WARNINGS) $(DEBUG)
  58. +CPPFLAGS += -Dlinux
  59. +CFLAGS += $(WARNINGS) $(DEBUG)
  60. PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
  61. INDENT := $(shell if [ -n "$$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
  62. DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi)
  63. diff --git a/libcap/Makefile b/libcap/Makefile
  64. index 0ccd2e7..6b446ea 100644
  65. --- a/libcap/Makefile
  66. +++ b/libcap/Makefile
  67. @@ -16,7 +16,7 @@ FILES=cap_alloc cap_proc cap_extint cap_flag cap_text
  68. # no support).
  69. ifeq ($(LIBATTR),yes)
  70. FILES += cap_file
  71. -LDFLAGS += -lattr
  72. +LDLIBS += -lattr
  73. DEPS = -lattr
  74. endif
  75. @@ -25,6 +25,7 @@ OBJS=$(addsuffix .o, $(FILES))
  76. MAJLIBNAME=$(LIBNAME).$(VERSION)
  77. MINLIBNAME=$(MAJLIBNAME).$(MINOR)
  78. GPERF_OUTPUT = _caps_output.gperf
  79. +CFLAGS += -fPIC
  80. all: $(MINLIBNAME) $(STALIBNAME) libcap.pc
  81. @@ -43,7 +44,7 @@ libcap.pc: libcap.pc.in
  82. $< >$@
  83. _makenames: _makenames.c cap_names.list.h
  84. - $(BUILD_CC) $(BUILD_CFLAGS) $< -o $@
  85. + $(BUILD_CC) $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< -o $@
  86. cap_names.h: _makenames
  87. ./_makenames > cap_names.h
  88. @@ -60,15 +61,15 @@ $(STALIBNAME): $(OBJS)
  89. $(RANLIB) $@
  90. $(MINLIBNAME): $(OBJS)
  91. - $(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^
  92. + $(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^ $(LDLIBS)
  93. ln -sf $(MINLIBNAME) $(MAJLIBNAME)
  94. ln -sf $(MAJLIBNAME) $(LIBNAME)
  95. %.o: %.c $(INCLS)
  96. - $(CC) $(CFLAGS) $(IPATH) -c $< -o $@
  97. + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
  98. cap_text.o: cap_text.c $(USE_GPERF_OUTPUT) $(INCLS)
  99. - $(CC) $(CFLAGS) $(IPATH) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@
  100. + $(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@
  101. install: all
  102. mkdir -p -m 0755 $(FAKEROOT)$(INCDIR)/sys
  103. diff --git a/pam_cap/Makefile b/pam_cap/Makefile
  104. index cc32fb6..6f07b6b 100644
  105. --- a/pam_cap/Makefile
  106. +++ b/pam_cap/Makefile
  107. @@ -9,6 +9,8 @@ include ../Make.Rules
  108. # written (and you know why it fails), email me and explain why. Thanks!
  109. LDLIBS += -L../libcap -lcap
  110. +CFLAGS += -fPIC
  111. +
  112. all: pam_cap.so
  113. $(MAKE) testcompile
  114. @@ -17,13 +19,13 @@ install: all
  115. install -m 0755 pam_cap.so $(FAKEROOT)$(LIBDIR)/security
  116. pam_cap.so: pam_cap.o
  117. - $(LD) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS)
  118. + $(LD) $(CFLAGS) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS)
  119. pam_cap.o: pam_cap.c
  120. - $(CC) $(CFLAGS) $(IPATH) -c $< -o $@
  121. + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
  122. testcompile: test.c pam_cap.o
  123. - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS)
  124. + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS)
  125. clean:
  126. rm -f *.o *.so testcompile *~
  127. diff --git a/progs/Makefile b/progs/Makefile
  128. index 778149e..8f4e2e6 100644
  129. --- a/progs/Makefile
  130. +++ b/progs/Makefile
  131. @@ -22,7 +22,7 @@ $(BUILD): %: %.o
  132. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
  133. %.o: %.c $(INCS)
  134. - $(CC) $(IPATH) $(CFLAGS) -c $< -o $@
  135. + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
  136. install: all
  137. mkdir -p -m 0755 $(FAKEROOT)$(SBINDIR)
  138. --
  139. 2.4.1