| 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 |
|
|---|
| 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 | # version information
|
|---|
| 29 |
|
|---|
| 30 | rm -f version
|
|---|
| 31 | echo ${PACKAGE_VERSION} > version # file containing version number for other tools
|
|---|
| 32 | chmod ugo-w version
|
|---|
| 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`
|
|---|
| 37 |
|
|---|
| 38 | # AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/version'])
|
|---|
| 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.])
|
|---|
| 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])
|
|---|
| 47 |
|
|---|
| 48 | #==============================================================================
|
|---|
| 49 | # HACK to be able to use conditionnals inside makefiles
|
|---|
| 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 |
|
|---|
| 59 | #==============================================================================
|
|---|
| 60 | # Installation paths
|
|---|
| 61 | M4CFA_PARSE_PREFIX
|
|---|
| 62 |
|
|---|
| 63 | #==============================================================================
|
|---|
| 64 | # Create variables for commonly used targets
|
|---|
| 65 |
|
|---|
| 66 | TOP_SRCDIR="$(readlink -m $ac_confdir/)/"
|
|---|
| 67 | TOP_BUILDDIR="$(readlink -m $ac_pwd/)/"
|
|---|
| 68 |
|
|---|
| 69 | AC_DEFINE_UNQUOTED(TOP_SRCDIR, "$TOP_SRCDIR", [Top src directory])
|
|---|
| 70 | AC_DEFINE_UNQUOTED(TOP_BUILDDIR, "$TOP_BUILDDIR", [Top build directory])
|
|---|
| 71 |
|
|---|
| 72 | DRIVER_DIR=${TOP_BUILDDIR}driver/
|
|---|
| 73 | CFACC=${DRIVER_DIR}cfa
|
|---|
| 74 | CFACPP=${DRIVER_DIR}cfa-cpp
|
|---|
| 75 | AC_SUBST(DRIVER_DIR)
|
|---|
| 76 | AC_SUBST(CFACC)
|
|---|
| 77 | AC_SUBST(CFACPP)
|
|---|
| 78 |
|
|---|
| 79 | #==============================================================================
|
|---|
| 80 | # Flag variables needed to build in tree
|
|---|
| 81 | LIBCFA_SRC='${TOP_SRCDIR}/libcfa/src'
|
|---|
| 82 | BUILD_IN_TREE_FLAGS="-XCFA -t -B${DRIVER_DIR}"
|
|---|
| 83 | AC_SUBST(BUILD_IN_TREE_FLAGS)
|
|---|
| 84 |
|
|---|
| 85 | #==============================================================================
|
|---|
| 86 | # handle the list of hosts to build for
|
|---|
| 87 | for var in $ac_configure_args
|
|---|
| 88 | do
|
|---|
| 89 | #strip quotes surrouding values
|
|---|
| 90 | case $var in
|
|---|
| 91 | # skip cross compilation related arguments
|
|---|
| 92 | \'--host=*) ;; \'host_alias=*) ;; \'--build=*) ;; \'build_alias=*) ;; \'--target=*) ;; \'target_alias=*) ;;
|
|---|
| 93 |
|
|---|
| 94 | # skip the target hosts
|
|---|
| 95 | \'--with-target-hosts=*) ;;
|
|---|
| 96 |
|
|---|
| 97 | # append all other arguments to the sub configure arguments
|
|---|
| 98 | *) LIBCFA_GENERAL_ARGS="${LIBCFA_GENERAL_ARGS} $var";;
|
|---|
| 99 | esac
|
|---|
| 100 | done
|
|---|
| 101 |
|
|---|
| 102 | #==============================================================================
|
|---|
| 103 | # handle the list of hosts to build for
|
|---|
| 104 | AC_CANONICAL_BUILD
|
|---|
| 105 | AC_CANONICAL_HOST
|
|---|
| 106 |
|
|---|
| 107 | if ! test "$host_cpu" = "$build_cpu"; then
|
|---|
| 108 | case $host_cpu in
|
|---|
| 109 | i386)
|
|---|
| 110 | HOST_FLAGS="-m32"
|
|---|
| 111 | ;;
|
|---|
| 112 | i686)
|
|---|
| 113 | HOST_FLAGS="-m32"
|
|---|
| 114 | ;;
|
|---|
| 115 | x86_64)
|
|---|
| 116 | HOST_FLAGS="-m64"
|
|---|
| 117 | ;;
|
|---|
| 118 | esac
|
|---|
| 119 | fi
|
|---|
| 120 | AC_SUBST(HOST_FLAGS)
|
|---|
| 121 |
|
|---|
| 122 | default_target="${host_cpu}:debug, ${host_cpu}:nodebug"
|
|---|
| 123 | AC_ARG_WITH(target-hosts,
|
|---|
| 124 | [ --with-target-hosts=HOSTS HOSTS comma seperated list of hosts to build for, format ARCH:[debug|nodebug|nolib]],
|
|---|
| 125 | target_hosts=$withval, target_hosts=${default_target})
|
|---|
| 126 |
|
|---|
| 127 | AC_SUBST(TARGET_HOSTS, ${target_hosts})
|
|---|
| 128 |
|
|---|
| 129 | LIBCFA_PATHS="DRIVER_DIR=${DRIVER_DIR}"
|
|---|
| 130 |
|
|---|
| 131 | for i in $(echo $target_hosts | sed "s/,/ /g")
|
|---|
| 132 | do
|
|---|
| 133 | # call your procedure/other scripts here below
|
|---|
| 134 | arch_name=$(echo $i | sed -r "s/:(.*)//g")
|
|---|
| 135 | lib_config=$(echo $i | sed -r "s/(.*)://g")
|
|---|
| 136 |
|
|---|
| 137 | case $lib_config in
|
|---|
| 138 | "nodebug") ;;
|
|---|
| 139 | "debug") ;;
|
|---|
| 140 | "nolib") ;;
|
|---|
| 141 | *)
|
|---|
| 142 | >&2 echo "Configuration must be 'debug', 'nodebug' or 'nolib'"
|
|---|
| 143 | exit 1
|
|---|
| 144 | ;;
|
|---|
| 145 | esac
|
|---|
| 146 |
|
|---|
| 147 | M4CFA_CANNON_CPU([${arch_name}])
|
|---|
| 148 | lib_arch=${cannon_arch_name}
|
|---|
| 149 | lib_dir="libcfa/${lib_arch}-${lib_config}"
|
|---|
| 150 |
|
|---|
| 151 | LIBCFA_TARGET_DIRS="${LIBCFA_TARGET_DIRS} ${lib_dir}"
|
|---|
| 152 | LIBCFA_TARGET_MAKEFILES="${LIBCFA_TARGET_MAKEFILES} ${lib_dir}/Makefile"
|
|---|
| 153 |
|
|---|
| 154 | mkdir -p ${lib_dir}
|
|---|
| 155 | echo -n "${LIBCFA_GENERAL_ARGS} " > ${lib_dir}/config.data
|
|---|
| 156 | echo -n "${LIBCFA_PATHS} " >> ${lib_dir}/config.data
|
|---|
| 157 | echo -n "ARCHITECTURE=${lib_arch} " >> ${lib_dir}/config.data
|
|---|
| 158 | echo -n "CONFIGURATION=${lib_config} " >> ${lib_dir}/config.data
|
|---|
| 159 | echo -n "CFA_VERSION=${ver_major}:${ver_minor}:${ver_patch}" >> ${lib_dir}/config.data
|
|---|
| 160 | done
|
|---|
| 161 |
|
|---|
| 162 | AC_SUBST(LIBCFA_TARGET_DIRS)
|
|---|
| 163 | AC_SUBST(LIBCFA_TARGET_MAKEFILES)
|
|---|
| 164 |
|
|---|
| 165 | M4CFA_CANNON_CPU([${host_cpu}])
|
|---|
| 166 | AC_DEFINE_UNQUOTED(CFA_DEFAULT_CPU, "$cannon_arch_name", [Default cpu to use if neither -m32 or -m64 are defined.])
|
|---|
| 167 | AC_DEFINE_UNQUOTED(CFA_64_CPU, "x64", [CPU to use if the -m64 flags is given.])
|
|---|
| 168 | AC_DEFINE_UNQUOTED(CFA_32_CPU, "x86", [CPU to use if the -m32 flags is given.])
|
|---|
| 169 |
|
|---|
| 170 | #==============================================================================
|
|---|
| 171 | # CAFLAGS
|
|---|
| 172 | AC_DEFINE_UNQUOTED(CFA_FLAGS, "${CFAFLAGS}", [compilation flags for cfa libraries and test programs.])
|
|---|
| 173 | AC_SUBST(CFA_FLAGS, ${CFAFLAGS})
|
|---|
| 174 |
|
|---|
| 175 | #==============================================================================
|
|---|
| 176 | # Checks for programs.
|
|---|
| 177 | AC_PROG_CXX
|
|---|
| 178 | AC_PROG_CC
|
|---|
| 179 | AM_PROG_AS
|
|---|
| 180 | AM_PROG_CC_C_O # deprecated
|
|---|
| 181 | # These are often not installed and people miss seeing the "no", so stop the configure.
|
|---|
| 182 | AC_PROG_YACC
|
|---|
| 183 | if test "${YACC}" = "yacc" ; then echo "Error: bison required." ; exit 1 ; fi
|
|---|
| 184 | AC_PROG_LEX
|
|---|
| 185 | if test "${LEX}" = "lex" ; then echo "Error: flex required." ; exit 1 ; fi
|
|---|
| 186 | AC_PROG_LIBTOOL
|
|---|
| 187 | AC_PROG_INSTALL
|
|---|
| 188 | AC_PROG_MAKE_SET
|
|---|
| 189 |
|
|---|
| 190 | # Checks for libraries.
|
|---|
| 191 | AC_CHECK_LIB([fibre], [Fibre::yield], [HAVE_LIBFIBRE=1], [HAVE_LIBFIBRE=0])
|
|---|
| 192 | AM_CONDITIONAL([WITH_LIBFIBRE], [test "$HAVE_LIBFIBRE" -eq 1])
|
|---|
| 193 |
|
|---|
| 194 | # Checks for header files.
|
|---|
| 195 | AC_FUNC_ALLOCA
|
|---|
| 196 | AC_CHECK_HEADERS([fenv.h float.h inttypes.h libintl.h limits.h malloc.h stddef.h stdlib.h string.h unistd.h])
|
|---|
| 197 |
|
|---|
| 198 | # Checks for typedefs, structures, and compiler characteristics.
|
|---|
| 199 | AC_HEADER_STDBOOL
|
|---|
| 200 | AC_C_INLINE
|
|---|
| 201 | AC_TYPE_INT16_T
|
|---|
| 202 | AC_TYPE_INT32_T
|
|---|
| 203 | AC_TYPE_INT8_T
|
|---|
| 204 | AC_C_RESTRICT
|
|---|
| 205 | AC_TYPE_SIZE_T
|
|---|
| 206 | AC_TYPE_UINT16_T
|
|---|
| 207 | AC_TYPE_UINT32_T
|
|---|
| 208 | AC_TYPE_UINT8_T
|
|---|
| 209 |
|
|---|
| 210 | # Checks for library functions.
|
|---|
| 211 | AC_CHECK_FUNCS([memset putenv strchr strtol])
|
|---|
| 212 |
|
|---|
| 213 | #==============================================================================
|
|---|
| 214 | # backend compiler implementation
|
|---|
| 215 | AC_DEFINE_UNQUOTED(CFA_BACKEND_CC, "${CC}", [Backend compiler to use.])
|
|---|
| 216 | AC_SUBST(CFA_BACKEND_CC)
|
|---|
| 217 |
|
|---|
| 218 | #==============================================================================
|
|---|
| 219 | AC_CONFIG_FILES([
|
|---|
| 220 | Makefile
|
|---|
| 221 | driver/Makefile
|
|---|
| 222 | src/Makefile
|
|---|
| 223 | benchmark/Makefile
|
|---|
| 224 | tests/Makefile
|
|---|
| 225 | tests/preempt_longrun/Makefile
|
|---|
| 226 | tools/Makefile
|
|---|
| 227 | tools/prettyprinter/Makefile
|
|---|
| 228 | ])
|
|---|
| 229 |
|
|---|
| 230 | AC_CONFIG_LINKS([tests/test.py:tests/test.py])
|
|---|
| 231 |
|
|---|
| 232 | AC_OUTPUT(tests/config.py)
|
|---|
| 233 |
|
|---|
| 234 | # Final text
|
|---|
| 235 | AC_MSG_RESULT(Cforall configuraton completed. Type "make -j 8 install".)
|
|---|