diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2021-08-30 20:01:13 -0700 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2021-08-30 20:02:22 -0700 |
commit | f5ae31ebd3d49a064cb85ccd62a75198883cec3b (patch) | |
tree | 037c0884e7be60392381a6b6e60baf587a84b989 | |
parent | 2bfe36c9999c852c79c0bba1c31b25285326b91d (diff) | |
download | libcap2-f5ae31ebd3d49a064cb85ccd62a75198883cec3b.tar.gz |
Be more consistent with make variables.
Noticed that we weren't applying the same amount of flag discipline
to local BUILD_* tool rules. Fixing that, I see we've been carrying
a source code issue in libcap/_makenames.c for a while. (FIXED).
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r-- | Make.Rules | 38 | ||||
-rw-r--r-- | go/Makefile | 8 | ||||
-rw-r--r-- | libcap/_makenames.c | 2 | ||||
-rw-r--r-- | progs/Makefile | 4 |
4 files changed, 27 insertions, 25 deletions
@@ -63,39 +63,41 @@ GOMAJOR=1 KERNEL_HEADERS := $(topdir)/libcap/include/uapi LIBCAP_INCLUDES = -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include DEFINES := -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +SYSTEM_HEADERS = /usr/include -CC := $(CROSS_COMPILE)gcc -LD=$(CC) -Wl,-x -shared SUDO := sudo +CC := $(CROSS_COMPILE)gcc +LD := $(CC) -Wl,-x -shared +AR := $(CROSS_COMPILE)ar +RANLIB := $(CROSS_COMPILE)ranlib +OBJCOPY := $(CROSS_COMPILE)objcopy + +# Reference: +# CPPFLAGS used for building .o files from .c & .h files +# CFLAGS used when building libraries from .o, .c and .h files + COPTS ?= -O2 -CFLAGS ?= $(COPTS) $(DEFINES) +CFLAGS ?= $(COPTS) +CPPFLAGS += -Dlinux $(WARNINGS) $(DEBUG) $(DEFINES) $(LIBCAP_INCLUDES) LDFLAGS ?= #-g -CPPFLAGS += $(LIBCAP_INCLUDES) +DEBUG = -g #-DDEBUG +WARNINGS=-Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs \ + -Winline -Wshadow BUILD_CC ?= $(CC) BUILD_LD ?= $(BUILD_CC) -Wl,-x -shared BUILD_COPTS ?= $(COPTS) -BUILD_CFLAGS ?= $(BUILD_COPTS) $(DEFINES) +BUILD_CFLAGS ?= $(BUILD_COPTS) +BUILD_CPPFLAGS += -Dlinux $(WARNINGS) $(DEBUG) $(DEFINES) $(LIBCAP_INCLUDES) BUILD_LDFLAGS ?= $(LDFLAGS) -BUILD_CPPFLAGS += $(LIBCAP_INCLUDES) +BUILD_GPERF := $(shell which gperf >/dev/null 2>/dev/null && echo yes) -AR := $(CROSS_COMPILE)ar -RANLIB := $(CROSS_COMPILE)ranlib -OBJCOPY := $(CROSS_COMPILE)objcopy -DEBUG = -g #-DDEBUG -WARNINGS=-Wall -Wwrite-strings \ - -Wpointer-arith -Wcast-qual -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes \ - -Wnested-externs -Winline -Wshadow LIBCAPLIB := -L$(topdir)/libcap -lcap PSXLINKFLAGS := -lpthread -Wl,-wrap,pthread_create LIBPSXLIB := -L$(topdir)/libcap -lpsx $(PSXLINKFLAGS) -BUILD_GPERF := $(shell which gperf >/dev/null 2>/dev/null && echo yes) - -SYSTEM_HEADERS = /usr/include INCS=$(topdir)/libcap/include/sys/capability.h -CFLAGS += -Dlinux $(WARNINGS) $(DEBUG) INDENT := $(shell if [ -n "$$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi) # SHARED tracks whether or not the SHARED libraries (libcap.so, diff --git a/go/Makefile b/go/Makefile index 854f0e3..5af5321 100644 --- a/go/Makefile +++ b/go/Makefile @@ -18,10 +18,10 @@ DEPS=../libcap/libcap.a ../libcap/libpsx.a all: PSXGOPACKAGE CAPGOPACKAGE web setid gowns captree compare-cap try-launching psx-signals $(DEPS): - make -C ../libcap all + $(MAKE) -C ../libcap all ../progs/tcapsh-static: - make -C ../progs tcapsh-static + $(MAKE) -C ../progs tcapsh-static vendor/$(IMPORTDIR) vendor/modules.txt: mkdir -p "vendor/$(IMPORTDIR)" @@ -39,7 +39,7 @@ vendor/$(IMPORTDIR)/cap: vendor/modules.txt touch ../cap $(topdir)/libcap/cap_names.h: - make -C $(topdir)/libcap cap_names.h + $(MAKE) -C $(topdir)/libcap cap_names.h good-names.go: $(topdir)/libcap/cap_names.h vendor/$(IMPORTDIR)/cap mknames.go CC="$(CC)" $(GO) run -mod=vendor mknames.go --header=$< --textdir=$(topdir)/doc/values | gofmt > $@ || rm -f $@ @@ -59,7 +59,7 @@ compare-cap: compare-cap.go CAPGOPACKAGE web: ../goapps/web/web.go CAPGOPACKAGE CC="$(CC)" CGO_ENABLED="$(CGO_REQUIRED)" $(CGO_LDFLAGS_ALLOW) $(GO) build -mod=vendor -o $@ $< ifeq ($(RAISE_GO_FILECAP),yes) - make -C ../progs setcap + $(MAKE) -C ../progs setcap $(SUDO) ../progs/setcap cap_setpcap,cap_net_bind_service=p web @echo "NOTE: RAISED cap_setpcap,cap_net_bind_service ON web binary" endif diff --git a/libcap/_makenames.c b/libcap/_makenames.c index c0d6db4..30eb080 100644 --- a/libcap/_makenames.c +++ b/libcap/_makenames.c @@ -26,7 +26,7 @@ struct { * indicated extended empty space. */ static void *recalloc(void *p, int was, int is) { - void *n = realloc(p, is); + char *n = realloc(p, is); if (!n) { fputs("out of memory", stderr); exit(1); diff --git a/progs/Makefile b/progs/Makefile index 51e9a63..0917dd3 100644 --- a/progs/Makefile +++ b/progs/Makefile @@ -22,10 +22,10 @@ DEPS = ../libcap/libcap.a endif ../libcap/libcap.a: - make -C ../libcap libcap.a + $(MAKE) -C ../libcap libcap.a ../libcap/libcap.so: - make -C ../libcap libcap.so + $(MAKE) -C ../libcap libcap.so $(BUILD): %: %.o $(DEPS) $(CC) $(CFLAGS) -o $@ $< $(LIBCAPLIB) $(LDFLAGS) |