| 2047 | # add default compiler variant if appropriate |
| 2048 | proc compiler_setup {args} { |
| 2049 | |
| 2050 | # build database of gcc 4{4..7} compiler attributes |
| 2051 | foreach v {4 5 6 7} { |
| 2052 | set db(gcc4$v,variant) "gcc4$v" |
| 2053 | set db(gcc4$v,compiler) "macports-gcc-4.$v" |
| 2054 | set db(gcc4$v,descrip) "MacPorts gcc 4.$v" |
| 2055 | set db(gcc4$v,depends) port:gcc4$v |
| 2056 | set db(gcc4$v,flags) { |
| 2057 | {{"-PIC"} {"-fPIC"}} |
| 2058 | } |
| 2059 | } |
| 2060 | |
| 2061 | set db(clang,variant) clang |
| 2062 | set db(clang,compiler) clang |
| 2063 | set db(clang,descrip) "Mac OS X clang" |
| 2064 | set db(clang,depends) bin:clang:clang |
| 2065 | set db(clang,flags) { |
| 2066 | {{"-PIC"} {"-fPIC"}} |
| 2067 | } |
| 2068 | |
| 2069 | set db(llvm,variant) llvm |
| 2070 | set db(llvm,compiler) llvm-gcc-4.2 |
| 2071 | set db(llvm,descrip) "Mac OS X llvm-gcc 4.2" |
| 2072 | set db(llvm,depends) bin:llvm-gcc-4.2:llvm-gcc42 |
| 2073 | set db(llvm,flags) { |
| 2074 | {{"-fPIC"} {"-PIC"}} |
| 2075 | } |
| 2076 | |
| 2077 | set db(system_gcc,variant) system_gcc |
| 2078 | set db(system_gcc,compiler) gcc-4.2 |
| 2079 | set db(system_gcc,descrip) "Mac OS X gcc 4.2" |
| 2080 | set db(system_gcc,depends) bin:gcc-4.2:llvm-gcc42 |
| 2081 | set db(system_gcc,flags) { |
| 2082 | {{"-fPIC"} {"-PIC"}} |
| 2083 | } |
| 2084 | |
| 2085 | set variants {} |
| 2086 | foreach name [array names db *,variant] { |
| 2087 | lappend variants $db($name) |
| 2088 | } |
| 2089 | |
| 2090 | foreach variant $variants { |
| 2091 | if {[variant_exists $variant]} { |
| 2092 | ui_debug "$variant variant already exists, so not adding the default one" |
| 2093 | } else { |
| 2094 | set i [lsearch -exact $variants $variant] |
| 2095 | set c [lreplace $variants $i $i] |
| 2096 | |
| 2097 | # for each pair of flags (old,new), build a string of if statements to replace old with new |
| 2098 | set f "" |
| 2099 | foreach flag $db($variant,flags) { |
| 2100 | foreach {old new} $flag { |
| 2101 | append f [subst { |
| 2102 | if {\[string first $old \${configure.cflags}\] > -1} { |
| 2103 | configure.cflags-delete $old |
| 2104 | configure.cflags-append $new |
| 2105 | } |
| 2106 | if {\[string first $old \${configure.cxxflags}\] > -1} { |
| 2107 | configure.cxxflags-delete $old |
| 2108 | configure.cxxflags-append $new |
| 2109 | } |
| 2110 | }] |
| 2111 | } |
| 2112 | } |
| 2113 | |
| 2114 | eval [subst { |
| 2115 | variant ${variant} description {Build using the $db($variant,descrip) compiler} conflicts $c { |
| 2116 | depends_lib-append $db($variant,depends) |
| 2117 | configure.compiler $db($variant,compiler) |
| 2118 | |
| 2119 | $f |
| 2120 | } |
| 2121 | }] |
| 2122 | } |
| 2123 | } |
| 2124 | } |
| 2125 | |