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 # http://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 preConfigure = "export LD=${if stdenv.isDarwin then "clang++" else "g++"}";
25
26 NIX_CFLAGS_COMPILE =
27 stdenv.lib.optional stdenv.isDarwin "-mmacosx-version-min=10.9";
28
29 buildInputs = [ unzip ];
30 buildPhase = ''
31 # use STL (xbmc requires it)
32 sed '1i#define TIXML_USE_STL 1' -i tinyxml.h
33 sed '1i#define TIXML_USE_STL 1' -i xmltest.cpp
34
35 # build xmltest
36 make
37
38 # build the lib as a shared library
39 ''${CXX} -Wall -O2 -shared -fpic tinyxml.cpp \
40 tinyxmlerror.cpp tinyxmlparser.cpp \
41 tinystr.cpp -o libtinyxml${SHLIB_EXT}
42 '';
43
44 doCheck = true;
45 checkPhase = ''
46 ./xmltest
47 result=$?
48 if [[ $result != 0 ]] ; then
49 exit $result
50 fi
51 '';
52
53 installPhase = ''
54 mkdir -pv $out/include/
55 mkdir -pv $out/lib/pkgconfig/
56 mkdir -pv $out/share/doc/tinyxml/
57
58 cp -v libtinyxml${SHLIB_EXT} $out/lib/
59 cp -v *.h $out/include/
60
61 substituteInPlace tinyxml.pc --replace "@out@" "$out"
62 substituteInPlace tinyxml.pc --replace "@version@" "${version}"
63 cp -v tinyxml.pc $out/lib/pkgconfig/
64
65 cp -v docs/* $out/share/doc/tinyxml/
66 '' + stdenv.lib.optionalString stdenv.isDarwin ''
67 install_name_tool -id $out/lib/libtinyxml.dylib $out/lib/libtinyxml.dylib
68 '';
69
70 meta = {
71 description = "Simple, small, C++ XML parser that can be easily integrating into other programs";
72 homepage = http://www.grinninglizard.com/tinyxml/index.html;
73 license = stdenv.lib.licenses.free;
74 platforms = stdenv.lib.platforms.unix;
75 };
76}