forked from choderalab/ambermini
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·195 lines (155 loc) · 5.8 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/usr/bin/env python
from __future__ import with_statement
import os, sys
from distutils.spawn import find_executable
from optparse import OptionParser
on_win = bool(sys.platform == 'win32')
CONFIG_H = """\
# Amber configuration file, created with: %(command)s
###############################################################################
# (1) Location of the installation
BASEDIR=%(basedir)s
BINDIR=%(basedir)s/bin
LIBDIR=%(basedir)s/lib
INCDIR=%(basedir)s/include
DATDIR=%(basedir)s/dat
###############################################################################
# (2) If you want NAB to search additional libraries by default, add them
# to the FLIBS variable here. (External libraries can also be linked into
# NAB programs simply by including them on the command line; libraries
# included in FLIBS are always searched.)
FLIBS= -L../lib -larpack -llapack -lblas -lgfortran -w
FLIBSF= -L../lib -larpack -llapack -lblas
###############################################################################
# (3) Modify any of the following if you need to change, e.g. to use gcc
# rather than cc, etc.
SHELL=%(shell)s
# Set the C compiler, etc.
# The configure script should be fine, but if you need to hand-edit,
# here is some info:
# Example: CC-->gcc; LEX-->flex; YACC-->yacc (built in byacc)
# Note: If your lexer is "really" flex, you need to set
# LEX=flex below. For example, on some distributions,
# /usr/bin/lex is really just a pointer to /usr/bin/flex,
# so LEX=flex is necessary. In general, gcc seems to need flex.
# The compiler flags CFLAGS and CXXFLAGS should always be used.
# By contrast, *OPTFLAGS and *NOOPTFLAGS will only be used with
# certain files, and usually at compile-time but not link-time.
# Where *OPTFLAGS and *NOOPTFLAGS are requested (in Makefiles,
# makedepend and depend), they should come before CFLAGS or
# CXXFLAGS; this allows the user to override *OPTFLAGS and
# *NOOPTFLAGS using the BUILDFLAGS variable.
# AMBERBUILDFLAGS provides a hook into all stages of the build process.
# It can be used to build debug versions, invoke special features, etc.
# Example: make AMBERBUILDFLAGS='-O0 -g' sander
#
CC=%(cc)s
CFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
CNOOPTFLAGS=
COPTFLAGS=%(copt)s
CXX=%(cxx)s
CPLUSPLUS=%(cxx)s
CXXFLAGS=
CXXNOOPTFLAGS=
CXXOPTFLAGS=%(cxxopt)s
LEX= flex
YACC= %(yacc)s
AR= ar rv
M4= m4
RANLIB=ranlib
MKDIR = %(mkdir)s
RM = %(rm)s
# Set the C-preprocessor. Code for a small preprocessor is in
# ucpp-1.3; it gets installed as $(BINDIR)/ucpp;
CPP=ucpp -l
# These variables control whether we will use compiled versions of BLAS
# and LAPACK (which are generally slower), or whether those libraries are
# already available (presumably in an optimized form).
LAPACK=install
BLAS=install
F2C=skip
# These variables determine whether builtin versions of certain components
# can be used, or whether we need to compile our own versions.
UCPP=install
C9XCOMPLEX=skip
# For Windows/cygwin, set SFX to ".exe"; for Unix/Linux leave it empty:
# Set OBJSFX to ".obj" instead of ".o" on Windows:
SFX=%(sfx)s
OSFX=.o
MV=mv
RM=rm
CP=cp
# Information about Fortran compilation:
FC=%(fc)s
FFLAGS= $(LOCALFLAGS) $(CUSTOMBUILDFLAGS) -I$(INCDIR) $(NETCDFINC) $(AMBERBUILDFLAGS)
FNOOPTFLAGS= -O0
FOPTFLAGS= %(fcopt)s
AMBERFFLAGS=$(AMBERBUILDFLAGS)
FREEFORMAT_FLAG= -ffree-form
LM=-lm
FPP=cpp -traditional -P
FPPFLAGS= -cpp -DBINTRAJ -DEMIL $(CUSTOMBUILDFLAGS) $(AMBERBUILDFLAGS)
AMBERFPPFLAGS=$(AMBERBUILDFLAGS)
FCREAL8=-fdefault-real-8
NOFORTRANMAIN=-lgfortran -w
XHOME= /usr
XLIBS= -L/usr/lib64 -L/usr/lib
MAKE_XLEAP=skip_xleap
PREFIX=%(prefix)s
"""
def which(prog):
""" Determine if a program exists """
def is_exe(fname):
return os.path.exists(fname) and os.access(fname, os.X_OK)
fpath, fname = os.path.split(prog)
if fpath:
if is_exe(prog): return prog
for path in os.environ['PATH'].split(os.pathsep):
exe_file = os.path.join(path, prog)
if is_exe(exe_file):
return exe_file
return None
# Get the working directory
cwd = os.path.abspath(os.path.dirname(sys.argv[0]))
options = dict(basedir=cwd, copt='-O3', cxxopt='-O3', fcopt='-O3', mathlib='')
parser = OptionParser()
parser.add_option('--prefix', dest='prefix', default='/usr/local',
help='Directory to install programs and files to.')
parser.add_option('--yacc', dest='yacc', default=None,
help='Which YACC implementation to use. Looks for byacc '
'first then looks for bison or yacc if not given')
parser.add_option('--cc', dest='cc', default='gcc',
help='Path to C compiler (default=gcc)')
parser.add_option('--cxx', dest='cxx', default='g++',
help='Path to C++ compiler (default=g++)')
parser.add_option('--fc', dest='fc', default='gfortran',
help='Path to fortran compiler (default=gfortran)')
opt, arg = parser.parse_args()
if opt.yacc is not None:
myyacc = opt.yacc
else:
yaccs = [which('byacc'), which('bison'), which('yacc')]
myyacc = None
for yacc in yaccs:
if yacc is not None:
myyacc = yacc
break
if myyacc is None:
sys.exit('Could not find a YACC-compatible parser generator!')
options['cc'] = opt.cc
options['cxx'] = opt.cxx
options['fc'] = opt.fc
options['prefix'] = os.path.abspath(opt.prefix)
options['yacc'] = myyacc
options['command'] = ' '.join(sys.argv)
options['mkdir'] = find_executable('mkdir')
options['rm'] = find_executable('rm')
options['sfx'] = '.exe' if on_win else ''
if on_win:
options['shell'] = 'C:/Windows/System32/cmd.exe'
else:
options['shell'] = '/bin/sh'
if myyacc.endswith('bison'):
options['yacc'] += ' -y'
with open(os.path.join(cwd, 'config.h'), 'w') as f:
f.write(CONFIG_H % options)