Annotation of /trunk/libcap/patches/libcap-2.16-build-system-fixes.patch
Parent Directory | Revision Log
Revision 774 -
(hide annotations)
(download)
Tue Apr 28 16:08:05 2009 UTC (15 years, 5 months ago) by niro
File size: 4626 byte(s)
Tue Apr 28 16:08:05 2009 UTC (15 years, 5 months ago) by niro
File size: 4626 byte(s)
libcap-2.16-r1 fixes
1 | niro | 774 | From 7ee197885e113878aedab58bdda80302e42aff4c 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 | 28 ++++++++++++++-------------- | ||
18 | libcap/Makefile | 11 ++++++----- | ||
19 | pam_cap/Makefile | 6 +++--- | ||
20 | progs/Makefile | 2 +- | ||
21 | 4 files changed, 24 insertions(+), 23 deletions(-) | ||
22 | |||
23 | diff --git a/Make.Rules b/Make.Rules | ||
24 | index 6e63a5b..32cb5ea 100644 | ||
25 | --- a/Make.Rules | ||
26 | +++ b/Make.Rules | ||
27 | @@ -42,27 +42,27 @@ MINOR=16 | ||
28 | |||
29 | # Compilation specifics | ||
30 | |||
31 | -KERNEL_HEADERS := $(topdir)/libcap/include | ||
32 | -IPATH += -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 | -DEBUG = -g #-DDEBUG | ||
41 | -WARNINGS=-fPIC -Wall -Wwrite-strings \ | ||
42 | +CC ?= gcc | ||
43 | +BUILD_CC ?= $(CC) | ||
44 | +AR ?= ar | ||
45 | +RANLIB ?= ranlib | ||
46 | +CFLAGS ?= -O2 | ||
47 | +BUILD_CFLAGS ?= $(CFLAGS) | ||
48 | +WARNINGS=-Wall -Wwrite-strings \ | ||
49 | -Wpointer-arith -Wcast-qual -Wcast-align \ | ||
50 | -Wstrict-prototypes -Wmissing-prototypes \ | ||
51 | -Wnested-externs -Winline -Wshadow | ||
52 | LD=$(CC) -Wl,-x -shared | ||
53 | -LDFLAGS := #-g | ||
54 | +LDFLAGS ?= #-g | ||
55 | |||
56 | -SYSTEM_HEADERS = /usr/include | ||
57 | +KERNEL_HEADERS = $(topdir)/libcap/include | ||
58 | +LIBCAP_CPPFLAGS = -I$(topdir)/libcap/include -I$(KERNEL_HEADERS) | ||
59 | +CPPFLAGS += $(LIBCAP_CPPFLAGS) | ||
60 | +BUILD_CPPFLAGS += $(LIBCAP_CPPFLAGS) | ||
61 | INCS=$(topdir)/libcap/include/sys/capability.h | ||
62 | LDFLAGS += -L$(topdir)/libcap | ||
63 | -CFLAGS += -Dlinux $(WARNINGS) $(DEBUG) $(IPATH) | ||
64 | +CPPFLAGS += -Dlinux | ||
65 | +CFLAGS += $(WARNINGS) | ||
66 | PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi) | ||
67 | INDENT := $(shell if [ -n "$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi) | ||
68 | DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi) | ||
69 | diff --git a/libcap/Makefile b/libcap/Makefile | ||
70 | index 8a61752..cf99523 100644 | ||
71 | --- a/libcap/Makefile | ||
72 | +++ b/libcap/Makefile | ||
73 | @@ -16,7 +16,7 @@ FILES=cap_alloc cap_proc cap_extint cap_flag cap_text | ||
74 | # no support). | ||
75 | ifeq ($(LIBATTR),yes) | ||
76 | FILES += cap_file | ||
77 | -LDFLAGS += -lattr | ||
78 | +LDLIBS += -lattr | ||
79 | endif | ||
80 | |||
81 | INCLS=libcap.h cap_names.h $(INCS) | ||
82 | @@ -24,6 +24,7 @@ OBJS=$(addsuffix .o, $(FILES)) | ||
83 | MAJLIBNAME=$(LIBNAME).$(VERSION) | ||
84 | MINLIBNAME=$(MAJLIBNAME).$(MINOR) | ||
85 | GPERF_OUTPUT = _caps_output.gperf | ||
86 | +CFLAGS += -fPIC | ||
87 | |||
88 | all: $(MINLIBNAME) $(STALIBNAME) | ||
89 | |||
90 | @@ -33,7 +34,7 @@ INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT) | ||
91 | endif | ||
92 | |||
93 | _makenames: _makenames.c cap_names.list.h | ||
94 | - $(BUILD_CC) $(BUILD_CFLAGS) $< -o $@ | ||
95 | + $(BUILD_CC) $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< -o $@ | ||
96 | |||
97 | cap_names.h: _makenames | ||
98 | ./_makenames > cap_names.h | ||
99 | @@ -50,15 +51,15 @@ $(STALIBNAME): $(OBJS) | ||
100 | $(RANLIB) $@ | ||
101 | |||
102 | $(MINLIBNAME): $(OBJS) | ||
103 | - $(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^ | ||
104 | + $(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^ $(LDLIBS) | ||
105 | ln -sf $(MINLIBNAME) $(MAJLIBNAME) | ||
106 | ln -sf $(MAJLIBNAME) $(LIBNAME) | ||
107 | |||
108 | %.o: %.c $(INCLS) | ||
109 | - $(CC) $(CFLAGS) -c $< -o $@ | ||
110 | + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ | ||
111 | |||
112 | cap_text.o: cap_text.c $(USE_GPERF_OUTPUT) $(INCLS) | ||
113 | - $(CC) $(CFLAGS) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@ | ||
114 | + $(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@ | ||
115 | |||
116 | install: all | ||
117 | mkdir -p -m 0755 $(INCDIR)/sys | ||
118 | diff --git a/pam_cap/Makefile b/pam_cap/Makefile | ||
119 | index eae88ed..bef59d2 100644 | ||
120 | --- a/pam_cap/Makefile | ||
121 | +++ b/pam_cap/Makefile | ||
122 | @@ -14,13 +14,13 @@ install: all | ||
123 | install -m 0755 pam_cap.so $(LIBDIR)/security | ||
124 | |||
125 | pam_cap.so: pam_cap.o | ||
126 | - $(LD) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS) | ||
127 | + $(LD) $(CFLAGS) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS) | ||
128 | |||
129 | pam_cap.o: pam_cap.c | ||
130 | - $(CC) $(CFLAGS) -c $< -o $@ | ||
131 | + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ | ||
132 | |||
133 | testcompile: test.c pam_cap.o | ||
134 | - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS) | ||
135 | + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS) | ||
136 | |||
137 | clean: | ||
138 | rm -f *.o *.so testcompile *~ | ||
139 | diff --git a/progs/Makefile b/progs/Makefile | ||
140 | index a1542dc..612cf86 100644 | ||
141 | --- a/progs/Makefile | ||
142 | +++ b/progs/Makefile | ||
143 | @@ -22,7 +22,7 @@ $(BUILD): %: %.o | ||
144 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS) | ||
145 | |||
146 | %.o: %.c $(INCS) | ||
147 | - $(CC) $(CFLAGS) -c $< -o $@ | ||
148 | + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ | ||
149 | |||
150 | install: all | ||
151 | mkdir -p -m 0755 $(SBINDIR) | ||
152 | -- | ||
153 | 1.6.0.4 | ||
154 |