-
Notifications
You must be signed in to change notification settings - Fork 1
/
mpi.setup
52 lines (41 loc) · 1.46 KB
/
mpi.setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
;; -*- 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 <mpi.h>"
(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 <mpi.h>" "-lmpi" ""))
(mpi-test ("#include <mpi.h>" "-lmpi" "-I/usr/include/mpi"))
(mpi-test ("#include <mpi.h>" "-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 -O -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 2.1)
))