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