Magellan Linux

Contents of /trunk/libcap/patches/libcap-2.20-build-system-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1332 - (show annotations) (download)
Sun May 29 20:02:41 2011 UTC (13 years, 5 months ago) by niro
File size: 4832 byte(s)
added 2.20 fixes
1 From 5540f3c2a3bd70ebc8140b74ac5a0aecdbc53234 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
6 This touches up the homebrewed build system to work much better "out of the
7 box" for people. Specifically:
8 - allow toolchain vars to be set via environment
9 - CC / BUILD_CC / AR / RANLIB
10 - CFLAGS / CPPFLAGS / LDFLAGS
11 - split CPPFLAGS out of CFLAGS
12 - break -fPIC out of global CFLAGS and only use where needed
13 - use LDLIBS for libraries, not LDFLAGS
14
15 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
16 ---
17 Make.Rules | 25 +++++++++++++------------
18 libcap/Makefile | 11 ++++++-----
19 pam_cap/Makefile | 8 +++++---
20 progs/Makefile | 2 +-
21 4 files changed, 25 insertions(+), 21 deletions(-)
22
23 diff --git a/Make.Rules b/Make.Rules
24 index 011aa14..6e432a6 100644
25 --- a/Make.Rules
26 +++ b/Make.Rules
27 @@ -44,27 +44,28 @@ MINOR=19
28
29 # Compilation specifics
30
31 -KERNEL_HEADERS := $(topdir)/libcap/include
32 -IPATH += -fPIC -I$(topdir)/libcap/include -I$(KERNEL_HEADERS)
33 -
34 -CC := gcc
35 -CFLAGS := -O2
36 -BUILD_CC := $(CC)
37 -BUILD_CFLAGS := $(CFLAGS) $(IPATH)
38 -AR := ar
39 -RANLIB := ranlib
40 +CC ?= gcc
41 +CFLAGS ?= -O2
42 +BUILD_CC ?= $(CC)
43 +BUILD_CFLAGS ?= $(CFLAGS)
44 +AR ?= ar
45 +RANLIB ?= ranlib
46 DEBUG = -g #-DDEBUG
47 WARNINGS=-Wall -Wwrite-strings \
48 -Wpointer-arith -Wcast-qual -Wcast-align \
49 -Wstrict-prototypes -Wmissing-prototypes \
50 -Wnested-externs -Winline -Wshadow
51 LD=$(CC) -Wl,-x -shared
52 -LDFLAGS := #-g
53 +LDFLAGS ?= #-g
54
55 -SYSTEM_HEADERS = /usr/include
56 +KERNEL_HEADERS = $(topdir)/libcap/include
57 +LIBCAP_CPPFLAGS = -I$(topdir)/libcap/include -I$(KERNEL_HEADERS)
58 +CPPFLAGS += $(LIBCAP_CPPFLAGS)
59 +BUILD_CPPFLAGS += $(LIBCAP_CPPFLAGS)
60 INCS=$(topdir)/libcap/include/sys/capability.h
61 LDFLAGS += -L$(topdir)/libcap
62 -CFLAGS += -Dlinux $(WARNINGS) $(DEBUG)
63 +CPPFLAGS += -Dlinux
64 +CFLAGS += $(WARNINGS) $(DEBUG)
65 PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
66 INDENT := $(shell if [ -n "$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
67 DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi)
68 diff --git a/libcap/Makefile b/libcap/Makefile
69 index 4762c60..cf99523 100644
70 --- a/libcap/Makefile
71 +++ b/libcap/Makefile
72 @@ -16,7 +16,7 @@ FILES=cap_alloc cap_proc cap_extint cap_flag cap_text
73 # no support).
74 ifeq ($(LIBATTR),yes)
75 FILES += cap_file
76 -LDFLAGS += -lattr
77 +LDLIBS += -lattr
78 endif
79
80 INCLS=libcap.h cap_names.h $(INCS)
81 @@ -24,6 +24,7 @@ OBJS=$(addsuffix .o, $(FILES))
82 MAJLIBNAME=$(LIBNAME).$(VERSION)
83 MINLIBNAME=$(MAJLIBNAME).$(MINOR)
84 GPERF_OUTPUT = _caps_output.gperf
85 +CFLAGS += -fPIC
86
87 all: $(MINLIBNAME) $(STALIBNAME)
88
89 @@ -33,7 +34,7 @@ INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT)
90 endif
91
92 _makenames: _makenames.c cap_names.list.h
93 - $(BUILD_CC) $(BUILD_CFLAGS) $< -o $@
94 + $(BUILD_CC) $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< -o $@
95
96 cap_names.h: _makenames
97 ./_makenames > cap_names.h
98 @@ -50,15 +51,15 @@ $(STALIBNAME): $(OBJS)
99 $(RANLIB) $@
100
101 $(MINLIBNAME): $(OBJS)
102 - $(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^
103 + $(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^ $(LDLIBS)
104 ln -sf $(MINLIBNAME) $(MAJLIBNAME)
105 ln -sf $(MAJLIBNAME) $(LIBNAME)
106
107 %.o: %.c $(INCLS)
108 - $(CC) $(CFLAGS) $(IPATH) -c $< -o $@
109 + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
110
111 cap_text.o: cap_text.c $(USE_GPERF_OUTPUT) $(INCLS)
112 - $(CC) $(CFLAGS) $(IPATH) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@
113 + $(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@
114
115 install: all
116 mkdir -p -m 0755 $(INCDIR)/sys
117 diff --git a/pam_cap/Makefile b/pam_cap/Makefile
118 index 9ca5bef..bdae933 100644
119 --- a/pam_cap/Makefile
120 +++ b/pam_cap/Makefile
121 @@ -9,6 +9,8 @@ include ../Make.Rules
122 # written (and you know why it fails), email me and explain why. Thanks!
123 LDLIBS += -L../libcap -lcap
124
125 +CFLAGS += -fPIC
126 +
127 all: pam_cap.so
128 $(MAKE) testcompile
129
130 @@ -17,13 +19,13 @@ install: all
131 install -m 0755 pam_cap.so $(LIBDIR)/security
132
133 pam_cap.so: pam_cap.o
134 - $(LD) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS)
135 + $(LD) $(CFLAGS) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS)
136
137 pam_cap.o: pam_cap.c
138 - $(CC) $(CFLAGS) $(IPATH) -c $< -o $@
139 + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
140
141 testcompile: test.c pam_cap.o
142 - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS)
143 + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS)
144
145 clean:
146 rm -f *.o *.so testcompile *~
147 diff --git a/progs/Makefile b/progs/Makefile
148 index ef51dc6..c261f57 100644
149 --- a/progs/Makefile
150 +++ b/progs/Makefile
151 @@ -22,7 +22,7 @@ $(BUILD): %: %.o
152 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
153
154 %.o: %.c $(INCS)
155 - $(CC) $(IPATH) $(CFLAGS) -c $< -o $@
156 + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
157
158 install: all
159 mkdir -p -m 0755 $(SBINDIR)
160 --
161 1.7.4.rc2
162