aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2008-06-02 22:02:01 -0700
committerAndrew G. Morgan <morgan@kernel.org>2008-06-02 22:02:01 -0700
commit953e7f1d9cf2a0134c342b7c5dd189e78b69d59e (patch)
tree8e67ac086c12d0aab5d64f57128ffc8219bd2c73
parent8e9b94b41f3f7e90404fe492f7bc7bc438726218 (diff)
downloadlibcap-953e7f1d9cf2a0134c342b7c5dd189e78b69d59e.tar.gz
Some makefile cleanups.
All the good parts of this change are Mike Frysinger's <vapier@gentoo.org> work. Everything that is broken, is due to my mangling of it. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r--Make.Rules30
-rw-r--r--Makefile8
-rw-r--r--libcap/Makefile10
-rw-r--r--pam_cap/Makefile7
-rw-r--r--progs/Makefile5
5 files changed, 30 insertions, 30 deletions
diff --git a/Make.Rules b/Make.Rules
index ca2da0d..6a469bd 100644
--- a/Make.Rules
+++ b/Make.Rules
@@ -42,34 +42,28 @@ MINOR=10
# Compilation specifics
-CC ?= gcc
-AR ?= ar
-RANLIB ?= ranlib
-COPTFLAGS=-O2
-DEBUG=-g #-DDEBUG
+CC := gcc
+CFLAGS := -O2
+BUILD_CC := $(CC)
+BUILD_CFLAGS := $(CFLAGS)
+AR := ar
+RANLIB := ranlib
+DEBUG = -g #-DDEBUG
WARNINGS=-fPIC -Wall -Wwrite-strings \
-Wpointer-arith -Wcast-qual -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes \
-Wnested-externs -Winline -Wshadow
LD=$(CC) -Wl,-x -shared
-LDFLAGS=#-g
+LDFLAGS := #-g
-KERNEL_HEADERS = $(topdir)/libcap/include
+KERNEL_HEADERS := $(topdir)/libcap/include
SYSTEM_HEADERS = /usr/include
IPATH += -I$(topdir)/libcap/include -I$(KERNEL_HEADERS)
INCS=$(topdir)/libcap/include/sys/capability.h
-LIBS=-L$(topdir)/libcap -lcap
-CFLAGS=-Dlinux $(WARNINGS) $(DEBUG) $(COPTFLAG) $(IPATH)
-PAM_CAP ?= $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
+LDFLAGS += -L$(topdir)/libcap
+CFLAGS += -Dlinux $(WARNINGS) $(DEBUG) $(IPATH)
+PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
# Global cleanup stuff
LOCALCLEAN=rm -f *~ core
DISTCLEAN=@find . \( -name '*.orig' -o -name '*.rej' \) | xargs rm -f
-
-# Flags to pass down recursive makes
-
-MAKE_DEFS = CC='$(CC)' CFLAGS='$(CFLAGS)' \
- LD='$(LD)' LIBS='$(LIBS)' LDFLAGS='$(LDFLAGS)' \
- VERSION='$(VERSION)' MINOR='$(MINOR)' \
- LIBDIR='$(LIBDIR)' INCDIR='$(INCDIR)' \
- SBINDIR='$(SBINDIR)' MANDIR='$(MANDIR)'
diff --git a/Makefile b/Makefile
index 52f7b42..9076724 100644
--- a/Makefile
+++ b/Makefile
@@ -9,12 +9,12 @@ include Make.Rules
#
all install clean: %: %-here
- $(MAKE) -C libcap $(MAKE_DEFS) $@
+ $(MAKE) -C libcap $@
ifneq ($(PAM_CAP),no)
- $(MAKE) -C pam_cap $(MAKE_DEFS) $@
+ $(MAKE) -C pam_cap $@
endif
- $(MAKE) -C progs $(MAKE_DEFS) $@
- $(MAKE) -C doc $(MAKE_DEFS) $@
+ $(MAKE) -C progs $@
+ $(MAKE) -C doc $@
all-here:
diff --git a/libcap/Makefile b/libcap/Makefile
index 871f727..da22bd1 100644
--- a/libcap/Makefile
+++ b/libcap/Makefile
@@ -17,7 +17,7 @@ OBJS=$(addsuffix .o, $(FILES))
MAJLIBNAME=$(LIBNAME).$(VERSION)
MINLIBNAME=$(MAJLIBNAME).$(MINOR)
GPERF_OUTPUT = _caps_output.gperf
-LDFLAGS+=-lattr
+LDFLAGS += -lattr
all: $(MINLIBNAME) $(STALIBNAME)
@@ -27,7 +27,7 @@ INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT)
endif
_makenames: _makenames.c cap_names.sed
- $(CC) $(CFLAGS) $< -o $@
+ $(BUILD_CC) $(BUILD_CFLAGS) $< -o $@
cap_names.h: _makenames
./_makenames > cap_names.h
@@ -40,11 +40,11 @@ cap_names.sed: Makefile $(KERNEL_HEADERS)/linux/capability.h
@sed -ne '/^#define[ \t]CAP[_A-Z]\+[ \t]\+[0-9]\+/{s/^#define \([^ \t]*\)[ \t]*\([^ \t]*\)/\{\"\1\",\2\},/;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;p;}' < $(KERNEL_HEADERS)/linux/capability.h | fgrep -v 0x > $@
$(STALIBNAME): $(OBJS)
- $(AR) rcs $(STALIBNAME) $(OBJS)
- $(RANLIB) $(STALIBNAME)
+ $(AR) rcs $@ $^
+ $(RANLIB) $@
$(MINLIBNAME): $(OBJS)
- $(LD) $(LDFLAGS) $(COPTFLAG) -Wl,-soname,$(MAJLIBNAME) -o $@ $(OBJS)
+ $(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^
ln -sf $(MINLIBNAME) $(MAJLIBNAME)
ln -sf $(MAJLIBNAME) $(LIBNAME)
diff --git a/pam_cap/Makefile b/pam_cap/Makefile
index 8819af2..6483790 100644
--- a/pam_cap/Makefile
+++ b/pam_cap/Makefile
@@ -3,6 +3,9 @@
topdir=$(shell pwd)/..
include ../Make.Rules
+LDLIBS += -lcap
+CFLAGS += -fPIC
+
all: pam_cap.so
$(MAKE) testcompile
@@ -11,13 +14,13 @@ install: all
install -m 0755 pam_cap.so $(LIBDIR)/security
pam_cap.so: pam_cap.o
- $(LD) -o pam_cap.so $< $(LIBS)
+ $(LD) $(CFLAGS) -o pam_cap.so $< $(LDLIBS)
pam_cap.o: pam_cap.c
$(CC) $(CFLAGS) -c $< -o $@
testcompile: test.c pam_cap.o
- $(CC) $(CFLAGS) -o $@ $+ -lpam -ldl $(LIBS)
+ $(CC) $(CFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS)
clean:
rm -f *.o *.so testcompile *~
diff --git a/progs/Makefile b/progs/Makefile
index ee03efa..a8e0e53 100644
--- a/progs/Makefile
+++ b/progs/Makefile
@@ -6,10 +6,13 @@ include $(topdir)/Make.Rules
#
PROGS=getpcaps getcap setcap capsh
+LDFLAGS += --static
+LDLIBS += -lcap
+
all: $(PROGS)
$(PROGS): %: %.o
- $(CC) --static $(COPTFLAG) $(LDFLAGS) -o $@ $< $(LIBS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
%.o: %.c $(INCS)
$(CC) $(CFLAGS) -c $< -o $@