1 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
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
15 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
17 Make.Rules | 28 ++++++++++++++--------------
18 libcap/Makefile | 11 ++++++-----
19 pam_cap/Makefile | 6 +++---
21 4 files changed, 24 insertions(+), 23 deletions(-)
23 diff --git a/Make.Rules b/Make.Rules
24 index 6e63a5b..32cb5ea 100644
27 @@ -42,27 +42,27 @@ MINOR=16
29 # Compilation specifics
31 -KERNEL_HEADERS := $(topdir)/libcap/include
32 -IPATH += -I$(topdir)/libcap/include -I$(KERNEL_HEADERS)
37 -BUILD_CFLAGS := $(CFLAGS) $(IPATH)
41 -WARNINGS=-fPIC -Wall -Wwrite-strings \
47 +BUILD_CFLAGS ?= -O2 -pipe
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
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)
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
73 @@ -16,7 +16,7 @@ FILES=cap_alloc cap_proc cap_extint cap_flag cap_text
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
88 all: $(MINLIBNAME) $(STALIBNAME)
90 @@ -33,7 +34,7 @@ INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT)
93 _makenames: _makenames.c cap_names.list.h
94 - $(BUILD_CC) $(BUILD_CFLAGS) $< -o $@
95 + $(BUILD_CC) $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< -o $@
97 cap_names.h: _makenames
98 ./_makenames > cap_names.h
99 @@ -50,15 +51,15 @@ $(STALIBNAME): $(OBJS)
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)
109 - $(CC) $(CFLAGS) -c $< -o $@
110 + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
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 $@
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
125 pam_cap.so: pam_cap.o
126 - $(LD) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS)
127 + $(LD) $(CFLAGS) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS) -lpam
130 - $(CC) $(CFLAGS) -c $< -o $@
131 + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
133 testcompile: test.c pam_cap.o
134 - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS)
135 + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS)
138 rm -f *.o *.so testcompile *~
139 diff --git a/progs/Makefile b/progs/Makefile
140 index a1542dc..612cf86 100644
143 @@ -22,7 +22,7 @@ $(BUILD): %: %.o
144 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
147 - $(CC) $(CFLAGS) -c $< -o $@
148 + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
151 mkdir -p -m 0755 $(SBINDIR)