[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]) |
---|
[d3b7937] | 7 | #AC_CONFIG_SRCDIR([src/main.cc]) |
---|
[a5c722b] | 8 | AC_CONFIG_HEADERS([config.h:src/config.h.in]) |
---|
[575a6e5] | 9 | AM_SILENT_RULES([yes]) |
---|
[5d6ce1f] | 10 | |
---|
[534e4e4] | 11 | m4_include([automake/cfa.m4]) |
---|
| 12 | |
---|
[575a6e5] | 13 | # don't use the default CFLAGS as they unconditonnaly add -O2 |
---|
| 14 | : ${CFLAGS=""} |
---|
| 15 | |
---|
[44f44617] | 16 | AM_INIT_AUTOMAKE([subdir-objects]) |
---|
[00cc023] | 17 | |
---|
[df47e2f] | 18 | # Allow program name tansformation |
---|
[6363ad1] | 19 | # will fill program_transform_name with appropriate sed regex |
---|
[df47e2f] | 20 | AC_ARG_PROGRAM |
---|
| 21 | |
---|
[c59712e] | 22 | #============================================================================== |
---|
[df47e2f] | 23 | #Trasforming cc1 will break compilation |
---|
[37fe352] | 24 | M4CFA_PROGRAM_NAME |
---|
[c59712e] | 25 | |
---|
| 26 | #============================================================================== |
---|
| 27 | # version information |
---|
| 28 | |
---|
[65c61ec] | 29 | rm -f version |
---|
[2042d41] | 30 | echo ${PACKAGE_VERSION} > version # file containing version number for other tools |
---|
[65c61ec] | 31 | chmod ugo-w version |
---|
[2042d41] | 32 | ver_major=`cut -d '.' -f1 version` # subdivide version number into components at periods |
---|
| 33 | ver_minor=`cut -d '.' -f2 version` |
---|
| 34 | ver_patch=`cut -d '.' -f3 version` |
---|
| 35 | ver_build=`cut -d '.' -f4 version` |
---|
[47a8d17] | 36 | |
---|
[4b1afb6] | 37 | # AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/version']) |
---|
[47a8d17] | 38 | AC_DEFINE_UNQUOTED(CFA_VERSION_MAJOR, ${ver_major}, [Major version number.]) |
---|
| 39 | AC_DEFINE_UNQUOTED(CFA_VERSION_MINOR, ${ver_minor}, [Minor version number.]) |
---|
| 40 | AC_DEFINE_UNQUOTED(CFA_VERSION_PATCH, ${ver_patch}, [Patch version number.]) |
---|
| 41 | AC_DEFINE_UNQUOTED(CFA_VERSION_BUILD, ${ver_build}, [Build version number.]) |
---|
[4b1afb6] | 42 | AC_DEFINE_UNQUOTED(CFA_VERSION_SHORT, ["${ver_major}"], [Major]) |
---|
| 43 | AC_DEFINE_UNQUOTED(CFA_VERSION, ["${ver_major}.${ver_minor}"], [Major.Minor]) |
---|
| 44 | AC_DEFINE_UNQUOTED(CFA_VERSION_LONG, ["${ver_major}.${ver_minor}.${ver_patch}"], [Major.Minor.Patch]) |
---|
| 45 | AC_DEFINE_UNQUOTED(CFA_VERSION_FULL, ["${ver_major}.${ver_minor}.${ver_patch}.${ver_build}"], [Major.Minor.Patch.Build]) |
---|
[ec129c4] | 46 | |
---|
[c59712e] | 47 | #============================================================================== |
---|
| 48 | # HACK to be able to use conditionnals inside makefiles |
---|
[05f4b85] | 49 | DOifskipcompile='ifeq ($(skipcompile),yes) |
---|
| 50 | else' |
---|
| 51 | AC_SUBST([DOifskipcompile]) |
---|
| 52 | AM_SUBST_NOTMAKE([DOifskipcompile]) |
---|
| 53 | |
---|
| 54 | DOendif='endif' |
---|
| 55 | AC_SUBST([DOendif]) |
---|
| 56 | AM_SUBST_NOTMAKE([DOendif]) |
---|
| 57 | |
---|
[c59712e] | 58 | #============================================================================== |
---|
| 59 | # backend compiler implementation |
---|
| 60 | AC_ARG_WITH(backend-compiler, |
---|
| 61 | [ --with-backend-compiler=PROGRAM PROGRAM that performs the final code compilation (must be gcc-compatible) ], |
---|
| 62 | backendcompiler=$withval, backendcompiler="") |
---|
| 63 | if test "x$backendcompiler" != "x"; then |
---|
| 64 | BACKEND_CC=${backendcompiler} |
---|
| 65 | else |
---|
| 66 | AC_PATH_PROG(BACKEND_CC, gcc, []) # check gcc installed |
---|
| 67 | if test "x$BACKEND_CC" = "x"; then |
---|
| 68 | AC_MSG_ERROR(some version of gcc is needed. Get it at ftp://ftp.gnu.org) |
---|
| 69 | exit 1 |
---|
| 70 | fi |
---|
| 71 | fi |
---|
| 72 | AC_DEFINE_UNQUOTED(CFA_BACKEND_CC, "${BACKEND_CC}", [Location of include files.]) |
---|
| 73 | AC_SUBST(CFA_BACKEND_CC) |
---|
| 74 | |
---|
| 75 | #============================================================================== |
---|
| 76 | # Installation paths |
---|
[534e4e4] | 77 | M4CFA_PARSE_PREFIX |
---|
[5d6ce1f] | 78 | |
---|
[c59712e] | 79 | #============================================================================== |
---|
[50697b0] | 80 | # Create variables for commonly used targets |
---|
[ff1e0f38] | 81 | |
---|
[8e485801] | 82 | TOP_SRCDIR="$(readlink -m $ac_confdir/)/" |
---|
| 83 | TOP_BUILDDIR="$(readlink -m $ac_pwd/)/" |
---|
[ff1e0f38] | 84 | |
---|
| 85 | AC_DEFINE_UNQUOTED(TOP_SRCDIR, "$TOP_SRCDIR", [Top src directory]) |
---|
| 86 | AC_DEFINE_UNQUOTED(TOP_BUILDDIR, "$TOP_BUILDDIR", [Top build directory]) |
---|
| 87 | |
---|
| 88 | DRIVER_DIR=${TOP_BUILDDIR}driver/ |
---|
| 89 | CFACC=${DRIVER_DIR}cfa |
---|
| 90 | CFACPP=${DRIVER_DIR}cfa-cpp |
---|
[7fb69f6] | 91 | AC_SUBST(DRIVER_DIR) |
---|
| 92 | AC_SUBST(CFACC) |
---|
[50697b0] | 93 | AC_SUBST(CFACPP) |
---|
| 94 | |
---|
[c59712e] | 95 | #============================================================================== |
---|
[7fb69f6] | 96 | # Flag variables needed to build in tree |
---|
[ff1e0f38] | 97 | LIBCFA_SRC='${TOP_SRCDIR}/libcfa/src' |
---|
| 98 | BUILD_IN_TREE_FLAGS="-XCFA -t -B${DRIVER_DIR}" |
---|
[7fb69f6] | 99 | AC_SUBST(BUILD_IN_TREE_FLAGS) |
---|
| 100 | |
---|
[ff1e0f38] | 101 | #============================================================================== |
---|
| 102 | # handle the list of hosts to build for |
---|
| 103 | for var in $ac_configure_args |
---|
| 104 | do |
---|
| 105 | #strip quotes surrouding values |
---|
| 106 | case $var in |
---|
| 107 | # skip cross compilation related arguments |
---|
[534e4e4] | 108 | \'--host=*) ;; \'host_alias=*) ;; \'--build=*) ;; \'build_alias=*) ;; \'--target=*) ;; \'target_alias=*) ;; |
---|
[ff1e0f38] | 109 | |
---|
| 110 | # skip the target hosts |
---|
[534e4e4] | 111 | \'--with-target-hosts=*) ;; |
---|
[ff1e0f38] | 112 | |
---|
| 113 | # append all other arguments to the sub configure arguments |
---|
| 114 | *) LIBCFA_GENERAL_ARGS="${LIBCFA_GENERAL_ARGS} $var";; |
---|
| 115 | esac |
---|
| 116 | done |
---|
| 117 | |
---|
| 118 | #============================================================================== |
---|
| 119 | # handle the list of hosts to build for |
---|
| 120 | AC_CANONICAL_BUILD |
---|
| 121 | AC_CANONICAL_HOST |
---|
| 122 | |
---|
[47c1928] | 123 | if ! test "$host_cpu" = "$build_cpu"; then |
---|
| 124 | case $host_cpu in |
---|
| 125 | i386) |
---|
| 126 | HOST_FLAGS="-m32" |
---|
| 127 | ;; |
---|
| 128 | i686) |
---|
| 129 | HOST_FLAGS="-m32" |
---|
| 130 | ;; |
---|
| 131 | x86_64) |
---|
| 132 | HOST_FLAGS="-m64" |
---|
| 133 | ;; |
---|
| 134 | esac |
---|
| 135 | fi |
---|
| 136 | AC_SUBST(HOST_FLAGS) |
---|
| 137 | |
---|
[ff1e0f38] | 138 | default_target="${host_cpu}:debug, ${host_cpu}:nodebug" |
---|
| 139 | AC_ARG_WITH(target-hosts, |
---|
| 140 | [ --with-target-hosts=HOSTS HOSTS comma seperated list of hosts to build for, format ARCH:[debug|nodebug|nolib]], |
---|
| 141 | target_hosts=$withval, target_hosts=${default_target}) |
---|
| 142 | |
---|
| 143 | AC_SUBST(TARGET_HOSTS, ${target_hosts}) |
---|
| 144 | |
---|
| 145 | LIBCFA_PATHS="DRIVER_DIR=${DRIVER_DIR}" |
---|
| 146 | |
---|
| 147 | for i in $(echo $target_hosts | sed "s/,/ /g") |
---|
| 148 | do |
---|
| 149 | # call your procedure/other scripts here below |
---|
[534e4e4] | 150 | arch_name=$(echo $i | sed -r "s/:(.*)//g") |
---|
[ff1e0f38] | 151 | lib_config=$(echo $i | sed -r "s/(.*)://g") |
---|
[37fe352] | 152 | |
---|
| 153 | case $lib_config in |
---|
| 154 | "nodebug") ;; |
---|
| 155 | "debug") ;; |
---|
| 156 | "nolib") ;; |
---|
| 157 | *) |
---|
| 158 | >&2 echo "Configuration must be 'debug', 'nodebug' or 'nolib'" |
---|
| 159 | exit 1 |
---|
| 160 | ;; |
---|
| 161 | esac |
---|
| 162 | |
---|
| 163 | M4CFA_CANNON_CPU([${arch_name}]) |
---|
| 164 | lib_arch=${cannon_arch_name} |
---|
[a5121bf] | 165 | lib_dir="libcfa/${lib_arch}-${lib_config}" |
---|
[ff1e0f38] | 166 | |
---|
| 167 | LIBCFA_TARGET_DIRS="${LIBCFA_TARGET_DIRS} ${lib_dir}" |
---|
| 168 | LIBCFA_TARGET_MAKEFILES="${LIBCFA_TARGET_MAKEFILES} ${lib_dir}/Makefile" |
---|
| 169 | |
---|
[a5121bf] | 170 | mkdir -p ${lib_dir} |
---|
| 171 | echo -n "${LIBCFA_GENERAL_ARGS} " > ${lib_dir}/config.data |
---|
| 172 | echo -n "${LIBCFA_PATHS} " >> ${lib_dir}/config.data |
---|
| 173 | echo -n "ARCHITECTURE=${lib_arch} " >> ${lib_dir}/config.data |
---|
| 174 | echo -n "CONFIGURATION=${lib_config}" >> ${lib_dir}/config.data |
---|
[ff1e0f38] | 175 | done |
---|
| 176 | |
---|
| 177 | AC_SUBST(LIBCFA_TARGET_DIRS) |
---|
| 178 | AC_SUBST(LIBCFA_TARGET_MAKEFILES) |
---|
| 179 | |
---|
[37fe352] | 180 | M4CFA_CANNON_CPU([${host_cpu}]) |
---|
| 181 | AC_DEFINE_UNQUOTED(CFA_DEFAULT_CPU, "$cannon_arch_name", [Default cpu to use if neither -m32 or -m64 are defined.]) |
---|
| 182 | AC_DEFINE_UNQUOTED(CFA_64_CPU, "x64", [CPU to use if the -m64 flags is given.]) |
---|
| 183 | AC_DEFINE_UNQUOTED(CFA_32_CPU, "x86", [CPU to use if the -m32 flags is given.]) |
---|
| 184 | |
---|
[c59712e] | 185 | #============================================================================== |
---|
| 186 | # CAFLAGS |
---|
[3f414ef] | 187 | AC_DEFINE_UNQUOTED(CFA_FLAGS, "${CFAFLAGS}", [compilation flags for cfa libraries and test programs.]) |
---|
| 188 | AC_SUBST(CFA_FLAGS, ${CFAFLAGS}) |
---|
| 189 | |
---|
[c59712e] | 190 | #============================================================================== |
---|
[5d6ce1f] | 191 | # Checks for programs. |
---|
| 192 | AC_PROG_CXX |
---|
| 193 | AC_PROG_CC |
---|
[8e5724e] | 194 | AM_PROG_AS |
---|
[00cc023] | 195 | AM_PROG_CC_C_O # deprecated |
---|
[c3a4385] | 196 | # These are often not installed and people miss seeing the "no", so stop the configure. |
---|
[56c3935] | 197 | AC_PROG_YACC |
---|
[c3a4385] | 198 | if test "${YACC}" = "yacc" ; then echo "Error: bison required." ; exit 1 ; fi |
---|
[56c3935] | 199 | AC_PROG_LEX |
---|
[c3a4385] | 200 | if test "${LEX}" = "lex" ; then echo "Error: flex required." ; exit 1 ; fi |
---|
[5d6ce1f] | 201 | AC_PROG_INSTALL |
---|
| 202 | AC_PROG_MAKE_SET |
---|
[00cc023] | 203 | AC_PROG_RANLIB |
---|
[5d6ce1f] | 204 | |
---|
| 205 | # Checks for libraries. |
---|
[41cca44] | 206 | AC_CHECK_LIB([fibre], [Fibre::yield], [HAVE_LIBFIBRE=1], [HAVE_LIBFIBRE=0]) |
---|
| 207 | AM_CONDITIONAL([WITH_LIBFIBRE], [test "$HAVE_LIBFIBRE" -eq 1]) |
---|
[5d6ce1f] | 208 | |
---|
| 209 | # Checks for header files. |
---|
| 210 | AC_FUNC_ALLOCA |
---|
| 211 | AC_CHECK_HEADERS([fenv.h float.h inttypes.h libintl.h limits.h malloc.h stddef.h stdlib.h string.h unistd.h]) |
---|
| 212 | |
---|
| 213 | # Checks for typedefs, structures, and compiler characteristics. |
---|
| 214 | AC_HEADER_STDBOOL |
---|
| 215 | AC_C_INLINE |
---|
| 216 | AC_TYPE_INT16_T |
---|
| 217 | AC_TYPE_INT32_T |
---|
| 218 | AC_TYPE_INT8_T |
---|
| 219 | AC_C_RESTRICT |
---|
| 220 | AC_TYPE_SIZE_T |
---|
| 221 | AC_TYPE_UINT16_T |
---|
| 222 | AC_TYPE_UINT32_T |
---|
| 223 | AC_TYPE_UINT8_T |
---|
| 224 | |
---|
| 225 | # Checks for library functions. |
---|
| 226 | AC_CHECK_FUNCS([memset putenv strchr strtol]) |
---|
| 227 | |
---|
[c59712e] | 228 | #============================================================================== |
---|
[00cc023] | 229 | AC_CONFIG_FILES([ |
---|
| 230 | Makefile |
---|
[bf71cfd] | 231 | driver/Makefile |
---|
[00cc023] | 232 | src/Makefile |
---|
[bf71cfd] | 233 | benchmark/Makefile |
---|
| 234 | tests/Makefile |
---|
| 235 | tests/preempt_longrun/Makefile |
---|
[4149d9d] | 236 | tools/Makefile |
---|
[2b7afbd] | 237 | tools/prettyprinter/Makefile |
---|
[00cc023] | 238 | ]) |
---|
[5d6ce1f] | 239 | |
---|
[bf71cfd] | 240 | AC_CONFIG_LINKS([tests/test.py:tests/test.py]) |
---|
[56de5932] | 241 | |
---|
[bf71cfd] | 242 | AC_OUTPUT(tests/config.py) |
---|
[7e91d4f] | 243 | |
---|
[5d6ce1f] | 244 | # Final text |
---|
| 245 | AC_MSG_RESULT(Cforall configuraton completed. Type "make -j 8 install".) |
---|