sternenseemann 2022-02-27 10:27:57 +01:00
parent cd8d955620
commit 51ec00354b
2 changed files with 36 additions and 50 deletions

View file

@ -1,16 +1,26 @@
{ lib, stdenv, fetchurl, fixDarwinDylibNames, which }:
{ lib, stdenv, fetchurl, fixDarwinDylibNames, which
, enableShared ? !(stdenv.hostPlatform.isStatic)
, enableStatic ? stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "lowdown";
version = "0.10.0";
version = "0.11.1";
outputs = [ "out" "lib" "dev" "man" ];
src = fetchurl {
url = "https://kristaps.bsd.lv/lowdown/snapshots/lowdown-${version}.tar.gz";
sha512 = "3gq6awxvkz2hb8xzcwqhdhdqgspvqjfzm50bq9i29qy2iisq9vzb91bdp3f4q2sqcmk3gms44xyxyn3ih2hwlzsnk0f5prjzyg97fjj";
sha512 = "1l0055g8v0dygyxvk5rchp4sn1g2lakbf6hhq0wkj6nxkfpl43mkyc4vpb02r7v6iqfdwq4461dmdi78blsb3nj8b1gcjx75v7x9pa1";
};
# Upstream always passes GNU-style "soname", but cctools expects "install_name".
# Whatever name is inserted will be replaced by fixDarwinDylibNames.
# https://github.com/kristapsdz/lowdown/issues/87
postPatch = lib.optionalString stdenv.isDarwin ''
substituteInPlace Makefile --replace soname install_name
'';
nativeBuildInputs = [ which ]
++ lib.optionals stdenv.isDarwin [ fixDarwinDylibNames ];
@ -27,12 +37,30 @@ stdenv.mkDerivation rec {
runHook postConfigure
'';
# Fix lib extension so that fixDarwinDylibNames detects it
postInstall = lib.optionalString stdenv.isDarwin ''
mv $lib/lib/liblowdown.{so,dylib}
'';
makeFlags = [
"bins" # prevents shared object from being built unnecessarily
];
patches = lib.optional (!stdenv.hostPlatform.isStatic) ./shared.patch;
installTargets = [
"install"
] ++ lib.optionals enableShared [
"install_shared"
] ++ lib.optionals enableStatic [
"install_static"
];
# Fix lib extension so that fixDarwinDylibNames detects it
# Symlink liblowdown.so to liblowdown.so.1 (or equivalent)
postInstall =
let
inherit (stdenv.hostPlatform.extensions) sharedLibrary;
in
lib.optionalString (enableShared && stdenv.isDarwin) ''
mv $lib/lib/liblowdown.{so.1,1.dylib}
'' + lib.optionalString enableShared ''
ln -s $lib/lib/liblowdown*${sharedLibrary}* $lib/lib/liblowdown${sharedLibrary}
'';
doInstallCheck = stdenv.hostPlatform == stdenv.buildPlatform;
installCheckPhase = ''

View file

@ -1,42 +0,0 @@
diff --git a/Makefile b/Makefile
index 955f737..2c9532c 100644
--- a/Makefile
+++ b/Makefile
@@ -80,7 +80,7 @@ REGRESS_ARGS += "--parse-no-autolink"
REGRESS_ARGS += "--parse-no-cmark"
REGRESS_ARGS += "--parse-no-deflists"
-all: lowdown lowdown-diff lowdown.pc
+all: lowdown lowdown-diff liblowdown.so lowdown.pc
www: $(HTMLS) $(PDFS) $(THUMBS) lowdown.tar.gz lowdown.tar.gz.sha512
@@ -101,6 +101,10 @@ lowdown-diff: lowdown
liblowdown.a: $(OBJS) $(COMPAT_OBJS)
$(AR) rs $@ $(OBJS) $(COMPAT_OBJS)
+%.o: CFLAGS += -fPIC
+liblowdown.so: $(OBJS) $(COMPAT_OBJS)
+ $(CC) -shared -o $@ $(OBJS) $(COMPAT_OBJS) $(LDFLAGS)
+
install: all
mkdir -p $(DESTDIR)$(BINDIR)
mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig
@@ -111,7 +114,7 @@ install: all
$(INSTALL_DATA) lowdown.pc $(DESTDIR)$(LIBDIR)/pkgconfig
$(INSTALL_PROGRAM) lowdown $(DESTDIR)$(BINDIR)
$(INSTALL_PROGRAM) lowdown-diff $(DESTDIR)$(BINDIR)
- $(INSTALL_LIB) liblowdown.a $(DESTDIR)$(LIBDIR)
+ $(INSTALL_LIB) liblowdown.so $(DESTDIR)$(LIBDIR)
$(INSTALL_DATA) lowdown.h $(DESTDIR)$(INCLUDEDIR)
for f in $(MANS) ; do \
name=`basename $$f .html` ; \
@@ -199,7 +202,7 @@ main.o: lowdown.h
clean:
rm -f $(OBJS) $(COMPAT_OBJS) main.o
- rm -f lowdown lowdown-diff liblowdown.a lowdown.pc
+ rm -f lowdown lowdown-diff liblowdown.so lowdown.pc
rm -f index.xml diff.xml diff.diff.xml README.xml lowdown.tar.gz.sha512 lowdown.tar.gz
rm -f $(PDFS) $(HTMLS) $(THUMBS)