Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 1 | licenses(["notice"]) |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 2 | |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 3 | load("@//tools/build_rules:fortran.bzl", "f2c_copts") |
Brian Silverman | 1720b7a | 2018-09-02 17:53:46 -0700 | [diff] [blame] | 4 | load("@//tools/build_rules:select.bzl", "compiler_select") |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 5 | |
| 6 | genrule( |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 7 | name = "create_sysdep1", |
| 8 | srcs = ["F2CLIBS/libf2c/sysdep1.h0"], |
| 9 | outs = ["extra_includes/sysdep1.h"], |
| 10 | cmd = "cp $< $@", |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 11 | ) |
| 12 | |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 13 | _xerbla_patch = """ |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 14 | --- xerbla.c 2018-02-19 19:58:03.685420156 -0500 |
| 15 | +++ xerbla.c 2018-02-19 19:59:02.993259128 -0500 |
| 16 | @@ -55,7 +55,7 @@ static integer c__1 = 1; |
| 17 | /* .. */ |
| 18 | /* .. Executable Statements .. */ |
| 19 | |
| 20 | - printf("** On entry to %6s, parameter number %2i had an illegal value\\n", |
| 21 | + printf("** On entry to %6s, parameter number %2li had an illegal value\\n", |
| 22 | \t\tsrname, *info); |
| 23 | |
| 24 | |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 25 | """ |
| 26 | |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 27 | genrule( |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 28 | name = "patch_xerbla", |
| 29 | srcs = ["SRC/xerbla.c"], |
| 30 | outs = ["patched_xerbla.c"], |
| 31 | cmd = "\n".join([ |
| 32 | "cp $< $@", |
| 33 | "$(location @patch) $@ - <<END", |
| 34 | _xerbla_patch, |
| 35 | "END", |
| 36 | ]), |
| 37 | tools = ["@patch"], |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 38 | ) |
| 39 | |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 40 | _err_patch = """ |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 41 | --- err.c 2018-02-19 20:06:40.532033141 -0500 |
| 42 | +++ err.c 2018-02-19 20:10:25.907439219 -0500 |
| 43 | @@ -164,8 +164,10 @@ f__fatal(int n, const char *s) |
| 44 | \tif (f__curunit) { |
| 45 | \t\tfprintf(stderr,"apparent state: unit %d ", |
| 46 | \t\t\t(int)(f__curunit-f__units)); |
| 47 | -\t\tfprintf(stderr, f__curunit->ufnm ? "named %s\\n" : "(unnamed)\\n", |
| 48 | -\t\t\tf__curunit->ufnm); |
| 49 | +\t\tif (f__curunit->ufnm) |
| 50 | +\t\t\tfprintf(stderr, "named %s\\n", f__curunit->ufnm); |
| 51 | +\t\telse |
| 52 | +\t\t\tfprintf(stderr, "(unnamed)\\n"); |
| 53 | \t\t} |
| 54 | \telse |
| 55 | \t\tfprintf(stderr,"apparent state: internal I/O\\n"); |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 56 | """ |
| 57 | |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 58 | genrule( |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 59 | name = "patch_err", |
| 60 | srcs = ["F2CLIBS/libf2c/err.c"], |
| 61 | outs = ["patched_err.c"], |
| 62 | cmd = "\n".join([ |
| 63 | "cp $< $@", |
| 64 | "$(location @patch) $@ - <<END", |
| 65 | _err_patch, |
| 66 | "END", |
| 67 | ]), |
| 68 | tools = ["@patch"], |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 69 | ) |
| 70 | |
| 71 | cc_library( |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 72 | name = "clapack", |
| 73 | srcs = glob( |
| 74 | include = [ |
| 75 | "SRC/*.c", |
| 76 | "BLAS/SRC/*.c", |
| 77 | ], |
| 78 | exclude = [ |
| 79 | # These are duplicated in SRC (with the ones in SRC a bit more cleaned up). |
| 80 | "BLAS/SRC/xerbla.c", |
| 81 | "BLAS/SRC/xerbla_array.c", |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 82 | |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 83 | # We need to use a patched version of this. |
| 84 | "SRC/xerbla.c", |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 85 | |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 86 | # Files requiring XBLAS (extended precision), which we don't have. |
| 87 | "SRC/sgesvxx.c", |
| 88 | "SRC/sgerfsx.c", |
| 89 | "SRC/sla_gerfsx_extended.c", |
| 90 | "SRC/sla_geamv.c", |
| 91 | "SRC/sla_gercond.c", |
| 92 | "SRC/sla_gerpvgrw.c", |
| 93 | "SRC/ssysvxx.c", |
| 94 | "SRC/ssyrfsx.c", |
| 95 | "SRC/sla_syrfsx_extended.c", |
| 96 | "SRC/sla_syamv.c", |
| 97 | "SRC/sla_syrcond.c", |
| 98 | "SRC/sla_syrpvgrw.c", |
| 99 | "SRC/sposvxx.c", |
| 100 | "SRC/sporfsx.c", |
| 101 | "SRC/sla_porfsx_extended.c", |
| 102 | "SRC/sla_porcond.c", |
| 103 | "SRC/sla_porpvgrw.c", |
| 104 | "SRC/sgbsvxx.c", |
| 105 | "SRC/sgbrfsx.c", |
| 106 | "SRC/sla_gbrfsx_extended.c", |
| 107 | "SRC/sla_gbamv.c", |
| 108 | "SRC/sla_gbrcond.c", |
| 109 | "SRC/sla_gbrpvgrw.c", |
| 110 | "SRC/sla_lin_berr.c", |
| 111 | "SRC/slarscl2.c", |
| 112 | "SRC/slascl2.c", |
| 113 | "SRC/sla_wwaddw.c", |
| 114 | "SRC/cgesvxx.c", |
| 115 | "SRC/cgerfsx.c", |
| 116 | "SRC/cla_gerfsx_extended.c", |
| 117 | "SRC/cla_geamv.c", |
| 118 | "SRC/cla_gercond_c.c", |
| 119 | "SRC/cla_gercond_x.c", |
| 120 | "SRC/cla_gerpvgrw.c", |
| 121 | "SRC/csysvxx.c", |
| 122 | "SRC/csyrfsx.c", |
| 123 | "SRC/cla_syrfsx_extended.c", |
| 124 | "SRC/cla_syamv.c", |
| 125 | "SRC/cla_syrcond_c.c", |
| 126 | "SRC/cla_syrcond_x.c", |
| 127 | "SRC/cla_syrpvgrw.c", |
| 128 | "SRC/cposvxx.c", |
| 129 | "SRC/cporfsx.c", |
| 130 | "SRC/cla_porfsx_extended.c", |
| 131 | "SRC/cla_porcond_c.c", |
| 132 | "SRC/cla_porcond_x.c", |
| 133 | "SRC/cla_porpvgrw.c", |
| 134 | "SRC/cgbsvxx.c", |
| 135 | "SRC/cgbrfsx.c", |
| 136 | "SRC/cla_gbrfsx_extended.c", |
| 137 | "SRC/cla_gbamv.c", |
| 138 | "SRC/cla_gbrcond_c.c", |
| 139 | "SRC/cla_gbrcond_x.c", |
| 140 | "SRC/cla_gbrpvgrw.c", |
| 141 | "SRC/chesvxx.c", |
| 142 | "SRC/cherfsx.c", |
| 143 | "SRC/cla_herfsx_extended.c", |
| 144 | "SRC/cla_heamv.c", |
| 145 | "SRC/cla_hercond_c.c", |
| 146 | "SRC/cla_hercond_x.c", |
| 147 | "SRC/cla_herpvgrw.c", |
| 148 | "SRC/cla_lin_berr.c", |
| 149 | "SRC/clarscl2.c", |
| 150 | "SRC/clascl2.c", |
| 151 | "SRC/cla_wwaddw.c", |
| 152 | "SRC/dgesvxx.c", |
| 153 | "SRC/dgerfsx.c", |
| 154 | "SRC/dla_gerfsx_extended.c", |
| 155 | "SRC/dla_geamv.c", |
| 156 | "SRC/dla_gercond.c", |
| 157 | "SRC/dla_gerpvgrw.c", |
| 158 | "SRC/dsysvxx.c", |
| 159 | "SRC/dsyrfsx.c", |
| 160 | "SRC/dla_syrfsx_extended.c", |
| 161 | "SRC/dla_syamv.c", |
| 162 | "SRC/dla_syrcond.c", |
| 163 | "SRC/dla_syrpvgrw.c", |
| 164 | "SRC/dposvxx.c", |
| 165 | "SRC/dporfsx.c", |
| 166 | "SRC/dla_porfsx_extended.c", |
| 167 | "SRC/dla_porcond.c", |
| 168 | "SRC/dla_porpvgrw.c", |
| 169 | "SRC/dgbsvxx.c", |
| 170 | "SRC/dgbrfsx.c", |
| 171 | "SRC/dla_gbrfsx_extended.c", |
| 172 | "SRC/dla_gbamv.c", |
| 173 | "SRC/dla_gbrcond.c", |
| 174 | "SRC/dla_gbrpvgrw.c", |
| 175 | "SRC/dla_lin_berr.c", |
| 176 | "SRC/dlarscl2.c", |
| 177 | "SRC/dlascl2.c", |
| 178 | "SRC/dla_wwaddw.c", |
| 179 | "SRC/zgesvxx.c", |
| 180 | "SRC/zgerfsx.c", |
| 181 | "SRC/zla_gerfsx_extended.c", |
| 182 | "SRC/zla_geamv.c", |
| 183 | "SRC/zla_gercond_c.c", |
| 184 | "SRC/zla_gercond_x.c", |
| 185 | "SRC/zla_gerpvgrw.c", |
| 186 | "SRC/zsysvxx.c", |
| 187 | "SRC/zsyrfsx.c", |
| 188 | "SRC/zla_syrfsx_extended.c", |
| 189 | "SRC/zla_syamv.c", |
| 190 | "SRC/zla_syrcond_c.c", |
| 191 | "SRC/zla_syrcond_x.c", |
| 192 | "SRC/zla_syrpvgrw.c", |
| 193 | "SRC/zposvxx.c", |
| 194 | "SRC/zporfsx.c", |
| 195 | "SRC/zla_porfsx_extended.c", |
| 196 | "SRC/zla_porcond_c.c", |
| 197 | "SRC/zla_porcond_x.c", |
| 198 | "SRC/zla_porpvgrw.c", |
| 199 | "SRC/zgbsvxx.c", |
| 200 | "SRC/zgbrfsx.c", |
| 201 | "SRC/zla_gbrfsx_extended.c", |
| 202 | "SRC/zla_gbamv.c", |
| 203 | "SRC/zla_gbrcond_c.c", |
| 204 | "SRC/zla_gbrcond_x.c", |
| 205 | "SRC/zla_gbrpvgrw.c", |
| 206 | "SRC/zhesvxx.c", |
| 207 | "SRC/zherfsx.c", |
| 208 | "SRC/zla_herfsx_extended.c", |
| 209 | "SRC/zla_heamv.c", |
| 210 | "SRC/zla_hercond_c.c", |
| 211 | "SRC/zla_hercond_x.c", |
| 212 | "SRC/zla_herpvgrw.c", |
| 213 | "SRC/zla_lin_berr.c", |
| 214 | "SRC/zlarscl2.c", |
| 215 | "SRC/zlascl2.c", |
| 216 | "SRC/zla_wwaddw.c", |
| 217 | ], |
| 218 | ) + [ |
| 219 | "INSTALL/dlamch.c", |
| 220 | "INSTALL/slamch.c", |
| 221 | "patched_xerbla.c", |
| 222 | "patched_err.c", |
| 223 | "F2CLIBS/libf2c/s_cat.c", |
| 224 | "F2CLIBS/libf2c/d_lg10.c", |
| 225 | "F2CLIBS/libf2c/d_sign.c", |
| 226 | "F2CLIBS/libf2c/i_dnnt.c", |
| 227 | "F2CLIBS/libf2c/pow_di.c", |
| 228 | "F2CLIBS/libf2c/s_copy.c", |
| 229 | "F2CLIBS/libf2c/s_cmp.c", |
| 230 | "F2CLIBS/libf2c/i_nint.c", |
| 231 | "F2CLIBS/libf2c/f77_aloc.c", |
| 232 | "F2CLIBS/libf2c/exit_.c", |
| 233 | "F2CLIBS/libf2c/r_cnjg.c", |
| 234 | "F2CLIBS/libf2c/c_abs.c", |
| 235 | "F2CLIBS/libf2c/r_imag.c", |
| 236 | "F2CLIBS/libf2c/c_div.c", |
| 237 | "F2CLIBS/libf2c/c_exp.c", |
| 238 | "F2CLIBS/libf2c/d_imag.c", |
| 239 | "F2CLIBS/libf2c/r_sign.c", |
| 240 | "F2CLIBS/libf2c/d_cnjg.c", |
| 241 | "F2CLIBS/libf2c/z_abs.c", |
| 242 | "F2CLIBS/libf2c/z_div.c", |
| 243 | "F2CLIBS/libf2c/z_exp.c", |
| 244 | "F2CLIBS/libf2c/z_sqrt.c", |
| 245 | "F2CLIBS/libf2c/pow_dd.c", |
| 246 | "F2CLIBS/libf2c/pow_ri.c", |
| 247 | "F2CLIBS/libf2c/pow_ci.c", |
| 248 | "F2CLIBS/libf2c/pow_ii.c", |
| 249 | "F2CLIBS/libf2c/pow_zi.c", |
| 250 | "F2CLIBS/libf2c/c_sqrt.c", |
| 251 | "F2CLIBS/libf2c/r_lg10.c", |
| 252 | "F2CLIBS/libf2c/i_len.c", |
| 253 | "F2CLIBS/libf2c/cabs.c", |
| 254 | "F2CLIBS/libf2c/sig_die.c", |
| 255 | "F2CLIBS/libf2c/close.c", |
| 256 | "F2CLIBS/libf2c/open.c", |
| 257 | "F2CLIBS/libf2c/endfile.c", |
| 258 | "F2CLIBS/libf2c/util.c", |
| 259 | "F2CLIBS/libf2c/iio.c", |
| 260 | "F2CLIBS/libf2c/fmt.c", |
| 261 | "F2CLIBS/libf2c/rdfmt.c", |
| 262 | "F2CLIBS/libf2c/wrtfmt.c", |
| 263 | #'F2CLIBS/libf2c/ctype.c', |
| 264 | "F2CLIBS/libf2c/wref.c", |
| 265 | "F2CLIBS/libf2c/fmtlib.c", |
| 266 | "F2CLIBS/libf2c/lread.c", |
| 267 | "F2CLIBS/libf2c/rsfe.c", |
| 268 | "F2CLIBS/libf2c/sfe.c", |
| 269 | "F2CLIBS/libf2c/dolio.c", |
| 270 | "F2CLIBS/libf2c/wsfe.c", |
| 271 | "extra_includes/sysdep1.h", |
| 272 | ], |
| 273 | hdrs = glob( |
| 274 | [ |
| 275 | "INCLUDE/*.h", |
| 276 | "F2CLIBS/libf2c/*.h", |
| 277 | ], |
| 278 | exclude = ["F2CLIBS/libf2c/ctype.h"], |
| 279 | ), |
| 280 | copts = f2c_copts + [ |
| 281 | "-Wno-sign-compare", |
| 282 | "-Wno-cast-qual", |
| 283 | "-Wno-cast-align", |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 284 | |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 285 | # Some files don't #include system headers when they should. sysdep1.h |
| 286 | # messes with feature test macros, so it always has to come first. |
| 287 | "-include", |
| 288 | "sysdep1.h", |
| 289 | "-include", |
| 290 | "stdio.h", |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 291 | |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 292 | # Don't mangle the names of all the BLAS symbols, because slicot needs to |
| 293 | # call them directly. |
| 294 | "-DNO_BLAS_WRAP", |
Brian Silverman | 1720b7a | 2018-09-02 17:53:46 -0700 | [diff] [blame] | 295 | ] + compiler_select({ |
| 296 | "clang": [ |
| 297 | "-Wno-self-assign", |
| 298 | ], |
| 299 | "gcc": [ |
| 300 | "-Wno-discarded-qualifiers", |
| 301 | ], |
| 302 | }), |
Brian Silverman | 7bda621 | 2018-08-05 11:42:11 -0700 | [diff] [blame] | 303 | includes = [ |
| 304 | "F2CLIBS/libf2c", |
| 305 | "INCLUDE", |
| 306 | "extra_includes", |
| 307 | ], |
| 308 | visibility = ["//visibility:public"], |
Brian Silverman | d3ad165 | 2018-02-18 22:16:29 -0500 | [diff] [blame] | 309 | ) |