source: configure.ac @ bbfd0e0

arm-ehjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-expr
Last change on this file since bbfd0e0 was bbfd0e0, checked in by Thierry Delisle <tdelisle@…>, 2 years ago

Tentative support for distcc in cforall, right now nothing works because distcc doesn't understand cfa

  • Property mode set to 100644
File size: 8.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])
8#AC_CONFIG_SRCDIR([src/main.cc])
9AC_CONFIG_HEADERS([config.h:src/config.h.in])
10AM_SILENT_RULES([yes])
11
12m4_include([automake/cfa.m4])
13
14# don't use the default CFLAGS as they unconditonnaly add -O2
15: ${CFLAGS=""}
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# version information
29
30rm -f version
31echo ${PACKAGE_VERSION} > version               # file containing version number for other tools
32chmod ugo-w version
33ver_major=`cut -d '.' -f1 version`              # subdivide version number into components at periods
34ver_minor=`cut -d '.' -f2 version`
35ver_patch=`cut -d '.' -f3 version`
36ver_build=`cut -d '.' -f4 version`
37
38# AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/version'])
39AC_DEFINE_UNQUOTED(CFA_VERSION_MAJOR, ${ver_major}, [Major version number.])
40AC_DEFINE_UNQUOTED(CFA_VERSION_MINOR, ${ver_minor}, [Minor version number.])
41AC_DEFINE_UNQUOTED(CFA_VERSION_PATCH, ${ver_patch}, [Patch version number.])
42AC_DEFINE_UNQUOTED(CFA_VERSION_BUILD, ${ver_build}, [Build version number.])
43AC_DEFINE_UNQUOTED(CFA_VERSION_SHORT, ["${ver_major}"], [Major])
44AC_DEFINE_UNQUOTED(CFA_VERSION, ["${ver_major}.${ver_minor}"], [Major.Minor])
45AC_DEFINE_UNQUOTED(CFA_VERSION_LONG, ["${ver_major}.${ver_minor}.${ver_patch}"], [Major.Minor.Patch])
46AC_DEFINE_UNQUOTED(CFA_VERSION_FULL, ["${ver_major}.${ver_minor}.${ver_patch}.${ver_build}"], [Major.Minor.Patch.Build])
47
48#==============================================================================
49# HACK to be able to use conditionnals inside makefiles
50DOifskipcompile='ifeq ($(skipcompile),yes)
51else'
52AC_SUBST([DOifskipcompile])
53AM_SUBST_NOTMAKE([DOifskipcompile])
54
55DOendif='endif'
56AC_SUBST([DOendif])
57AM_SUBST_NOTMAKE([DOendif])
58
59#==============================================================================
60# distcc support
61
62AC_ARG_ENABLE(distcc,
63        [  --enable-distcc     whether or not to enable distributed compilation],
64        enable_distcc=$enableval, enable_distcc=no)
65
66AM_CONDITIONAL([ENABLE_DISTCC], [test x$enable_distcc = xyes])
67
68if test x$enable_distcc = xyes; then
69        CXX="distcc ${CXX}"
70        LD="distcc ${LD} -lstdc++"
71        echo "Enabling distributed builds"
72fi
73
74AC_SUBST(CXX)
75AC_SUBST(LD)
76
77#==============================================================================
78# Installation paths
79M4CFA_PARSE_PREFIX
80
81#==============================================================================
82# Create variables for commonly used targets
83
84TOP_SRCDIR="$(readlink -m $ac_confdir/)/"
85TOP_BUILDDIR="$(readlink -m $ac_pwd/)/"
86
87AC_DEFINE_UNQUOTED(TOP_SRCDIR, "$TOP_SRCDIR", [Top src directory])
88AC_DEFINE_UNQUOTED(TOP_BUILDDIR, "$TOP_BUILDDIR", [Top build directory])
89
90DRIVER_DIR=${TOP_BUILDDIR}driver/
91CFACC=${DRIVER_DIR}cfa
92CFACPP=${DRIVER_DIR}cfa-cpp
93AC_SUBST(DRIVER_DIR)
94AC_SUBST(CFACC)
95AC_SUBST(CFACPP)
96
97#==============================================================================
98# Flag variables needed to build in tree
99LIBCFA_SRC='${TOP_SRCDIR}/libcfa/src'
100BUILD_IN_TREE_FLAGS="-XCFA -t -B${DRIVER_DIR}"
101AC_SUBST(BUILD_IN_TREE_FLAGS)
102
103#==============================================================================
104# handle the list of hosts to build for
105for var in $ac_configure_args
106do
107        #strip quotes surrouding values
108        case $var in
109                # skip cross compilation related arguments
110                \'--host=*) ;; \'host_alias=*) ;; \'--build=*) ;; \'build_alias=*) ;; \'--target=*) ;; \'target_alias=*) ;;
111
112                # skip the target hosts
113                \'--with-target-hosts=*) ;;
114
115                # skip gprofiler for libcfa
116                \'--enable-gprofiler=*) ;;
117                \'--disable-gprofiler) ;;
118
119                # append all other arguments to the sub configure arguments
120                *) LIBCFA_GENERAL_ARGS="${LIBCFA_GENERAL_ARGS} $var";;
121        esac
122done
123
124#==============================================================================
125# handle the list of hosts to build for
126AC_CANONICAL_BUILD
127AC_CANONICAL_HOST
128
129if ! test "$host_cpu" = "$build_cpu"; then
130        case $host_cpu in
131                i386)
132                        HOST_FLAGS="-m32"
133                        ;;
134                i686)
135                        HOST_FLAGS="-m32"
136                        ;;
137                x86_64)
138                        HOST_FLAGS="-m64"
139                        ;;
140        esac
141fi
142AC_SUBST(HOST_FLAGS)
143
144default_target="${host_cpu}:debug, ${host_cpu}:nodebug"
145AC_ARG_WITH(target-hosts,
146        [  --with-target-hosts=HOSTS     HOSTS comma seperated list of hosts to build for, format ARCH:[debug|nodebug|nolib]],
147        target_hosts=$withval, target_hosts=${default_target})
148
149AC_ARG_ENABLE(gprofiler,
150        [  --enable-gprofiler     whether or not to enable gprofiler tools (if available)],
151        enable_gprofiler=$enableval, enable_gprofiler=yes)
152
153AC_ARG_ENABLE(demangler,
154        [  --enable-demangler     whether or not to build the demangler (executable and library)],
155        enable_demangler=$enableval, enable_demangler=yes)
156
157AC_SUBST(TARGET_HOSTS, ${target_hosts})
158
159LIBCFA_PATHS="DRIVER_DIR=${DRIVER_DIR}"
160
161for i in $(echo $target_hosts | sed "s/,/ /g")
162do
163        # call your procedure/other scripts here below
164        arch_name=$(echo $i | sed -r "s/:(.*)//g")
165        lib_config=$(echo $i | sed -r "s/(.*)://g")
166
167        case $lib_config in
168                "nodebug") ;;
169                "debug") ;;
170                "nolib") ;;
171                "profile") ;;
172                *)
173                        >&2 echo "Configuration must be 'debug', 'nodebug' or 'nolib'"
174                        exit 1
175                ;;
176        esac
177
178        M4CFA_CANNON_CPU([${arch_name}])
179        lib_arch=${cannon_arch_name}
180        lib_dir="libcfa/${lib_arch}-${lib_config}"
181
182        LIBCFA_TARGET_DIRS="${LIBCFA_TARGET_DIRS} ${lib_dir}"
183        LIBCFA_TARGET_MAKEFILES="${LIBCFA_TARGET_MAKEFILES} ${lib_dir}/Makefile"
184
185        mkdir -p ${lib_dir}
186        echo -n "${LIBCFA_GENERAL_ARGS} " > ${lib_dir}/config.data
187        echo -n "${LIBCFA_PATHS} " >> ${lib_dir}/config.data
188        echo -n "ARCHITECTURE=${lib_arch} " >> ${lib_dir}/config.data
189        echo -n "CONFIGURATION=${lib_config} " >> ${lib_dir}/config.data
190        echo -n "CFA_VERSION=${ver_major}:${ver_minor}:${ver_patch}" >> ${lib_dir}/config.data
191done
192
193AC_SUBST(LIBCFA_TARGET_DIRS)
194AC_SUBST(LIBCFA_TARGET_MAKEFILES)
195
196M4CFA_CANNON_CPU([${host_cpu}])
197AC_DEFINE_UNQUOTED(CFA_DEFAULT_CPU, "$cannon_arch_name", [Default cpu to use if neither -m32 or -m64 are defined.])
198AC_DEFINE_UNQUOTED(CFA_64_CPU, "x64", [CPU to use if the -m64 flags is given.])
199AC_DEFINE_UNQUOTED(CFA_32_CPU, "x86", [CPU to use if the -m32 flags is given.])
200
201#==============================================================================
202# CAFLAGS
203AC_DEFINE_UNQUOTED(CFA_FLAGS, "${CFAFLAGS}", [compilation flags for cfa libraries and test programs.])
204AC_SUBST(CFA_FLAGS, ${CFAFLAGS})
205
206#==============================================================================
207# Checks for programs.
208AC_PROG_CXX
209AC_PROG_CC
210AM_PROG_AS
211# These are often not installed and people miss seeing the "no", so stop the configure.
212AC_PROG_YACC
213if test "${YACC}" = "yacc" ; then echo "Error: bison required." ; exit 1 ; fi
214AC_PROG_LEX
215if test "${LEX}" = "lex" ; then echo "Error: flex required." ; exit 1 ; fi
216AC_PROG_LIBTOOL
217AC_PROG_INSTALL
218
219# Checks for libraries.
220AC_CHECK_LIB([fibre], [Fibre::yield], [HAVE_LIBFIBRE=1], [HAVE_LIBFIBRE=0])
221AM_CONDITIONAL([WITH_LIBFIBRE], [test "$HAVE_LIBFIBRE" -eq 1])
222
223AC_CHECK_LIB([profiler], [ProfilingIsEnabledForAllThreads], [HAVE_LIBPROFILER=1], [HAVE_LIBPROFILER=0])
224AM_CONDITIONAL([WITH_LIBPROFILER], [test "x$enable_gprofiler" = "xyes" -a "$HAVE_LIBPROFILER" -eq 1])
225
226AC_CHECK_LIB([tcmalloc], [malloc], [HAVE_LIBTCMALLOC=1], [HAVE_LIBTCMALLOC=0])
227AM_CONDITIONAL([WITH_LIBTCMALLOC], [test "x$enable_gprofiler" = "xyes" -a "$HAVE_LIBTCMALLOC" -eq 1])
228
229# conditionnally build the demangler
230if test "x$enable_demangler" == xyes; then
231        LIBDEMANGLE="libdemangle.a"
232        DEMANGLER="demangler"
233else
234        LIBDEMANGLE=""
235        DEMANGLER=""
236fi
237AC_SUBST([LIBDEMANGLE])
238AC_SUBST([DEMANGLER])
239
240# Checks for header files.
241AC_CHECK_HEADERS([libintl.h malloc.h unistd.h], [], [echo "Error: Missing required header"; exit 1])
242
243# Checks for typedefs, structures, and compiler characteristics.
244AC_CHECK_TYPES([_Float32], AC_DEFINE([HAVE_KEYWORDS_FLOATXX], [], [Have keywords _FloatXX.]), [], [[]])
245
246# Checks for compiler flags.
247M4CFA_CHECK_COMPILE_FLAG([-Wcast-function-type], AC_DEFINE([HAVE_CAST_FUNCTION_TYPE], [], [Have compiler warning cast-function-type.]))
248
249#==============================================================================
250# backend compiler implementation
251AC_DEFINE_UNQUOTED(CFA_BACKEND_CC, "${CC}", [Backend compiler to use.])
252AC_SUBST(CFA_BACKEND_CC)
253
254#==============================================================================
255AC_CONFIG_FILES([
256        Makefile
257        driver/Makefile
258        src/Makefile
259        benchmark/Makefile
260        tests/Makefile
261        longrun_tests/Makefile
262        tools/Makefile
263        tools/prettyprinter/Makefile
264        ])
265
266AC_CONFIG_LINKS([tests/test.py:tests/test.py])
267
268AC_OUTPUT(tests/config.py)
269
270# Final text
271AC_MSG_RESULT(Cforall configuraton completed. Type "make -j 8 install".)
Note: See TracBrowser for help on using the repository browser.