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