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