diff options
Diffstat (limited to 'Make.Rules')
-rw-r--r-- | Make.Rules | 89 |
1 files changed, 61 insertions, 28 deletions
@@ -1,7 +1,7 @@ # Common version number defines for libcap LIBTITLE=libcap VERSION=2 -MINOR=53 +MINOR=69 # ## Optional prefixes: @@ -18,7 +18,15 @@ FAKEROOT=$(DESTDIR) # administrative operations that could be needed to recover a system. ifndef lib -lib=$(shell ldd /usr/bin/ld|egrep "ld-linux|ld.so"|cut -d/ -f2) +lib=$(shell ldd /usr/bin/ld|grep -E "ld-linux|ld.so"|cut -d/ -f2) +endif + +ifndef sbin +sbin=sbin +endif + +ifdef sbindir +sbin=$(sbindir) endif ifdef prefix @@ -37,7 +45,7 @@ endif # Target directories MANDIR=$(man_prefix)/man -SBINDIR=$(exec_prefix)/sbin +SBINDIR=$(exec_prefix)/$(sbin) INCDIR=$(inc_prefix)/include LIBDIR=$(lib_prefix)/$(lib) PKGCONFIGDIR=$(LIBDIR)/pkgconfig @@ -46,40 +54,63 @@ GOPKGDIR=$(prefix)/share/gocode/src # From here on out, the Go module packages should always remain # backwardly compatible. I will only resort to using major version 2 # etc if Go's syntax dramatically changes in a backwards incompatible -# manner. (Let's hope not.) +# manner. (Let's hope not. If that happens, I'll also drop deprecated +# API functions.) GOMAJOR=1 # Compilation specifics KERNEL_HEADERS := $(topdir)/libcap/include/uapi -IPATH += -fPIC -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include +LIBCAP_INCLUDES = -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include +DEFINES := -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +SYSTEM_HEADERS = /usr/include +SUDO := sudo CC := $(CROSS_COMPILE)gcc -DEFINES := -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -COPTS ?= -O2 -CFLAGS ?= $(COPTS) $(DEFINES) -BUILD_CC ?= $(CC) -BUILD_COPTS ?= -O2 -BUILD_CFLAGS ?= $(BUILD_COPTS) $(DEFINES) $(IPATH) +LD := $(CC) -Wl,-x -shared 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 -LD=$(CC) -Wl,-x -shared -LDFLAGS ?= #-g + +# Reference: +# CPPFLAGS used for building .o files from .c & .h files +# CFLAGS used when building libraries from .o, .c and .h files + +DEBUG = # -g -DDEBUG +WARNINGS=-Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs \ + -Winline -Wshadow -Wunreachable-code +COPTS ?= -O2 +CFLAGS ?= $(COPTS) $(DEBUG) +CFLAGS += $(WARNINGS) +CPPFLAGS += -Dlinux $(DEFINES) $(LIBCAP_INCLUDES) +LDFLAGS ?= # -g + +BUILD_CC ?= $(CC) +BUILD_LD ?= $(BUILD_CC) -Wl,-x -shared +BUILD_COPTS ?= $(COPTS) +BUILD_CFLAGS ?= $(BUILD_COPTS) +BUILD_CPPFLAGS += -Dlinux $(WARNINGS) $(DEBUG) $(DEFINES) $(LIBCAP_INCLUDES) +BUILD_LDFLAGS ?= $(LDFLAGS) +BUILD_SED ?= sed +BUILD_GREP ?= grep +BUILD_EGREP ?= $(BUILD_GREP) -E +BUILD_FGREP ?= $(BUILD_GREP) -F + +# Plan to eventually redefine BUILD_GPERF to be the actual gperf tool +# alias as per above. Typical distributions are upto a year behind +# HEAD so we'll not do that before 2023-01-01. +ifdef BUILD_GPERF +$(error BUILD_GPERF is now reserved, please use USE_GPERF=yes or no instead) +endif + +USE_GPERF ?= $(shell which gperf >/dev/null 2>/dev/null && echo yes) + 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, @@ -87,6 +118,7 @@ INDENT := $(shell if [ -n "$$(which indent 2>/dev/null)" ]; then echo "| indent # support shared libraries.) SHARED ?= yes # DYNAMIC controls how capsh etc are linked - to shared or static libraries +# Force enabled with "make DYNAMIC=yes ...". DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo $(SHARED); else echo no ; fi) PAM_CAP ?= $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo $(SHARED) ; else echo no ; fi) @@ -109,15 +141,16 @@ ifeq ($(GOLANG),yes) GOROOT ?= $(shell $(GO) env GOROOT) GOCGO ?= $(shell if [ "$(shell $(GO) env CGO_ENABLED)" = 1 ]; then echo yes ; else echo no ; fi) GOOSARCH ?= $(shell $(GO) env GOHOSTOS)_$(shell $(GO) env GOHOSTARCH) -CGO_REQUIRED=$(shell $(topdir)/go/cgo-required.sh $(GO)) +CGO_REQUIRED := $(shell $(topdir)/go/cgo-required.sh $(GO)) ifeq ($(CGO_REQUIRED),1) # Strictly speaking go1.15 doesn't need this, but 1.16 is when the # real golang support arrives for non-cgo support, so drop the last # vestige of legacy workarounds then. CGO_LDFLAGS_ALLOW := CGO_LDFLAGS_ALLOW="-Wl,-?-wrap[=,][^-.@][^,]*" endif -CGO_CFLAGS := -I$(topdir)/libcap/include +CGO_CFLAGS := $(LIBCAP_INCLUDES) CGO_LDFLAGS := -L$(topdir)/libcap +GO_BUILD_FLAGS := endif endif @@ -136,11 +169,11 @@ endif # # make RAISE_SETFCAP=yes install # -# This is now defaulted to no because some distributions have started -# shipping with all users blessed with full inheritable sets which makes -# no sense whatsoever! +# This is now defaulted to no because some distributions started +# shipping with all users blessed with full inheritable sets which +# makes no sense whatsoever! # -# Indeed, it looks alarmingly like these distributions are recreating +# Indeed, it looked alarmingly like these distributions were recreating # the environment for what became known as the sendmail-capabilities # bug from 2000: # |