[125807] trunk/dports/pure/pure-stllib
ryandesign at macports.org
ryandesign at macports.org
Fri Sep 26 14:03:27 PDT 2014
Revision: 125807
https://trac.macports.org/changeset/125807
Author: ryandesign at macports.org
Date: 2014-09-26 14:03:27 -0700 (Fri, 26 Sep 2014)
Log Message:
-----------
pure-stllib: add tr1 support for systems with libstdc++ and blacklist compilers that don't do C++11
Modified Paths:
--------------
trunk/dports/pure/pure-stllib/Portfile
Added Paths:
-----------
trunk/dports/pure/pure-stllib/files/
trunk/dports/pure/pure-stllib/files/patch-Makefiles.diff
trunk/dports/pure/pure-stllib/files/patch-tr1-support.diff
Modified: trunk/dports/pure/pure-stllib/Portfile
===================================================================
--- trunk/dports/pure/pure-stllib/Portfile 2014-09-26 20:59:49 UTC (rev 125806)
+++ trunk/dports/pure/pure-stllib/Portfile 2014-09-26 21:03:27 UTC (rev 125807)
@@ -19,8 +19,20 @@
depends_build-append port:pkgconfig
+patchfiles-append patch-Makefiles.diff
+patchfiles-append patch-tr1-support.diff
+
+# Requires C++11.
+compiler.blacklist-append gcc-* *llvm-gcc*
+
# These are set in the Makefile but the pure portgroup overrides them.
configure.cxxflags-append -g -std=c++0x -Wall
+# No auto-detection of TR1 support yet.
+# https://bitbucket.org/purelang/pure-lang/issue/29/pure-stldict-08-fails-to-build-on-os-x-108
+if {${configure.cxx_stdlib} eq "libstdc++"} {
+ configure.cxxflags-append -DHAVE_TR1
+}
+
test.run yes
test.target check
Added: trunk/dports/pure/pure-stllib/files/patch-Makefiles.diff
===================================================================
--- trunk/dports/pure/pure-stllib/files/patch-Makefiles.diff (rev 0)
+++ trunk/dports/pure/pure-stllib/files/patch-Makefiles.diff 2014-09-26 21:03:27 UTC (rev 125807)
@@ -0,0 +1,46 @@
+https://bitbucket.org/purelang/pure-lang/issue/29/pure-stldict-08-fails-to-build-on-os-x-108
+--- Makefile.orig Fri Sep 26 00:34:35 2014 +0200
++++ Makefile Fri Sep 26 07:20:14 2014 +0200
+@@ -14,10 +14,10 @@
+ libdir = $(shell pkg-config pure --variable libdir)
+ installdir = $(addprefix $(DESTDIR), $(libdir)/pure)
+
+-MOD_CXXFLAGS = $(PIC) $(shell pkg-config pure --cflags) $(CFLAGS) $(CPPFLAGS)
++MOD_CXXFLAGS = $(PIC) $(shell pkg-config pure --cflags) $(CXXFLAGS) $(CPPFLAGS)
+ MOD_LDFLAGS = $(shell pkg-config pure --libs) $(LDFLAGS)
+
+-CFLAGS = -g -O2 -Wall -Wextra
++CXXFLAGS = -g -O2 -Wall -Wextra
+
+ ifeq "$(DLL)" ".dylib"
+ DLL_FLAGS = -install_name "$(libdir)/pure/$@"
+--- pure-stlmap/Makefile.orig Fri Sep 26 00:34:35 2014 +0200
++++ pure-stlmap/Makefile Fri Sep 26 07:20:14 2014 +0200
+@@ -11,10 +11,10 @@
+ installdir = $(addprefix $(DESTDIR), $(libdir)/pure)
+
+ MOD_CXXFLAGS = $(PIC) $(shell pkg-config pure --cflags) -I.. \
+- $(CFLAGS) $(CPPFLAGS)
++ $(CXXFLAGS) $(CPPFLAGS)
+ MOD_LDFLAGS = $(shell pkg-config pure --libs) $(LDFLAGS)
+
+-CFLAGS = -g -O2 -Wall -Wextra
++CXXFLAGS = -g -O2 -Wall -Wextra
+ ifneq "$(DLL)" ".so"
+ # additional libraries to be linked (Mac/Windows only)
+ EXTRA_LIBS = ../stlbase$(DLL)
+--- pure-stlvec/Makefile.orig Fri Sep 26 00:34:35 2014 +0200
++++ pure-stlvec/Makefile Fri Sep 26 07:20:14 2014 +0200
+@@ -12,10 +12,10 @@
+
+
+ MOD_CXXFLAGS = $(PIC) $(shell pkg-config pure --cflags) -I.. \
+- $(CFLAGS) $(CPPFLAGS)
++ $(CXXFLAGS) $(CPPFLAGS)
+ MOD_LDFLAGS = $(shell pkg-config pure --libs) $(LDFLAGS)
+
+-CFLAGS = -g -O2 -Wall -Wextra
++CXXFLAGS = -g -O2 -Wall -Wextra
+ ifneq "$(DLL)" ".so"
+ # additional libraries to be linked (Mac/Windows only)
+ EXTRA_LIBS = ../stlbase$(DLL)
Added: trunk/dports/pure/pure-stllib/files/patch-tr1-support.diff
===================================================================
--- trunk/dports/pure/pure-stllib/files/patch-tr1-support.diff (rev 0)
+++ trunk/dports/pure/pure-stllib/files/patch-tr1-support.diff 2014-09-26 21:03:27 UTC (rev 125807)
@@ -0,0 +1,114 @@
+https://bitbucket.org/purelang/pure-lang/issue/29/pure-stldict-08-fails-to-build-on-os-x-108
+--- pure-stlmap/stlhmap.cpp.orig Fri Sep 26 07:21:36 2014 +0200
++++ pure-stlmap/stlhmap.cpp Fri Sep 26 07:32:32 2014 +0200
+@@ -403,11 +403,69 @@
+ return ret;
+ }
+
++#ifdef HAVE_TR1
++// There's no equality defined for tr1::unordered_map, we have to do it
++// ourselves. (Code pilfered from pure-stldict. -ag)
++static bool myequal(pair<pure_expr*,pure_expr*> x,
++ pair<pure_expr*,pure_expr*> y)
++{
++ return same(x.second, y.second);
++}
++
++#include <functional>
++#include <tr1/tuple>
++
++template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
++static bool my_is_permutation(ForwardIterator1 first, ForwardIterator1 last,
++ ForwardIterator2 d_first, BinaryPredicate p)
++{
++ // skip common prefix
++ tie(first, d_first) = mismatch(first, last, d_first, p);
++ // iterate over the rest, counting how many times each element
++ // from [first, last) appears in [d_first, d_last)
++ if (first != last) {
++ ForwardIterator2 d_last = d_first;
++ advance(d_last, distance(first, last));
++ for (ForwardIterator1 i = first; i != last; ++i) {
++ using placeholders::_1;
++ if (i != find_if(first, i, bind(p, _1, *i)))
++ continue; // already counted this *i
++ auto m = count_if(d_first, d_last, bind(p, _1, *i));
++ if (m==0 || count_if(i, last, bind(p, _1, *i)) != m) {
++ return false;
++ }
++ }
++ }
++ return true;
++}
++
++static bool pxhmequal(pxhmap &x, pxhmap &y)
++{
++ if (&x == &y) return true;
++ if (x.size() != y.size()) return false;
++ for (pxhmap::iterator it = x.begin(); it != x.end(); ) {
++ pair<pxhmap::iterator, pxhmap::iterator>
++ r1 = x.equal_range(it->first),
++ r2 = y.equal_range(it->first);
++ if (distance(r1.first, r1.second) != distance(r2.first, r2.second))
++ return false;
++ if (!my_is_permutation(r1.first, r1.second, r2.first, myequal))
++ return false;
++ it = r1.second;
++ }
++ return true;
++}
++#endif
++
+ bool stl_shm_equal(px* pxshp1, px* pxshp2)
+ {
+ sh *shp1 = 0, *shp2 = 0;
+ if ( !get_shp(pxshp1,&shp1) || !get_shp(pxshp2,&shp2) ) bad_argument();
++#ifdef HAVE_TR1
++ return pxhmequal(shp1->hm, shp2->hm);
++#else
+ return shp1->hm == shp2->hm;
++#endif
+ }
+
+ px* stl_shm_make_vector(px* pxshp)
+--- pure-stlmap/stlhmap.hpp.orig Fri Sep 26 07:21:36 2014 +0200
++++ pure-stlmap/stlhmap.hpp Fri Sep 26 07:32:32 2014 +0200
+@@ -19,7 +19,20 @@
+
+ #include <iostream>
+ #include <utility>
++
++/* Define this for C++ TR1 extensions support. This is needed to get
++ unordered_map for some older C++ libraries which don't provide full C++11
++ support yet. */
++//#define HAVE_TR1
++#ifdef HAVE_TR1
++#include <tr1/unordered_map>
++using namespace std;
++using namespace std::tr1;
++#else
+ #include <unordered_map>
++using namespace std;
++#endif
++
+ #include "stlbase.hpp"
+
+ typedef pure_expr px;
+@@ -28,7 +41,7 @@
+ struct px_hash
+ {
+ size_t operator()(px* x) const
+- { return hash(x); };
++ { return ::hash(x); };
+ };
+
+ struct px_same {
+@@ -52,7 +65,7 @@
+ }
+ };
+
+-typedef std::unordered_map<px*,px*,px_hash,px_same> pxhmap;
++typedef unordered_map<px*,px*,px_hash,px_same> pxhmap;
+ typedef pxhmap::iterator pxhmapi;
+
+ struct stlhmap {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140926/7bf5a0f6/attachment.html>
More information about the macports-changes
mailing list