-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
412 lines (353 loc) · 9.68 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.71])
AC_INIT([snptools],[1.0],[[email protected]])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CONFIG_HEADERS([config.h])
AX_PREFIX_CONFIG_H([./src/snptools_config.h])
AM_PATH_PYTHON([2])
dnl Initialize Libtool
LT_CONFIG_LTDL_DIR([libltdl])
LT_INIT([dlopen])
LTDL_INIT([recursive])
# Save previous compilation flags
CFLAGS_AUX=${CFLAGS}
CXXFLAGS_AUX=${CXXFLAGS}
# Checks for Python modules
AX_PYTHON_MODULE(mwparserfromhell,fatal,python)
AX_PYTHON_MODULE(wikitools,fatal,python)
AX_PYTHON_MODULE(nltk,fatal,python)
# Checks for programs.
AC_PATH_PROGS(PYTHON, python)
AC_PATH_PROGS(RSCRIPT, Rscript)
AC_PATH_PROGS(SPLIT, split)
AC_PATH_PROGS(SED, sed)
AC_PATH_PROGS(GREP, grep)
AC_PATH_PROGS(UNIQ, uniq)
AC_PATH_PROGS(HEAD, head)
AC_PATH_PROGS(TAIL, tail)
AC_PATH_PROGS(FIND, find)
AC_PATH_PROGS(LN, ln)
AC_PATH_PROGS(WC, wc)
AC_PATH_PROGS(BASENAME, basename)
AC_PATH_PROGS(DIRNAME, dirname)
AC_PATH_PROGS(MKTEMP, mktemp)
AC_PATH_PROGS(SSH, ssh)
AC_PATH_PROGS(QSUB, qsub)
AC_PATH_PROGS(QSTAT, qstat)
AC_PATH_PROGS(QRLS, qrls)
AC_PATH_PROGS(WGET, wget)
AC_PATH_PROGS(PANDOC, pandoc)
# BASH may already be set in the shell, if the admin then changes the
# the /bin/sh symlink to a non-bash shell, then the installation will
# break
unset BASH
AC_PATH_PROGS(BASH, bash, "no", [$PATH:/bin:/usr/bin:/usr/sbin])
if test x$BASH = "xno"; then
AC_MSG_ERROR([bash is required])
fi
# check that qsub works
if test ! -z "$QSUB"; then
echo -n "checking whether qsub works... "
echo "" | ${QSUB} >/dev/null 2>&1
if test $? -eq 0; then
QSUB_WORKS="yes"
echo "yes"
else
QSUB_WORKS="no"
echo "no"
fi
else
QSUB_WORKS="no"
fi
AC_SUBST(QSUB_WORKS)
# check qsub parameter (-terse)
if test "${QSUB_WORKS}" = "yes"; then
echo -n "checking whether qsub accepts -terse... "
echo "" | ${QSUB} -terse >/dev/null 2>&1
if test $? -eq 0; then
QSUB_TERSE_OPT="-terse"
echo "yes"
else
QSUB_TERSE_OPT=""
echo "no"
fi
else
QSUB_TERSE_OPT=""
fi
AC_SUBST(QSUB_TERSE_OPT)
# check qstat parameter (-j)
if test "${QSUB_WORKS}" = "yes"; then
echo -n "checking whether qstat accepts -j... "
jid=0
${QSTAT} -j ${jid} 2>&1 | $GREP "invalid option" >/dev/null 2>&1
if test $? -eq 0; then
QSTAT_J_OPT=""
echo "no"
else
QSTAT_J_OPT="-j"
echo "yes"
fi
else
QSTAT_J_OPT=""
fi
AC_SUBST(QSTAT_J_OPT)
# Search awk
## GAWK
AC_PATH_PROG(GAWK, gawk, no)
if test "$GAWK" = no; then
## NAWK
AC_PATH_PROG(NAWK, nawk, no)
if test "$NAWK" = no; then
## MAWK
AC_PATH_PROG(MAWK, mawk, no)
if test "$MAWK" = no; then
AWK=awk
else
# mawk found
AWK=$MAWK
fi
else
# nawk found
AWK=$NAWK
fi
else
# gawk found
AWK=$GAWK
fi
AC_SUBST(AWK)
AC_SUBST(USE_SOURCE_OPT)
# check awk delete array
AC_MSG_CHECKING(whether awk supports delete array )
USE_FAST_DELETE="no"
echo "" | $AWK '{ a[[1]]=1; delete a; if (a[[1]]!=0) exit (1) }' && USE_FAST_DELETE="yes"
if test ${USE_FAST_DELETE} = "yes"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_SUBST(USE_FAST_DELETE)
# Search sort and check parameters
AC_PATH_PROGS(SORT,sort)
echo -n "checking whether sort accepts -S <buffsize>... "
echo "" | ${SORT} -S 131072 >/dev/null 2>&1
if test $? -eq 0; then
sortpars="-S 131072"
echo "yes"
else
sortpars=""
echo "no"
fi
AC_SUBST(sortpars)
echo -n "checking whether sort accepts -T <dir>... "
echo "" | ${SORT} -T /tmp >/dev/null 2>&1
if test $? -eq 0; then
sortT="yes"
echo "yes"
else
sortT="no"
echo "no"
fi
AC_SUBST(sortT)
echo -n "checking whether sort accepts -m... "
echo "" | ${SORT} -m >/dev/null 2>&1
if test $? -eq 0; then
sortm="yes"
echo "yes"
else
sortm="no"
echo "no"
fi
AC_SUBST(sortm)
# Check for compilers
AC_PROG_CXX
AC_PROG_CC
AM_PROG_CC_C_O
CFLAGS="${CFLAGS_AUX}"
CXXFLAGS="${CXXFLAGS_AUX}"
# Checks for basic flags
AC_LANG(C++)
for f in -Wno-deprecated
do
AC_MSG_CHECKING(whether ${CXX} supports ${f})
saved_cxxflags="${CXXFLAGS}"
CXXFLAGS="${CXXFLAGS} ${f}"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }],
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
CXXFLAGS="${saved_cxxflags}")],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
done
dnl Check if we have enable debug support.
AC_MSG_CHECKING(whether to enable debugging)
AC_ARG_ENABLE(debug,[ --enable-debug turn on debugging], enable_debug=yes,
enable_debug=no)
dnl Yes, debug is enabled
if test "$enable_debug" = "yes"; then
AC_MSG_RESULT(yes)
AC_DEFINE(DEBUG,,[Define if the debugging mode is enabled])
# Checks for flags
AC_LANG(C)
for f in -g -Wall
do
AC_MSG_CHECKING(whether ${CC} supports ${f})
saved_cflags="${CFLAGS}"
CFLAGS="${CFLAGS} ${f}"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }],
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
CFLAGS="${saved_cflags}")],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
done
AC_LANG(C++)
for f in -g -Wall
do
AC_MSG_CHECKING(whether ${CXX} supports ${f})
saved_cxxflags="${CXXFLAGS}"
CXXFLAGS="${CXXFLAGS} ${f}"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }],
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
CXXFLAGS="${saved_cxxflags}")],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
done
else
AC_MSG_RESULT(no)
# Checks for flags
AC_LANG(C)
for f in -Wall -O2
do
AC_MSG_CHECKING(whether ${CC} supports ${f})
saved_cflags="${CFLAGS}"
CFLAGS="${CFLAGS} ${f}"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }],
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
CFLAGS="${saved_cflags}")],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
done
AC_LANG(C++)
for f in -Wall -O2
do
AC_MSG_CHECKING(whether ${CXX} supports ${f})
saved_cxxflags="${CXXFLAGS}"
CXXFLAGS="${CXXFLAGS} ${f}"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }],
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
CXXFLAGS="${saved_cxxflags}")],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
done
fi
for top_builddir in . .. ../.. $ac_auxdir $ac_auxdir/..; do
test -f $top_builddir/configure && break
done
# Checks for libraries.
# AC_PROG_RANLIB
# Adds an extra argument to configure (profiling)
AC_MSG_CHECKING(whether to enable profiling)
AC_ARG_ENABLE(developer,[ --enable-developer enable developer features],enable_developer=yes,
enable_developer=no)
dnl Yes, profiling is enabled
if test "$enable_developer" = "yes"; then
AC_MSG_RESULT(yes)
if test "$enable_debug" = "yes"; then
flags="-pg"
else
flags="-g -pg"
fi
AC_LANG(C)
for f in ${flags}
do
AC_MSG_CHECKING(whether ${CC} supports ${f})
saved_cflags="${CFLAGS}"
CFLAGS="${CFLAGS} ${f}"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }],
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
CFLAGS="${saved_cflags}")],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
done
AC_LANG(C++)
for f in ${flags}
do
AC_MSG_CHECKING(whether ${CXX} supports ${f})
saved_cxxflags="${CXXFLAGS}"
CXXFLAGS="${CXXFLAGS} ${f}"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }],
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
CXXFLAGS="${saved_cxxflags}")],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
done
else
AC_MSG_RESULT(no)
fi
# Checks for lm library
AC_CHECK_LIB([m], [log])
# Checks for glpk library
LGLPK=""
libaux=${LIBS}
AC_CHECK_LIB([glpk], [glp_free])
if test $ac_cv_lib_glpk_glp_free = yes; then
LGLPK="-lglpk"
AC_DEFINE(HAVE_GLPK,,[Define if the glpk library is present])
fi
AC_SUBST(LGLPK)
LIBS=${libaux}
# Checks for gmp library
LGMP=""
libaux=${LIBS}
AC_CHECK_LIB([gmp], [__gmpz_init])
if test $ac_cv_lib_gmp___gmpz_init = yes; then
LGMP="-lgmp"
AC_DEFINE(HAVE_GMP,,[Define if the gmp library is present])
fi
AC_SUBST(LGMP)
LIBS=${libaux}
# Checks for zlib library
ZLIB=""
libaux=${LIBS}
AC_CHECK_LIB([z], [inflate])
if test $ac_cv_lib_z_inflate = yes; then
ZLIB="-lz"
AC_DEFINE(HAVE_ZLIB,,[Define if the zlib library is present])
fi
AC_SUBST(ZLIB)
LIBS=${libaux}
# Checks for header files.
AC_CHECK_HEADERS([float.h limits.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_CHECK_TYPE(ssize_t, int)
AC_TYPE_OFF_T
# Checks for large file support
AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
# Checks for library functions.
AC_FUNC_REALLOC
AC_CHECK_FUNCS([gettimeofday pow getdelim])
# Some systems do not supply getline()
AC_MSG_CHECKING([if getline() is supported])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdio.h>
]],[[
char* buf = 0;
size_t len = 0;
FILE* f=NULL;
getline(&buf,&len,f);
]]
)],
[AC_DEFINE(HAVE_GETLINE,[],[Define if getline() is supported])
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
# Checks for doxygen
AC_PATH_PROG(DOXYGEN,doxygen)
# Process options given in shell variables
# Change path of distribution include directory
includedir=${prefix}/include/snptools
#AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([Makefile doc/Makefile m4/Makefile src/Makefile utils/Makefile examples/Makefile])
AC_OUTPUT