tinyxml: darwin compatibility

- Relax the baked-in assumption that g++ is used to build and link
- Use the appropriate shared library extension on darwin
This commit is contained in:
Anthony Cowley 2016-04-01 14:56:07 -04:00 committed by Bjørn Forsman
parent 3a1beb6347
commit 7b56411fef
2 changed files with 28 additions and 3 deletions

View File

@ -0,0 +1,17 @@
diff -u a/Makefile b/Makefile
--- a/Makefile 2011-05-14 22:24:57.000000000 -0400
+++ b/Makefile 2016-04-01 14:53:05.000000000 -0400
@@ -19,9 +19,9 @@
#****************************************************************************
-CC := gcc
-CXX := g++
-LD := g++
+CC ?= gcc
+CXX ?= g++
+LD ?= g++
AR := ar rc
RANLIB := ranlib
Common subdirectories: a/docs and b/docs

View File

@ -2,6 +2,7 @@
let
version = "2.6.2";
SHLIB_EXT = if stdenv.isDarwin then "dylib" else "so";
in stdenv.mkDerivation {
name = "tinyxml-${version}";
@ -16,7 +17,14 @@ in stdenv.mkDerivation {
# http://sourceforge.net/tracker/index.php?func=detail&aid=3031828&group_id=13559&atid=313559
./2.6.2-entity.patch
# Use CC, CXX, and LD from environment
./2.6.2-cxx.patch
];
preConfigure = "export LD=${if stdenv.isDarwin then "clang++" else "g++"}";
NIX_CFLAGS_COMPILE =
stdenv.lib.optional stdenv.isDarwin "-mmacosx-version-min=10.9";
buildInputs = [ unzip ];
buildPhase = ''
@ -28,9 +36,9 @@ in stdenv.mkDerivation {
make
# build the lib as a shared library
g++ -Wall -O2 -shared -fpic tinyxml.cpp \
''${CXX} -Wall -O2 -shared -fpic tinyxml.cpp \
tinyxmlerror.cpp tinyxmlparser.cpp \
tinystr.cpp -o libtinyxml.so
tinystr.cpp -o libtinyxml.${SHLIB_EXT}
'';
doCheck = true;
@ -47,7 +55,7 @@ in stdenv.mkDerivation {
mkdir -pv $out/lib/pkgconfig/
mkdir -pv $out/share/doc/tinyxml/
cp -v libtinyxml.so $out/lib/
cp -v libtinyxml.${SHLIB_EXT} $out/lib/
cp -v *.h $out/include/
substituteInPlace tinyxml.pc --replace "@out@" "$out"