forked from xrf/talent-astro-proj2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·123 lines (105 loc) · 3.42 KB
/
configure
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env python
#
# This script uses `Makefile.in` to generate the actual Makefile.
#
import glob, os, shutil, subprocess, sys
import utils
def msum(actions):
exception = Exception("no actions")
for action in actions:
try:
return action()
except Exception as e:
exception = e
raise exception
def escape_apos(s):
return s.replace("'", '''"'"'"'"''')
def find_command(name, ds):
for d in ds:
if subprocess.call(["sh", "-c",
"command -v '{0}'".format(escape_apos(d))],
stdout=utils.DEV_NULL, stderr=utils.DEV_NULL) == 0:
print("using {1} as {0}".format(name, d))
return d
raise Exception("can't find {0}; tried: {1}".format(name, ds))
def find_dir(name, ds):
for d in ds:
if os.path.isfile(os.path.join(d, name)):
print("found {0} at {1}".format(name, d))
return d
raise Exception("can't find {0}; tried: {1}".format(name, ds))
def find_lib(name, *args, **kwargs):
try:
d = libs[name]
print("override: using {0} at {1}".format(name, d))
return d
except KeyError:
return msum(map(
lambda ext: lambda:
find_dir("lib" + name + ext, ds=common_lib_dirs, *args, **kwargs),
common_lib_exts
))
def find_include(name, *args, **kwargs):
try:
d = includes[name]
print("override: using {0} at {1}".format(name, d))
return d
except KeyError:
return find_dir(name, ds=common_include_dirs, *args, **kwargs)
fflags = ["-O3", "-Wall", "-Wno-unused-variable"]
optimize_native = True
includes = dict()
include_dirs = set()
libs = dict()
lib_dirs = set()
common_include_dirs = [
"/usr/include",
"/usr/local/include",
"/opt/local/include",
]
common_lib_dirs = [
"/usr/lib",
"/usr/local/lib",
"/opt/local/lib",
]
common_lib_exts = [".so", ".dylib", ".dll.a"]
try:
from configure_overrides import *
except ImportError:
pass
# detect compilers
fc = find_command("Fortran compiler", ["gfortran"]) # assume gfortran
fflags.extend("-I" + d for d in include_dirs)
wiki_url = "https://wikihost.nscl.msu.edu/talent/lib/exe/fetch.php?media="
make_vars = {
# fortran stuff
"FC": fc,
"FFLAGS": " ".join(fflags),
# default run directory
"RUN_DIR": "main",
# config for reducereaclib
"RRL_URL": wiki_url + "reducereaclib.tar.gz",
"RRL_ROOT": "dist/reducereaclib",
"RRL": "$(RRL_ROOT)/.cookie",
# config for xnet
"XNET_URL": wiki_url + "xnet_public.zip",
"XNET_DIR": "dist/xnet_public",
"XNET": "$(XNET_DIR)/.cookie",
"XNET_ROOT": "$(XNET_DIR)/branches/public",
# xnet-specific flags
"CMODE": "OPTIMIZE",
"MATRIX_SOLVER": "dense",
"R8": "-fdefault-real-8 -fdefault-double-8",
"OPT": "-O3 -ftree-vectorize",
"TRAP": "-fbacktrace -finit-real=nan",
"DEBUG": "-C -g -g -fbounds-check $(TRAP)",
"PROFILE": "-p -pg",
"MOD": "",
"EXTRA_LINK": "",
"LAPACK_LIBDIR": "-L" + find_lib("lapack"),
"LAPACK_LIBS": "-llapack",
}
lines = ["# note: this file is autogenerated\n.POSIX:"]
lines.extend("{0}={1}".format(k, v) for k, v in make_vars.items())
lines.append(utils.read_file("Makefile.in"))
utils.write_file("Makefile", "\n".join(lines))