1 | # -*- Autoconf -*-
|
---|
2 | # Process this file with autoconf to produce a configure script.
|
---|
3 |
|
---|
4 | AC_PREREQ([2.68])
|
---|
5 | AC_INIT([cfa-cc],[1.0.0],[cforall@plg.uwaterloo.ca])
|
---|
6 | AC_CONFIG_AUX_DIR([automake])
|
---|
7 | AC_CONFIG_MACRO_DIRS([automake])
|
---|
8 | AC_CONFIG_HEADERS([config.h:src/config.h.in])
|
---|
9 | AM_SILENT_RULES([yes])
|
---|
10 |
|
---|
11 | m4_include([tools/build/cfa.m4])
|
---|
12 |
|
---|
13 | # don't use the default CFLAGS as they unconditonnaly add -O2
|
---|
14 | : ${CFLAGS=""}
|
---|
15 | : ${CXXFLAGS=""}
|
---|
16 |
|
---|
17 | AM_INIT_AUTOMAKE([subdir-objects])
|
---|
18 |
|
---|
19 | # Allow program name tansformation
|
---|
20 | # will fill program_transform_name with appropriate sed regex
|
---|
21 | AC_ARG_PROGRAM
|
---|
22 |
|
---|
23 | #==============================================================================
|
---|
24 | #Trasforming cc1 will break compilation
|
---|
25 | M4CFA_PROGRAM_NAME
|
---|
26 |
|
---|
27 | #==============================================================================
|
---|
28 | # New AST toggling support
|
---|
29 | AH_TEMPLATE([CFA_USE_NEW_AST],[Sets whether or not to use the new-ast, this is adefault value and can be overrided by --old-ast and --new-ast])
|
---|
30 | DEFAULT_NEW_AST="True"
|
---|
31 | AC_ARG_ENABLE(new-ast,
|
---|
32 | [ --enable-new-ast whether or not to use new ast as the default AST algorithm],
|
---|
33 | [case "${enableval}" in
|
---|
34 | yes) newast=true ; DEFAULT_NEW_AST="True" ;;
|
---|
35 | no) newast=false; DEFAULT_NEW_AST="False" ;;
|
---|
36 | *) AC_MSG_ERROR([bad value ${enableval} for --enable-new-ast]) ;;
|
---|
37 | esac],[newast=true])
|
---|
38 | AC_DEFINE_UNQUOTED([CFA_USE_NEW_AST], $newast)
|
---|
39 | AC_SUBST(DEFAULT_NEW_AST)
|
---|
40 |
|
---|
41 | #==============================================================================
|
---|
42 | # version information
|
---|
43 |
|
---|
44 | rm -f version
|
---|
45 | echo ${PACKAGE_VERSION} > version # file containing version number for other tools
|
---|
46 | chmod ugo-w version
|
---|
47 | ver_major=`cut -d '.' -f1 version` # subdivide version number into components at periods
|
---|
48 | ver_minor=`cut -d '.' -f2 version`
|
---|
49 | ver_patch=`cut -d '.' -f3 version`
|
---|
50 | ver_build=`cut -d '.' -f4 version`
|
---|
51 |
|
---|
52 | # AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/version'])
|
---|
53 | AC_DEFINE_UNQUOTED(CFA_VERSION_MAJOR, ${ver_major}, [Major version number.])
|
---|
54 | AC_DEFINE_UNQUOTED(CFA_VERSION_MINOR, ${ver_minor}, [Minor version number.])
|
---|
55 | AC_DEFINE_UNQUOTED(CFA_VERSION_PATCH, ${ver_patch}, [Patch version number.])
|
---|
56 | AC_DEFINE_UNQUOTED(CFA_VERSION_BUILD, ${ver_build}, [Build version number.])
|
---|
57 | AC_DEFINE_UNQUOTED(CFA_VERSION_SHORT, ["${ver_major}"], [Major])
|
---|
58 | AC_DEFINE_UNQUOTED(CFA_VERSION, ["${ver_major}.${ver_minor}"], [Major.Minor])
|
---|
59 | AC_DEFINE_UNQUOTED(CFA_VERSION_LONG, ["${ver_major}.${ver_minor}.${ver_patch}"], [Major.Minor.Patch])
|
---|
60 | AC_DEFINE_UNQUOTED(CFA_VERSION_FULL, ["${ver_major}.${ver_minor}.${ver_patch}.${ver_build}"], [Major.Minor.Patch.Build])
|
---|
61 |
|
---|
62 | #==============================================================================
|
---|
63 | # HACK to be able to use conditionnals inside makefiles
|
---|
64 | DOifskipcompile='ifeq ($(skipcompile),yes)
|
---|
65 | else'
|
---|
66 | AC_SUBST([DOifskipcompile])
|
---|
67 | AM_SUBST_NOTMAKE([DOifskipcompile])
|
---|
68 |
|
---|
69 | DOendif='endif'
|
---|
70 | AC_SUBST([DOendif])
|
---|
71 | AM_SUBST_NOTMAKE([DOendif])
|
---|
72 |
|
---|
73 | #==============================================================================
|
---|
74 | # distcc support
|
---|
75 |
|
---|
76 | AC_ARG_ENABLE(distcc,
|
---|
77 | [ --enable-distcc whether or not to enable distributed compilation],
|
---|
78 | enable_distcc=$enableval, enable_distcc=no)
|
---|
79 |
|
---|
80 | AC_ARG_WITH(bwlimit,
|
---|
81 | [ --with-bwlimit=RATE RATE the maximum rate at which rsync will be limited when using distributed builds],
|
---|
82 | [], [])
|
---|
83 |
|
---|
84 | AM_CONDITIONAL([ENABLE_DISTCC], [test x$enable_distcc = xyes])
|
---|
85 | HAS_DISTCC="False"
|
---|
86 |
|
---|
87 | if test x$enable_distcc = xyes; then
|
---|
88 | CXX="distcc ${CXX}"
|
---|
89 | LD="distcc ${LD} -lstdc++"
|
---|
90 | HAS_DISTCC="True"
|
---|
91 | echo "Enabling distributed builds"
|
---|
92 | fi
|
---|
93 |
|
---|
94 | AC_SUBST(CXX)
|
---|
95 | AC_SUBST(LD)
|
---|
96 | AC_SUBST(HAS_DISTCC)
|
---|
97 |
|
---|
98 | #==============================================================================
|
---|
99 | # Installation paths
|
---|
100 | M4CFA_PARSE_PREFIX
|
---|
101 |
|
---|
102 | #==============================================================================
|
---|
103 | # Create variables for commonly used targets
|
---|
104 |
|
---|
105 | TOP_SRCDIR="$(readlink -e $ac_abs_confdir/)/"
|
---|
106 | TOP_BUILDDIR="$(readlink -e $ac_pwd/)/"
|
---|
107 |
|
---|
108 | AC_DEFINE_UNQUOTED(TOP_SRCDIR, "$TOP_SRCDIR", [Top src directory])
|
---|
109 | AC_DEFINE_UNQUOTED(TOP_BUILDDIR, "$TOP_BUILDDIR", [Top build directory])
|
---|
110 |
|
---|
111 | DRIVER_DIR=${TOP_BUILDDIR}driver/
|
---|
112 | CFACC=${DRIVER_DIR}cfa
|
---|
113 | CFACC_INSTALL=${CFA_BINDIR}${CFA_NAME}
|
---|
114 | CFACPP=${DRIVER_DIR}cfa-cpp
|
---|
115 | AC_SUBST(DRIVER_DIR)
|
---|
116 | AC_SUBST(CFACC)
|
---|
117 | AC_SUBST(CFACC_INSTALL)
|
---|
118 | AC_SUBST(CFACPP)
|
---|
119 |
|
---|
120 | #==============================================================================
|
---|
121 | # Flag variables needed to build in tree
|
---|
122 | LIBCFA_SRC='${TOP_SRCDIR}/libcfa/src'
|
---|
123 | BUILD_IN_TREE_FLAGS="-XCFA -t -B${DRIVER_DIR}"
|
---|
124 | AC_SUBST(BUILD_IN_TREE_FLAGS)
|
---|
125 |
|
---|
126 | #==============================================================================
|
---|
127 | # handle the list of hosts to build for
|
---|
128 | for var in $ac_configure_args
|
---|
129 | do
|
---|
130 | #strip quotes surrouding values
|
---|
131 | case $var in
|
---|
132 | # skip cross compilation related arguments
|
---|
133 | \'--host=*) ;; \'host_alias=*) ;; \'--build=*) ;; \'build_alias=*) ;; \'--target=*) ;; \'target_alias=*) ;;
|
---|
134 |
|
---|
135 | # skip the target hosts
|
---|
136 | \'--with-target-hosts=*) ;;
|
---|
137 |
|
---|
138 | # skip gprofiler for libcfa
|
---|
139 | \'--enable-gprofiler=*) ;;
|
---|
140 | \'--disable-gprofiler) ;;
|
---|
141 |
|
---|
142 | # skip the target hosts
|
---|
143 | \'--enable-new-ast=*) ;;
|
---|
144 | \'--disable-new-ast) ;;
|
---|
145 |
|
---|
146 | # skip this, it only causes problems
|
---|
147 | \'--srcdir=*) ;;
|
---|
148 |
|
---|
149 | # append all other arguments to the sub configure arguments
|
---|
150 | *) LIBCFA_GENERAL_ARGS="${LIBCFA_GENERAL_ARGS} $var";;
|
---|
151 | esac
|
---|
152 | done
|
---|
153 |
|
---|
154 | #==============================================================================
|
---|
155 | # handle the list of hosts to build for
|
---|
156 | AC_CANONICAL_BUILD
|
---|
157 | AC_CANONICAL_HOST
|
---|
158 |
|
---|
159 | if ! test "$host_cpu" = "$build_cpu"; then
|
---|
160 | case $host_cpu in
|
---|
161 | i386)
|
---|
162 | HOST_FLAGS="-m32"
|
---|
163 | ;;
|
---|
164 | i686)
|
---|
165 | HOST_FLAGS="-m32"
|
---|
166 | ;;
|
---|
167 | x86_64)
|
---|
168 | HOST_FLAGS="-m64"
|
---|
169 | ;;
|
---|
170 | esac
|
---|
171 | fi
|
---|
172 | AC_SUBST(HOST_FLAGS)
|
---|
173 |
|
---|
174 | default_target="${host_cpu}:debug, ${host_cpu}:nodebug"
|
---|
175 | AC_ARG_WITH(target-hosts,
|
---|
176 | [ --with-target-hosts=HOSTS HOSTS comma seperated list of hosts to build for, format ARCH:[debug|nodebug|nolib]],
|
---|
177 | target_hosts=$withval, target_hosts=${default_target})
|
---|
178 |
|
---|
179 | AC_ARG_ENABLE(gprofiler,
|
---|
180 | [ --enable-gprofiler whether or not to enable gprofiler tools (if available)],
|
---|
181 | enable_gprofiler=$enableval, enable_gprofiler=yes)
|
---|
182 |
|
---|
183 | AC_ARG_ENABLE(demangler,
|
---|
184 | [ --enable-demangler whether or not to build the demangler (executable and library)],
|
---|
185 | enable_demangler=$enableval, enable_demangler=yes)
|
---|
186 |
|
---|
187 | AC_SUBST(TARGET_HOSTS, ${target_hosts})
|
---|
188 |
|
---|
189 | LIBCFA_PATHS="DRIVER_DIR=${DRIVER_DIR}"
|
---|
190 |
|
---|
191 | for i in $(echo $target_hosts | sed "s/,/ /g")
|
---|
192 | do
|
---|
193 | # call your procedure/other scripts here below
|
---|
194 | arch_name=$(echo $i | sed -r "s/:(.*)//g")
|
---|
195 | lib_config=$(echo $i | sed -r "s/(.*)://g")
|
---|
196 |
|
---|
197 | case $lib_config in
|
---|
198 | "nodebug") ;;
|
---|
199 | "debug") ;;
|
---|
200 | "nolib") ;;
|
---|
201 | "profile") ;;
|
---|
202 | *)
|
---|
203 | >&2 echo "Configuration must be 'debug', 'nodebug' or 'nolib'"
|
---|
204 | exit 1
|
---|
205 | ;;
|
---|
206 | esac
|
---|
207 |
|
---|
208 | M4CFA_CANNON_CPU([${arch_name}])
|
---|
209 | lib_arch=${cannon_arch_name}
|
---|
210 | lib_dir="libcfa/${lib_arch}-${lib_config}"
|
---|
211 |
|
---|
212 | LIBCFA_TARGET_DIRS="${LIBCFA_TARGET_DIRS} ${lib_dir}"
|
---|
213 | LIBCFA_1TARGET_DIR="${lib_dir}"
|
---|
214 | LIBCFA_TARGET_MAKEFILES="${LIBCFA_TARGET_MAKEFILES} ${lib_dir}/Makefile"
|
---|
215 |
|
---|
216 | mkdir -p ${lib_dir}
|
---|
217 | echo -n "${LIBCFA_GENERAL_ARGS} " > ${lib_dir}/config.data
|
---|
218 | echo -n "${LIBCFA_PATHS} " >> ${lib_dir}/config.data
|
---|
219 | echo -n "ARCHITECTURE=${lib_arch} " >> ${lib_dir}/config.data
|
---|
220 | echo -n "CONFIGURATION=${lib_config} " >> ${lib_dir}/config.data
|
---|
221 | echo -n "CFA_VERSION=${ver_major}:${ver_minor}:${ver_patch}" >> ${lib_dir}/config.data
|
---|
222 | done
|
---|
223 |
|
---|
224 | AC_SUBST(LIBCFA_TARGET_DIRS)
|
---|
225 | AC_SUBST(LIBCFA_1TARGET_DIR)
|
---|
226 | AC_SUBST(LIBCFA_TARGET_MAKEFILES)
|
---|
227 |
|
---|
228 | M4CFA_CANNON_CPU([${host_cpu}])
|
---|
229 | AC_DEFINE_UNQUOTED(CFA_DEFAULT_CPU, "$cannon_arch_name", [Default cpu to use if neither -m32 or -m64 are defined.])
|
---|
230 | AC_DEFINE_UNQUOTED(CFA_64_CPU, "x64", [CPU to use if the -m64 flags is given.])
|
---|
231 | AC_DEFINE_UNQUOTED(CFA_32_CPU, "x86", [CPU to use if the -m32 flags is given.])
|
---|
232 |
|
---|
233 | #==============================================================================
|
---|
234 | # CAFLAGS
|
---|
235 | AC_DEFINE_UNQUOTED(CFA_FLAGS, "${CFAFLAGS}", [compilation flags for cfa libraries and test programs.])
|
---|
236 | AC_SUBST(CFA_FLAGS, ${CFAFLAGS})
|
---|
237 |
|
---|
238 | #==============================================================================
|
---|
239 | # Checks for programs.
|
---|
240 | AC_PROG_CXX
|
---|
241 | AC_PROG_CC
|
---|
242 | AM_PROG_AS
|
---|
243 | # These are often not installed and people miss seeing the "no", so stop the configure.
|
---|
244 | AC_PROG_YACC
|
---|
245 | if test "${YACC}" = "yacc" ; then echo "Error: bison required." ; exit 1 ; fi
|
---|
246 | AC_PROG_LEX
|
---|
247 | if test "${LEX}" = "lex" ; then echo "Error: flex required." ; exit 1 ; fi
|
---|
248 | AC_PROG_LIBTOOL
|
---|
249 | AC_PROG_INSTALL
|
---|
250 |
|
---|
251 | # Checks for libraries.
|
---|
252 | AC_CHECK_LIB([fibre], [Fibre::yield], [HAVE_LIBFIBRE=1], [HAVE_LIBFIBRE=0])
|
---|
253 | AM_CONDITIONAL([WITH_LIBFIBRE], [test "$HAVE_LIBFIBRE" -eq 1])
|
---|
254 |
|
---|
255 | AC_CHECK_LIB([profiler], [ProfilingIsEnabledForAllThreads], [HAVE_LIBPROFILER=1], [HAVE_LIBPROFILER=0])
|
---|
256 | AM_CONDITIONAL([WITH_LIBPROFILER], [test "x$enable_gprofiler" = "xyes" -a "$HAVE_LIBPROFILER" -eq 1])
|
---|
257 |
|
---|
258 | AC_CHECK_LIB([tcmalloc], [malloc], [HAVE_LIBTCMALLOC=1], [HAVE_LIBTCMALLOC=0])
|
---|
259 | AM_CONDITIONAL([WITH_LIBTCMALLOC], [test "x$enable_gprofiler" = "xyes" -a "$HAVE_LIBTCMALLOC" -eq 1])
|
---|
260 |
|
---|
261 | # conditionnally build the demangler
|
---|
262 | if test "x$enable_demangler" == xyes; then
|
---|
263 | LIBDEMANGLE="libdemangle.a"
|
---|
264 | DEMANGLER="demangler"
|
---|
265 | else
|
---|
266 | LIBDEMANGLE=""
|
---|
267 | DEMANGLER=""
|
---|
268 | fi
|
---|
269 | AC_SUBST([LIBDEMANGLE])
|
---|
270 | AC_SUBST([DEMANGLER])
|
---|
271 |
|
---|
272 | # Checks for header files.
|
---|
273 | AC_CHECK_HEADERS([libintl.h malloc.h unistd.h], [], [echo "Error: Missing required header"; exit 1])
|
---|
274 |
|
---|
275 | # Checks for typedefs, structures, and compiler characteristics.
|
---|
276 | AC_CHECK_TYPES([_Float32], AC_DEFINE([HAVE_KEYWORDS_FLOATXX], [], [Have keywords _FloatXX.]), [], [[]])
|
---|
277 |
|
---|
278 | # Checks for compiler flags.
|
---|
279 | M4CFA_CHECK_COMPILE_FLAG([-Wcast-function-type], AC_DEFINE([HAVE_CAST_FUNCTION_TYPE], [], [Have compiler warning cast-function-type.]))
|
---|
280 |
|
---|
281 | #==============================================================================
|
---|
282 | # backend compiler implementation
|
---|
283 | AC_DEFINE_UNQUOTED(CFA_BACKEND_CC, "${CC}", [Backend compiler to use.])
|
---|
284 | AC_SUBST(CFA_BACKEND_CC)
|
---|
285 |
|
---|
286 | #==============================================================================
|
---|
287 | AC_CONFIG_FILES([
|
---|
288 | Makefile
|
---|
289 | driver/Makefile
|
---|
290 | src/Makefile
|
---|
291 | libcfa/Makefile:libcfa/Makefile.dist.in
|
---|
292 | tests/Makefile
|
---|
293 | ])
|
---|
294 |
|
---|
295 | # Some of our makefile don't need to be distributed
|
---|
296 | AM_CONDITIONAL([CFORALL_DISTRIBUTE], [test -e $TOP_SRCDIR/autogen.sh])
|
---|
297 | AM_COND_IF([CFORALL_DISTRIBUTE], [
|
---|
298 | AC_CONFIG_FILES([
|
---|
299 | longrun_tests/Makefile
|
---|
300 | benchmark/Makefile
|
---|
301 | benchmark/io/http/Makefile
|
---|
302 | tools/Makefile
|
---|
303 | tools/prettyprinter/Makefile
|
---|
304 | ])
|
---|
305 |
|
---|
306 | AC_OUTPUT(benchmark/Cargo.toml)
|
---|
307 | ])
|
---|
308 |
|
---|
309 | AC_CONFIG_LINKS([tests/test.py:tests/test.py])
|
---|
310 |
|
---|
311 | AC_OUTPUT(tests/config.py)
|
---|
312 |
|
---|
313 | # Final text
|
---|
314 | AC_MSG_RESULT(Cforall configuraton completed. Type "make -j 8 install".)
|
---|