1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 xmlto,
7 docbook_xml_dtd_412,
8 docbook_xsl,
9 autoconf,
10 automake,
11 libtool,
12 autoreconfHook,
13}:
14
15stdenv.mkDerivation rec {
16 pname = "opensp";
17 version = "1.5.2";
18
19 src = fetchurl {
20 url = "mirror://sourceforge/openjade/OpenSP-${version}.tar.gz";
21 sha256 = "1khpasr6l0a8nfz6kcf3s81vgdab8fm2dj291n5r2s53k228kx2p";
22 };
23
24 postPatch = ''
25 sed -i s,/usr/share/sgml/docbook/xml-dtd-4.1.2/,${docbook_xml_dtd_412}/xml/dtd/docbook/, \
26 docsrc/*.xml
27 '';
28
29 patches = [
30 (fetchpatch {
31 url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-text/opensp/files/opensp-1.5.2-c11-using.patch?id=688d9675782dfc162d4e6cff04c668f7516118d0";
32 sha256 = "04q14s8qsad0bkjmj067dn831i0r6v7742rafdlnbfm5y249m2q6";
33 })
34 # Clang 16 defaults to C++17, which does not allow `register` as a storage class specifier.
35 ./fix-register-storage-class.patch
36 ];
37
38 setupHook = ./setup-hook.sh;
39
40 postFixup = ''
41 # Remove random ids in the release notes
42 sed -i -e 's/href="#idm.*"//g' $out/share/doc/OpenSP/releasenotes.html
43 sed -i -e 's/name="idm.*"//g' $out/share/doc/OpenSP/releasenotes.html
44 '';
45
46 preConfigure = lib.optionalString stdenv.hostPlatform.isCygwin ''
47 autoreconf -fi
48 '';
49
50 strictDeps = true;
51
52 nativeBuildInputs = [
53 xmlto
54 docbook_xml_dtd_412
55 docbook_xsl
56 ]
57 # Clang 16 fails to build due to inappropriate definitions in the `config.h` generated by the
58 # existing configure scripts. Regenerate them to make sure they detect its features correctly.
59 ++ lib.optional stdenv.cc.isClang autoreconfHook
60 ++ lib.optionals stdenv.hostPlatform.isCygwin [
61 autoconf
62 automake
63 libtool
64 ];
65
66 env = lib.optionalAttrs stdenv.cc.isGNU {
67 NIX_CFLAGS_COMPILE = "-fpermissive";
68 };
69
70 doCheck = false; # fails
71
72 meta = with lib; {
73 description = "Suite of SGML/XML processing tools";
74 license = licenses.mit;
75 homepage = "https://openjade.sourceforge.net/";
76 platforms = platforms.unix;
77 maintainers = [ ];
78 };
79}