/
configure.ac
246 lines (201 loc) · 7.58 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
# This file is processed by autoconf to create a Makefile for the GARLI
# This file was written by hand (by mth using PAUP's configure.ac and http://autotoolset.sourceforge.net/tutorial.html as guides).
AC_PREREQ(2.59)
AC_INIT([2nexml], [0.01], [mtholder@gmail.com])
AC_CONFIG_SRCDIR([src/2nexml.cpp])
AC_CONFIG_HEADER([config.h])
# Directory that contains install-sh and other auxiliary files
AC_CONFIG_AUX_DIR([config])
################################################################################
# Checks for build-platform and target info
# this defines the "target" variable that is used later in this file
################################################################################
AC_CANONICAL_TARGET
################################################################################
# According to (http://www.mail-archive.com/autoconf@gnu.org/msg14232.html)
# this macro should be after AC_INIT but before AM_INIT_AUTOMAKE
################################################################################
AC_CONFIG_MACRO_DIR(config)
AM_INIT_AUTOMAKE([1.9 foreign dist-tarZ tar-ustar filename-length-max=299])
# Checks for programs.
AC_PROG_LN_S
AC_PROG_CC
AC_PROG_CPP
INP_CXXFLAGS="$CXXFLAGS"
AC_PROG_CXX
# Initialize CXXFLAGS to prevent it from defaulting to "-g -O2"
CXXFLAGS="$INP_CXXFLAGS -DUNIX -DNCL_CONST_FUNCS"
# required because we are building a library
AC_PROG_RANLIB
AC_PROG_INSTALL
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([float.h malloc.h stddef.h stdlib.h sys/time.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_STRUCT_TM
# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_FUNC_MALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([floor memmove memset pow sqrt strchr strdup strtol])
# A few miscelaneous features, not of general interest
AC_ARG_ENABLE(profiler, AC_HELP_STRING([--enable-profiler], [built in runtime profiler]),
[AC_DEFINE([ENABLE_CUSTOM_PROFILER], [1], [profiler for assessing execution times])],
[])
AC_ARG_ENABLE(leak_detection, AC_HELP_STRING([--enable-leak-detection], [memory leak detection is turned on]),
[AC_DEFINE([MONITORING_ALLOCATION], [1], [monitors all allocation/deallocation, writes report])],
[])
#--------------------------------------------------------------------------------------------------#
# Set CXXFLAGS #
#--------------------------------------------------------------------------------------------------#
# Check for debugging mode.
AC_ARG_ENABLE(debugging,
AC_HELP_STRING([--enable-debugging],[build for debugging]), , [enable_debugging=no])
if test "$enable_debugging" = yes; then
AC_MSG_NOTICE([
*** NOTE: debugging is enabled; optimization is suppressed!
])
fi
# we tell NCL that we will ignore asserts
NCL_ASSERT_FLAG="-DIGNORE_NXS_ASSERT"
# Check whether asserts should be allowed.
AC_ARG_ENABLE(asserts,
AC_HELP_STRING([--enable-asserts],[build with asserts on (NDEBUG not defined)]), , [enable_asserts=no])
if test "$enable_asserts" = yes; then
AC_MSG_NOTICE([
*** NOTE: compiling with assertions on (NDEBUG not defined)
])
if test "$enable_debugging" = yes; then
NCL_ASSERT_FLAG=""
fi
fi
# Initialize optimization flag in case it doesn't get set below.
CXXFLAGS_OPTIM_SPEED="-O"
# "-g" may not work with some compilers, but end users shouldn't be
if test "$enable_debugging" = yes; then
CXXFLAGS_OPTIM_SPEED="-O0"
CXXFLAGS="$CXXFLAGS -Wall -g -Wreturn-type -Wunused -Wredundant-decls -Wcast-align -Wcomment -Wextra"
fi
if test "$enable_asserts" = no; then
CXXFLAGS="$CXXFLAGS -DNDEBUG"
fi
#Compiler choice
if test "$CC" = "icc" -o "$CC" = "icc" ; then
# Intel C compiler for Linux
if test "$enable_debugging" = no; then
CXXFLAGS_OPTIM_SPEED="-O2 -ip -funroll-loops -fno-alias"
fi
elif test "$CC" = "ccc"; then
# Compaq C compiler for Linux
if test "x$arch" = "x"; then
arch="host"
fi
if test "$enable_debugging" = no; then
CXXFLAGS_OPTIM_SPEED="-fast -inline speed -arch $arch"
fi
elif test "$CC" = "xlc"; then
# IBM XL C compiler
CCFLAGS="$CXXFLAGS -qsourcetype=c++ -qenablevmx -qchars=signed"
if test "x$arch" = "x"; then
arch="auto"
fi
if test "$enable_debugging" = no; then
CXXFLAGS_OPTIM_SPEED="-O3 -qarch=$arch -qtune=$arch -qalias=ansi -qunroll=yes"
fi
elif test "x$GCC" = "xyes" ; then
CXXFLAGS="$CXXFLAGS -Wno-uninitialized"
if test "$enable_debugging" = yes; then
CXXFLAGS_OPTIM_SPEED="-O0 -Wimplicit"
else
CXXFLAGS_OPTIM_SPEED="-O3 -ffast-math -funroll-loops -fstrict-aliasing"
fi
case "$build_os" in
darwin*) CXXFLAGS="$CXXFLAGS" ;;
*) CXXFLAGS="$CXXFLAGS -fsigned-char";;
esac
fi
AC_LANG(C++)
CXXFLAGS="$CXXFLAGS $CXXFLAGS_OPTIM_SPEED"
################################################################################
# Require the builder to provide the --with-ncl argument,
# otherwise default to looking for a system level installation.
# ideally people should be using the build_garli.sh install script
################################################################################
NCL_INC_DIR="/usr/local/include"
NCL_LIB_DIR="/usr/local/lib"
NCL_BIN_DIR="/usr/local/bin"
AC_ARG_WITH(
[ncl],
AC_HELP_STRING(
[--with-ncl=DIR],
[Specify the root directory for the ncl version 2.1 or greater library (parent of the include/ncl and lib directories). Omit this flag and configure will look for a system level NCL installation.]
),
[
if ! test "$withval" = "yes" -o "$withval" = "no" ; then
NCL_INC_DIR="$withval/include"
NCL_LIB_DIR="$withval/lib"
NCL_BIN_DIR="$withval/bin"
fi
])
if ! test -d "$NCL_INC_DIR/ncl" ; then
AC_MSG_ERROR([NCL 2.1 or higher is a prerequisite for building 2nexml. Expecting a directory called $NCL_INC_DIR/ncl, verify that the argument to --with-ncl is correct.])
else
if ! test -f "$NCL_INC_DIR/ncl/nxsdefs.h" ; then
AC_MSG_ERROR([NCL 2.1 or higher is a prerequisite for building 2nexml. Expecting a directory called $NCL_INC_DIR/ncl, verify that the argument to --with-ncl is correct.])
fi
fi
if ! test -d "$NCL_LIB_DIR" ; then
AC_MSG_ERROR([NCL 2.1 or higher is a prerequisite for building 2nexml. Expecting a directory called $NCL_LIB_DIR, verify that the argument to --with-ncl is correct.])
fi
CPPFLAGS="$CPPFLAGS -I$NCL_INC_DIR -I$NCL_INC_DIR/ncl $NCL_ASSERT_FLAG"
if test -d "$NCL_LIB_DIR/ncl" ; then
LDFLAGS="$LDFLAGS -L$NCL_LIB_DIR/ncl"
else
LDFLAGS="$LDFLAGS -L$NCL_LIB_DIR"
fi
LIBS="$LIBS -lncl"
AC_TRY_LINK(
[],
[int foo=2;],
[],
[AC_MSG_ERROR([Problem with link flags. Most likely a library cannot be found.
Check that any libraries listed below can be found in a system default location or a location specified in LDFLAGS with a -L.
LIBS=$LIBS
LDFLAGS=$LDFLAGS
])])
AC_TRY_LINK(
[#include "ncl/nxsdefs.h" ],
[onlyDefinedInCouldBeConst ();],
[],
[AC_MSG_ERROR([NCL must be compiled with the NCL_CONST_FUNCS macro defined. Usually adding -DNCL_CONST_FUNCS to CPPFLAGS in your invocation of the NCL configure script is the solution.])])
AC_COMPILE_IFELSE(
[#include "ncl/nxsdefs.h"
# if ! defined(NCL_MAJOR_VERSION) || NCL_MAJOR_VERSION < 2
# error "need at least v2"
# else
# if ! defined(NCL_MINOR_VERSION) || NCL_MINOR_VERSION < 1
# error "need at least v2.1"
# endif
# endif
],
[],
[AC_MSG_ERROR([Sorry. NCL 2.1 or greater is required.])])
TO_NEXML_LIBS="-lncl"
AC_SUBST([NCL_BIN_DIR])
AC_SUBST([TO_NEXML_LIBS])
AC_SUBST([CPPFLAGS])
AC_SUBST([LDFLAGS])
#currently we are bundling NCL in the svn, so we know the path
# Variables to substitute in Makefile:
AC_SUBST(CPPFLAGS)
AC_CONFIG_FILES([
Makefile \
src/Makefile \
tests/Makefile \
])
AC_OUTPUT