Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchurl, unzip }:
2
3let
4 version = "2.6.2";
5 SHLIB_EXT = stdenv.hostPlatform.extensions.sharedLibrary;
6in stdenv.mkDerivation {
7 pname = "tinyxml";
8 inherit version;
9
10 src = fetchurl {
11 url = "mirror://sourceforge/project/tinyxml/tinyxml/${version}/tinyxml_2_6_2.zip";
12 sha256 = "04nmw6im2d1xp12yir8va93xns5iz816pwi25n9cql3g3i8bjsxc";
13 };
14
15 patches = [
16 # add pkg-config file
17 ./2.6.2-add-pkgconfig.patch
18
19 # https://sourceforge.net/tracker/index.php?func=detail&aid=3031828&group_id=13559&atid=313559
20 ./2.6.2-entity.patch
21
22 # Use CC, CXX, and LD from environment
23 ./2.6.2-cxx.patch
24 ];
25
26 preConfigure = "export LD=${stdenv.cc.targetPrefix}c++";
27
28 hardeningDisable = [ "format" ];
29
30 env.NIX_CFLAGS_COMPILE =
31 lib.optionalString stdenv.isDarwin "-mmacosx-version-min=10.9";
32
33 nativeBuildInputs = [ unzip ];
34 buildPhase = ''
35 # use STL (xbmc requires it)
36 sed '1i#define TIXML_USE_STL 1' -i tinyxml.h
37 sed '1i#define TIXML_USE_STL 1' -i xmltest.cpp
38
39 # build xmltest
40 make
41
42 # build the lib as a shared library
43 ''${CXX} -Wall -O2 -shared -fpic tinyxml.cpp \
44 tinyxmlerror.cpp tinyxmlparser.cpp \
45 tinystr.cpp -o libtinyxml${SHLIB_EXT}
46 '';
47
48 doCheck = true;
49 checkPhase = ''
50 ./xmltest
51 result=$?
52 if [[ $result != 0 ]] ; then
53 exit $result
54 fi
55 '';
56
57 installPhase = ''
58 mkdir -pv $out/include/
59 mkdir -pv $out/lib/pkgconfig/
60 mkdir -pv $out/share/doc/tinyxml/
61
62 cp -v libtinyxml${SHLIB_EXT} $out/lib/
63 cp -v *.h $out/include/
64
65 substituteInPlace tinyxml.pc --replace "@out@" "$out"
66 substituteInPlace tinyxml.pc --replace "@version@" "${version}"
67 cp -v tinyxml.pc $out/lib/pkgconfig/
68
69 cp -v docs/* $out/share/doc/tinyxml/
70 '' + lib.optionalString stdenv.isDarwin ''
71 install_name_tool -id $out/lib/libtinyxml.dylib $out/lib/libtinyxml.dylib
72 '';
73
74 meta = {
75 description = "Simple, small, C++ XML parser that can be easily integrating into other programs";
76 homepage = "http://www.grinninglizard.com/tinyxml/index.html";
77 license = lib.licenses.free;
78 platforms = lib.platforms.unix;
79 };
80}