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