libcap: fix static build

This makes the build correct when cap==null

It also patches the Makefiles so that shared libraries aren't built during the install phase
This commit is contained in:
Joe Hermaszewski 2020-11-10 15:54:52 +08:00 committed by Frederik Rietdijk
parent 88fcd687d0
commit 4fe23ed6ca
3 changed files with 32 additions and 4 deletions

View file

@ -1,4 +1,5 @@
{ stdenv, buildPackages, fetchurl, attr, perl, pam }:
{ stdenv, lib, buildPackages, fetchurl, attr, perl, pam
, static ? stdenv.targetPlatform.isStatic }:
stdenv.mkDerivation rec {
pname = "libcap";
@ -9,7 +10,10 @@ stdenv.mkDerivation rec {
sha256 = "1qf80lifygbnxwvqjf8jz5j24n6fqqx4ixnkbf76xs2vrmcq664j";
};
outputs = [ "out" "dev" "lib" "man" "doc" "pam" ];
patches = lib.optional static ./no-shared-lib.patch;
outputs = [ "out" "dev" "lib" "man" "doc" ]
++ lib.optional (pam != null) "pam";
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ perl ];
@ -20,7 +24,7 @@ stdenv.mkDerivation rec {
makeFlags = [
"lib=lib"
"PAM_CAP=yes"
"PAM_CAP=${if pam == null then "no" else "yes"}"
"BUILD_CC=$(CC_FOR_BUILD)"
"CC:=$(CC)"
];
@ -44,7 +48,7 @@ stdenv.mkDerivation rec {
installFlags = [ "RAISE_SETFCAP=no" ];
postInstall = ''
rm "$lib"/lib/*.a
${lib.optionalString (!static) ''rm "$lib"/lib/*.a''}
mkdir -p "$doc/share/doc/${pname}-${version}"
cp License "$doc/share/doc/${pname}-${version}/"
'' + stdenv.lib.optionalString (pam != null) ''

View file

@ -0,0 +1,22 @@
diff --git a/libcap/Makefile b/libcap/Makefile
index de6a28d..7e4d8ac 100644
--- a/libcap/Makefile
+++ b/libcap/Makefile
@@ -22,7 +22,7 @@ MAJLIBNAME=$(LIBNAME).$(VERSION)
MINLIBNAME=$(MAJLIBNAME).$(MINOR)
GPERF_OUTPUT = _caps_output.gperf
-all: $(MINLIBNAME) $(STACAPLIBNAME) pcs $(STAPSXLIBNAME)
+all: $(STACAPLIBNAME) pcs $(STAPSXLIBNAME)
pcs: libcap.pc libpsx.pc
@@ -93,7 +93,7 @@ cap_test: cap_test.c libcap.h
test: cap_test
./cap_test
-install: install-static install-shared
+install: install-static
install-static: install-static-cap install-static-psx

View file

@ -314,4 +314,6 @@ in {
configureFlags = attrs.configureFlags ++ [ "--disable-shared" ];
});
});
libcap = super.libcap.override { pam = null; };
}