<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[125807] trunk/dports/pure/pure-stllib</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/125807">125807</a></dd>
<dt>Author</dt> <dd>ryandesign@macports.org</dd>
<dt>Date</dt> <dd>2014-09-26 14:03:27 -0700 (Fri, 26 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>pure-stllib: add tr1 support for systems with libstdc++ and blacklist compilers that don't do C++11</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkdportspurepurestllibPortfile">trunk/dports/pure/pure-stllib/Portfile</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/dports/pure/pure-stllib/files/</li>
<li><a href="#trunkdportspurepurestllibfilespatchMakefilesdiff">trunk/dports/pure/pure-stllib/files/patch-Makefiles.diff</a></li>
<li><a href="#trunkdportspurepurestllibfilespatchtr1supportdiff">trunk/dports/pure/pure-stllib/files/patch-tr1-support.diff</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkdportspurepurestllibPortfile"></a>
<div class="modfile"><h4>Modified: trunk/dports/pure/pure-stllib/Portfile (125806 => 125807)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -19,8 +19,20 @@
</span><span class="cx"> 
</span><span class="cx"> depends_build-append    port:pkgconfig
</span><span class="cx"> 
</span><ins>+patchfiles-append       patch-Makefiles.diff
+patchfiles-append       patch-tr1-support.diff
+
+# Requires C++11.
+compiler.blacklist-append gcc-* *llvm-gcc*
+
</ins><span class="cx"> # These are set in the Makefile but the pure portgroup overrides them.
</span><span class="cx"> configure.cxxflags-append -g -std=c++0x -Wall
</span><span class="cx"> 
</span><ins>+# 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 &quot;libstdc++&quot;} {
+    configure.cxxflags-append -DHAVE_TR1
+}
+
</ins><span class="cx"> test.run                yes
</span><span class="cx"> test.target             check
</span></span></pre></div>
<a id="trunkdportspurepurestllibfilespatchMakefilesdiff"></a>
<div class="addfile"><h4>Added: trunk/dports/pure/pure-stllib/files/patch-Makefiles.diff (0 => 125807)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+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 &quot;$(DLL)&quot; &quot;.dylib&quot;
+ DLL_FLAGS = -install_name &quot;$(libdir)/pure/$@&quot;
+--- 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 &quot;$(DLL)&quot; &quot;.so&quot;
+ # 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 &quot;$(DLL)&quot; &quot;.so&quot;
+ # additional libraries to be linked (Mac/Windows only)
+ EXTRA_LIBS = ../stlbase$(DLL)
</ins></span></pre></div>
<a id="trunkdportspurepurestllibfilespatchtr1supportdiff"></a>
<div class="addfile"><h4>Added: trunk/dports/pure/pure-stllib/files/patch-tr1-support.diff (0 => 125807)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,114 @@
</span><ins>+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&lt;pure_expr*,pure_expr*&gt; x,
++                    pair&lt;pure_expr*,pure_expr*&gt; y)
++{
++  return same(x.second, y.second);
++}
++
++#include &lt;functional&gt;
++#include &lt;tr1/tuple&gt;
++
++template&lt;class ForwardIterator1, class ForwardIterator2, class BinaryPredicate&gt;
++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 &amp;x, pxhmap &amp;y)
++{
++  if (&amp;x == &amp;y) return true;
++  if (x.size() != y.size()) return false;
++  for (pxhmap::iterator it = x.begin(); it != x.end(); ) {
++    pair&lt;pxhmap::iterator, pxhmap::iterator&gt;
++      r1 = x.equal_range(it-&gt;first),
++      r2 = y.equal_range(it-&gt;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,&amp;shp1) || !get_shp(pxshp2,&amp;shp2) ) bad_argument();
++#ifdef HAVE_TR1
++  return pxhmequal(shp1-&gt;hm, shp2-&gt;hm);
++#else
+   return shp1-&gt;hm == shp2-&gt;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 &lt;iostream&gt;
+ #include &lt;utility&gt;
++
++/* 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 &lt;tr1/unordered_map&gt;
++using namespace std;
++using namespace std::tr1;
++#else
+ #include &lt;unordered_map&gt;
++using namespace std;
++#endif
++
+ #include &quot;stlbase.hpp&quot;

+ 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&lt;px*,px*,px_hash,px_same&gt; pxhmap;
++typedef unordered_map&lt;px*,px*,px_hash,px_same&gt; pxhmap;
+ typedef pxhmap::iterator pxhmapi;

+ struct stlhmap {
</ins></span></pre>
</div>
</div>

</body>
</html>