(import (chicken base) (chicken format) (chicken process-context) srfi-13 compile-file) (define args (command-line-arguments)) (define (blas-try-compile header ldflags) (and (try-compile (string-append "#include " header "\n" "int main() { cblas_ddot(0, NULL, 0, NULL, 0); return 0; }\n") ldflags: ldflags verbose: #t) ldflags )) (define-syntax blas-test (syntax-rules () ((_ (flags ...)) (condition-case (blas-try-compile flags ...) (t () #f))))) (define ld-options (or (blas-test ("" "-lblas -lm")) (blas-test ("" "-lcblas -lm")) (blas-test ("" "-lgsl -lgslcblas -lm")) (blas-test ("" "-lcblas -lm")) (blas-test ("" "-lcblas -lm")) (blas-test ("" "-framework Accelerate")) (error "unable to figure out location of BLAS library"))) (define cmd (intersperse (append args (list (sprintf "-L \"~A\"" ld-options))) " ")) (system (string-concatenate cmd))