source: configure.ac @ 0c30ecc

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 0c30ecc was 0c30ecc, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Move cfa.m4 and cfa.make to tools/build

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