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