source: configure.ac @ 5c028ac

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 5c028ac was 969e7ee7, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Configure script now creates subst for whether new-ast was specified or not as the default

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