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