;; -*- Hen -*- (define (dynld-name fn) (make-pathname #f fn ##sys#load-dynamic-extension)) (define (mpi-try-compile header ldflags cppflags) (and (try-compile (string-append header "\n" "int main(int argc, char **argv) { MPI_Init(&argc, &argv); return 0; }\n") ldflags: ldflags cflags: cppflags ) (cons ldflags cppflags))) (define-syntax mpi-test (syntax-rules () ((_ (flags ...)) (condition-case (mpi-try-compile flags ...) (t () #f))))) (define mpi-dir (get-environment-variable "MPI_DIR")) (define ld+cpp-options (or (and mpi-dir (mpi-test ("#include " (sprintf "-lmpi -L~S" (make-pathname mpi-dir "lib") ) (sprintf "-I~S -L~S" (make-pathname mpi-dir "include") (make-pathname mpi-dir "lib") )) )) (mpi-test ("#include " "-lmpi" "")) (mpi-test ("#include " "-lmpi" "-I/usr/include/mpi")) (mpi-test ("#include " "-lmpi" "-I/usr/lib/openmpi/include")) (error "unable to figure out location of MPI library; try setting environment variable MPI_DIR to the proper location"))) (compile -S -O2 -d0 -I. -s mpi.scm -j mpi -L "\"" ,(car ld+cpp-options) "\"" -C "\"" ,(cdr ld+cpp-options) "\"") (compile -O2 -d0 -s mpi.import.scm) (install-extension ; Name of your extension: 'mpi ; Files to install for your extension: `(,(dynld-name "mpi") ,(dynld-name "mpi.import") ) ; Assoc list with properties for your extension: `((version 1.17) ))