diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2021-08-23 19:17:42 -0700 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2021-08-23 19:17:42 -0700 |
commit | 2e28d3f3e8a1eab3cae561465a4e8076b984be2f (patch) | |
tree | 2c34777cd6865f069b986207f6ec313b3487a3ac | |
parent | afbc554d16a32ed352191e49b3673f2f72d0002f (diff) | |
download | libcap-2e28d3f3e8a1eab3cae561465a4e8076b984be2f.tar.gz |
Allow the builder to force -lpam linkage.
I've yet to understand why this is needed. But, apparently, folk
feel strongly that there is a reason one might want to force it
one way or another. If you don't care one way or the other, let
the Makefiles figure out something that works.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r-- | Make.Rules | 12 | ||||
-rw-r--r-- | pam_cap/Makefile | 20 |
2 files changed, 25 insertions, 7 deletions
@@ -53,16 +53,22 @@ 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 CC := $(CROSS_COMPILE)gcc -DEFINES := -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +LD=$(CC) -Wl,-x -shared COPTS ?= -O2 CFLAGS ?= $(COPTS) $(DEFINES) +LDFLAGS ?= #-g CPPFLAGS += $(LIBCAP_INCLUDES) + BUILD_CC ?= $(CC) -BUILD_COPTS ?= -O2 +BUILD_LD ?= $(BUILD_CC) -Wl,-x -shared +BUILD_COPTS ?= $(COPTS) BUILD_CFLAGS ?= $(BUILD_COPTS) $(DEFINES) +BUILD_LDFLAGS ?= $(LDFLAGS) BUILD_CPPFLAGS += $(LIBCAP_INCLUDES) + AR := $(CROSS_COMPILE)ar RANLIB := $(CROSS_COMPILE)ranlib OBJCOPY := $(CROSS_COMPILE)objcopy @@ -71,8 +77,6 @@ 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 LIBCAPLIB := -L$(topdir)/libcap -lcap PSXLINKFLAGS := -lpthread -Wl,-wrap,pthread_create LIBPSXLIB := -L$(topdir)/libcap -lpsx $(PSXLINKFLAGS) diff --git a/pam_cap/Makefile b/pam_cap/Makefile index 758d51b..d35bdb4 100644 --- a/pam_cap/Makefile +++ b/pam_cap/Makefile @@ -31,15 +31,29 @@ pam_cap.so: pam_cap.o execable.o pam_cap_linkopts # # https://bugzilla.kernel.org/show_bug.cgi?id=214023 # -# If the current build environment is one of those, extend the link -# options for pam_cap.so to force linkage against libpam and the -# gazillion other things libpam is linked against... +# If the current build environment is one of those, or we can't +# reliably prove it isn't, extend the link options for pam_cap.so to +# force linkage against libpam and the gazillion other things libpam +# is linked against... +# +# If you want to force this behavior one way or the other, use the +# make FORCELINKPAM=yes or FORCELINKPAM=no override. +ifeq ($(FORCELINKPAM),yes) +pam_cap_linkopts: Makefile + echo "-Wl,-e,__so_start -lpam" > $@ +else +ifeq ($(FORCELINKPAM),no) +pam_cap_linkopts: Makefile + echo "-Wl,-e,__so_start" > $@ +else pam_cap_linkopts: lazylink.so echo "-Wl,-e,__so_start" > $@ ./lazylink.so || echo "-lpam" >> $@ lazylink.so: lazylink.c ../libcap/execable.h ../libcap/loader.txt $(LD) -o $@ $(CFLAGS) $(CPPFLAGS) lazylink.c -DSHARED_LOADER=\"$(shell cat ../libcap/loader.txt)\" $(LDFLAGS) -Wl,-e,__so_start +endif +endif pam_cap.o: pam_cap.c $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ |