-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
223 lines (187 loc) · 5.05 KB
/
configure.ac
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#-------------------------------------------------------------------------------
AC_PREREQ(2.69)
AC_INIT([SNOPT-EXAMPLES],[7.7],[[email protected]],[snopt])
AC_CONFIG_SRCDIR([fortran/snmaina.f])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR([config/m4])
AC_PREFIX_DEFAULT([`pwd`])
user_FCFLAGS=${FCFLAGS}
user_CFLAGS=${CFLAGS}
user_CPPFLAGS=${CPPFLAGS}
user_CXXFLAGS=${CXXFLAGS}
user_LDFLAGS=${LDFLAGS}
# Libtool
LT_INIT
AC_SUBST([LIBTOOL_DEPS])
# Check compilers.
AC_PROG_FC([gfortran nagfor ifort])
AC_PROG_CC
AC_PROG_CXX
AC_FC_LIBRARY_LDFLAGS
AC_SUBST([FCLIBS])
AC_SEARCH_LIBS([pow], [m])
AC_SUBST([LIBS])
AC_FC_MODULE_OUTPUT_FLAG([],
[ case $FC in
*nagfor* ) FC_MODOUT="-mdir ";;
esac
])
AC_FC_MODULE_FLAG([],
[ case $FC in
*nagfor* ) FC_MODINC="-mdir ";;
esac
])
AC_SUBST(FC_MODOUT)
AC_SUBST(FC_MODINC)
AC_PROG_MAKE_SET
AC_SUBST([SET_MAKE])
dnl ----------------------------------------------------------------------------
AC_ARG_ENABLE([openmp],
[AS_HELP_STRING([--enable-openmp],
[enable OpenMP support (disabled by default)])],
[],
[OPENMP_FC_FLAGS=""; enable_openmp=no;])
if test x"${enable_openmp}" = xyes; then
AC_LANG_PUSH(Fortran)
AC_OPENMP
AC_LANG_POP(Fortran)
fi
AC_SUBST([OPENMP_FCFLAGS])
AC_SUBST([enable_openmp])
dnl ----------------------------------------------------------------------------
# SNOPT library
AC_MSG_CHECKING(for snopt)
AC_ARG_WITH([snopt],
[AS_HELP_STRING([--with-snopt="-L/path/to/snopt/lib -lsnopt7"],
[location of SNOPT library])],
[ snopt_lib="${withval}" ],
[ snopt_lib=${libdir} ] )
AC_ARG_WITH([snopt-cpp],
[AS_HELP_STRING([--with-snopt-cpp="-L/path/to/snopt/lib -lsnopt7_cpp"],
[location of SNOPT C++ library])],
[ snopt_lib="${withval}"; with_cpp=yes; ],
[] )
AC_MSG_RESULT(${snopt_lib})
AC_SUBST([snopt_lib])
AC_SUBST([with_cpp])
dnl ----------------------------------------------------------------------------
# BLAS library.
AC_ARG_WITH([blas],
[AS_HELP_STRING([--with-blas=<lib>], [use BLAS library <lib>])],
[with_blas=${withval} ], [ blas=no ] )
case $with_blas in
yes | "" | no) blas=no ;;
-* | */* | *.a | *.so | *.so.* | *.o)
blas=yes; BLAS_LIBS="$with_blas" ;;
matlab )
blas=yes; BLAS_LIBS="matlab" ;;
*)
blas=yes; BLAS_LIBS="-l$with_blas" ;;
esac
AC_SUBST([blas])
AC_SUBST([BLAS_LIBS])
dnl ----------------------------------------------------------------------------
AC_ARG_WITH([64],
[AS_HELP_STRING( [--with-64],
[64-bit integer support (default is 32-bit)]) ],
[ prec=64;
AC_MSG_NOTICE([64-bit integers enabled]) ], [])
AC_ARG_WITH([128],
[AS_HELP_STRING( [--with-128],
[quad-precision support (64-bit ints, 128-bit reals)]) ],
[ prec=128;
AC_MSG_NOTICE([quad-precision enabled (64-bit ints, 128-bit reals)]) ], [])
AC_ARG_WITH([debug],
[AS_HELP_STRING([--with-debug],
[Compile with debug flags])],
[DBGFLAG="-g"; OPTFLAG="";],
[OPTFLAG="-O"; DBGFLAG="";])
dnl ----------------------------------------------------------------------------
FCFLAGS="${user_FCFLAGS}"
CFLAGS="${user_CFLAGS}"
CXXFLAGS="${user_CXXFLAGS}"
LDFLAGS="${user_LDFLAGS}"
if test x"${prec}" == x; then
prec=32
fi
if test x"${prec}" = x64; then
PC_FLAGS="-DD64"
case "${FC}" in
*gfortran*)
PF_FLAGS="-fdefault-integer-8"
;;
*nagfor*)
PF_FLAGS="-i8"
;;
*ifort*)
PF_FLAGS="-i8"
;;
esac
elif test x"${prec}" = x128; then
PC_FLAGS=" -DD128"
case "${FC}" in
*gfortran*)
PF_FLAGS=" -fdefault-integer-8"
;;
*nagfor* )
PF_FLAGS=" -i8"
;;
*ifort* )
PF_FLAGS=" -i8"
;;
esac
fi
case "${FC}" in
*nagfor* )
PF_FLAGS+=" -w"
;;
esac
if test -z "${FCFLAGS}"; then
if test -z "${DBGFLAG}"; then
FCFLAGS="${OPTFLAG} ${PF_FLAGS}"
else
FCFLAGS="${DBGFLAG} ${PF_FLAGS}"
fi
else
FCFLAGS="${FCFLAGS} ${PF_FLAGS}"
fi
if test -z "${CFLAGS}"; then
if test -z "${DBGFLAG}"; then
CFLAGS="${OPTFLAG} ${PC_FLAGS}"
else
CFLAGS="${DBGFLAG} ${PC_FLAGS}"
fi
else
CFLAGS="${CFLAGS} ${PC_FLAGS}"
fi
if test -z "${CXXFLAGS}"; then
if test -z "${DBGFLAG}"; then
CXXFLAGS="${OPTFLAG}"
else
CXXFLAGS="${DBGFLAG}"
fi
fi
AC_SUBST([prec])
AC_SUBST([FCFLAGS])
AC_SUBST([CFLAGS])
AC_SUBST([CXXFLAGS])
dnl ----------------------------------------------------------------------------
AC_SUBST([enable_shared])
AC_SUBST([enable_static])
AC_OUTPUT([GNUmakefile])
echo ""
echo "SNOPT Examples:"
if test x"${with_cpp}" == xyes; then
echo " SNOPT C++ library ${snopt_lib}"
else
echo " SNOPT library ${snopt_lib}"
fi
echo ""
echo "To build all examples 'make' or 'make all'"
echo "To build Fortran examples 'make fortran'"
echo "To build C examples 'make c'"
if test x"${with_cpp}" == xyes; then
echo "To build C++ examples 'make cpp'"
fi
echo "To check the build 'make check'"
echo ""