about summary refs log tree commit diff
path: root/pkgs/development/libraries/tinyxml
diff options
context:
space:
mode:
authorAnthony Cowley <acowley@gmail.com>2016-04-01 14:56:07 -0400
committerBjørn Forsman <bjorn.forsman@gmail.com>2016-05-21 21:04:41 +0200
commit7b56411fef87d7ab775640117bf461aaeb4a55e1 (patch)
treefbb8e01e04b0e3feef1e8fd153bb25c17ea4f3d4 /pkgs/development/libraries/tinyxml
parent3a1beb6347799a8d8f3290a6158b2d5249c7ecb8 (diff)
tinyxml: darwin compatibility
- Relax the baked-in assumption that g++ is used to build and link
- Use the appropriate shared library extension on darwin
Diffstat (limited to 'pkgs/development/libraries/tinyxml')
-rw-r--r--pkgs/development/libraries/tinyxml/2.6.2-cxx.patch17
-rw-r--r--pkgs/development/libraries/tinyxml/2.6.2.nix14
2 files changed, 28 insertions, 3 deletions
diff --git a/pkgs/development/libraries/tinyxml/2.6.2-cxx.patch b/pkgs/development/libraries/tinyxml/2.6.2-cxx.patch
new file mode 100644
index 0000000000000..e55d0be43bcc2
--- /dev/null
+++ b/pkgs/development/libraries/tinyxml/2.6.2-cxx.patch
@@ -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
diff --git a/pkgs/development/libraries/tinyxml/2.6.2.nix b/pkgs/development/libraries/tinyxml/2.6.2.nix
index 7f0a343eba233..231550cd55714 100644
--- a/pkgs/development/libraries/tinyxml/2.6.2.nix
+++ b/pkgs/development/libraries/tinyxml/2.6.2.nix
@@ -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"