Ticket #33890: multiplecompilers.patch

File multiplecompilers.patch, 7.0 KB (added by seanfarley (Sean Farley), 13 years ago)
Line 
1[0;32m89821[0m:[0;32m9b0f78eae55a[0m portgroup: add multiplecompilers-1.0 to generate default compiler variants and deal with fortran dependency [1;35m[0m [0;35m[0m
2[1;29m(8 hours ago by Sean Farley)[0m
3
4[0;32mA dports/_resources/port1.0/group/multiplecompilers-1.0.tcl[0m
5
6[0;0mdiff --git a/dports/_resources/port1.0/group/multiplecompilers-1.0.tcl b/dports/_resources/port1.0/group/multiplecompilers-1.0.tcl[0m
7[0;36mnew file mode 100644[0m
8[0;31m--- /dev/null[0m
9[0;32m+++ b/dports/_resources/port1.0/group/multiplecompilers-1.0.tcl[0m
10[0;33;1m@@ -0,0 +1,136 @@[0m
11[0;32m+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4[0m
12[0;32m+# $Id$[0m
13[0;32m+#[0m
14[0;32m+# Copyright (c) 2012 The MacPorts Project[0m
15[0;32m+# All rights reserved.[0m
16[0;32m+#[0m
17[0;32m+# Redistribution and use in source and binary forms, with or without[0m
18[0;32m+# modification, are permitted provided that the following conditions are[0m
19[0;32m+# met:[0m
20[0;32m+#[0m
21[0;32m+# 1. Redistributions of source code must retain the above copyright[0m
22[0;32m+#    notice, this list of conditions and the following disclaimer.[0m
23[0;32m+# 2. Redistributions in binary form must reproduce the above copyright[0m
24[0;32m+#    notice, this list of conditions and the following disclaimer in the[0m
25[0;32m+#    documentation and/or other materials provided with the distribution.[0m
26[0;32m+# 3. Neither the name of The MacPorts Project nor the names of its[0m
27[0;32m+#    contributors may be used to endorse or promote products derived from[0m
28[0;32m+#    this software without specific prior written permission.[0m
29[0;32m+#[0m
30[0;32m+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS[0m
31[0;32m+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT[0m
32[0;32m+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR[0m
33[0;32m+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT[0m
34[0;32m+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,[0m
35[0;32m+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT[0m
36[0;32m+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,[0m
37[0;32m+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY[0m
38[0;32m+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT[0m
39[0;32m+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE[0m
40[0;32m+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.[0m
41[0;32m+#[0m
42[0;32m+#[0m
43[0;32m+# This PortGroup sets up default variants for projects that want m[0m
44[0;32m+#[0m
45[0;32m+# Usage:[0m
46[0;32m+#[0m
47[0;32m+#   PortGroup               multiplecompilers 1.0[0m
48[0;32m+[0m
49[0;32m+options multiplecompilers.variants multiplecompilers.gcc_variants[0m
50[0;32m+default multiplecompilers.variants {}[0m
51[0;32m+default multiplecompilers.gcc_variants {}[0m
52[0;32m+[0m
53[0;32m+# build database of gcc 4{4..7} compiler attributes[0m
54[0;32m+set gcc_versions {4 5 6 7 8}[0m
55[0;32m+foreach v ${gcc_versions} {[0m
56[0;32m+    lappend multiplecompilers.gcc_variants gcc4$v[0m
57[0;32m+    set db(gcc4$v,variant)  "gcc4$v"[0m
58[0;32m+    set db(gcc4$v,compiler) "macports-gcc-4.$v"[0m
59[0;32m+    set db(gcc4$v,descrip)  "MacPorts gcc 4.$v"[0m
60[0;32m+    set db(gcc4$v,depends)  port:gcc4$v[0m
61[0;32m+    set db(gcc4$v,dependsd) "bin:gfortran:gfortran port:g95"[0m
62[0;32m+    set db(gcc4$v,conflict) "gfortran g95"[0m
63[0;32m+    set db(gcc4$v,flags)    {[0m
64[0;32m+        {{"-PIC"} {"-fPIC"}}[0m
65[0;32m+    }[0m
66[0;32m+}[0m
67[0;32m+[0m
68[0;32m+set db(clang,variant)  clang[0m
69[0;32m+set db(clang,compiler) clang[0m
70[0;32m+set db(clang,descrip)  "Mac OS X clang"[0m
71[0;32m+set db(clang,depends)  bin:clang:clang[0m
72[0;32m+set db(clang,dependsd) ""[0m
73[0;32m+set db(clang,conflict) ""[0m
74[0;32m+set db(clang,flags)    {[0m
75[0;32m+    {{"-PIC"} {"-fPIC"}}[0m
76[0;32m+}[0m
77[0;32m+[0m
78[0;32m+set db(llvm,variant)  llvm[0m
79[0;32m+set db(llvm,compiler) llvm-gcc-4.2[0m
80[0;32m+set db(llvm,descrip)  "Mac OS X llvm-gcc 4.2"[0m
81[0;32m+set db(llvm,depends)  bin:llvm-gcc-4.2:llvm-gcc42[0m
82[0;32m+set db(llvm,dependsd) ""[0m
83[0;32m+set db(llvm,conflict) ""[0m
84[0;32m+set db(llvm,flags)    {[0m
85[0;32m+    {{"-fPIC"} {"-PIC"}}[0m
86[0;32m+}[0m
87[0;32m+[0m
88[0;32m+set db(system_gcc,variant)  system_gcc[0m
89[0;32m+set db(system_gcc,compiler) gcc-4.2[0m
90[0;32m+set db(system_gcc,descrip)  "Mac OS X gcc 4.2"[0m
91[0;32m+set db(system_gcc,depends)  bin:gcc-4.2:llvm-gcc42[0m
92[0;32m+set db(system_gcc,dependsd) ""[0m
93[0;32m+set db(system_gcc,conflict) ""[0m
94[0;32m+set db(system_gcc,flags)    {[0m
95[0;32m+    {{"-fPIC"} {"-PIC"}}[0m
96[0;32m+}[0m
97[0;32m+[0m
98[0;32m+foreach name [array names db *,variant] {[0m
99[0;32m+    lappend multiplecompilers.variants $db($name)[0m
100[0;32m+}[0m
101[0;32m+[0m
102[0;32m+foreach variant ${multiplecompilers.variants} {[0m
103[0;32m+    if {[variant_exists $variant]} {[0m
104[0;32m+        ui_debug "$variant variant already exists, so not adding the default one"[0m
105[0;32m+    } else {[0m
106[0;32m+        set i [lsearch -exact ${multiplecompilers.variants} $variant][0m
107[0;32m+        set c [lreplace ${multiplecompilers.variants} $i $i][0m
108[0;32m+[0m
109[0;32m+        # for each pair of flags (old,new), build a string of if statements to replace old with new[0m
110[0;32m+        set f ""[0m
111[0;32m+        foreach flag $db($variant,flags) {[0m
112[0;32m+            foreach {old new} $flag {[0m
113[0;32m+                append f [subst {[0m
114[0;32m+                    if {\[string first $old \${configure.cflags}\] > -1} {[0m
115[0;32m+                        configure.cflags-delete $old[0m
116[0;32m+                        configure.cflags-append $new[0m
117[0;32m+                    }[0m
118[0;32m+                    if {\[string first $old \${configure.cxxflags}\] > -1} {[0m
119[0;32m+                        configure.cxxflags-delete $old[0m
120[0;32m+                        configure.cxxflags-append $new[0m
121[0;32m+                    }[0m
122[0;32m+                }][0m
123[0;32m+            }[0m
124[0;32m+        }[0m
125[0;32m+[0m
126[0;32m+        eval [subst {[0m
127[0;32m+            variant ${variant} description {Build using the $db($variant,descrip) compiler} conflicts $c $db($variant,conflict) {[0m
128[0;32m+                depends_lib-append $db($variant,depends)[0m
129[0;32m+                depends_lib-delete $db($variant,dependsd)[0m
130[0;32m+                configure.compiler $db($variant,compiler)[0m
131[0;32m+[0m
132[0;32m+                $f[0m
133[0;32m+            }[0m
134[0;32m+        }][0m
135[0;32m+    }[0m
136[0;32m+}[0m
137[0;32m+[0m
138[0;32m+default_variants +clang[0m
139[0;32m+[0m
140[0;32m+foreach variant ${multiplecompilers.gcc_variants} {[0m
141[0;32m+    if {[ variant_isset $variant ]} {[0m
142[0;32m+        depends_lib-delete      bin:gfortran:gfortran[0m
143[0;32m+        depends_lib-delete      port:g95[0m
144[0;32m+        break[0m
145[0;32m+    }[0m
146[0;32m+}[0m
147