[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]) |
---|
[5d6ce1f] | 8 | AC_CONFIG_HEADERS([config.h]) |
---|
[ef7d253] | 9 | AM_SILENT_RULES([no]) |
---|
[5d6ce1f] | 10 | |
---|
[90c3b1c] | 11 | if test "x${CXXFLAGS}" = "x"; then |
---|
[6e4b913] | 12 | export CXXFLAGS="-std=c++11 -g ${CXXFLAGS}" # defaults, no -O2 for debugging and failures |
---|
[90c3b1c] | 13 | else |
---|
[6e4b913] | 14 | export CXXFLAGS="-std=c++11 ${CXXFLAGS}" # flags from configure command |
---|
[90c3b1c] | 15 | fi |
---|
| 16 | |
---|
[00cc023] | 17 | AM_INIT_AUTOMAKE |
---|
[6e4b913] | 18 | AM_MAINTAINER_MODE(enable) # may require auto* software to be installed |
---|
[00cc023] | 19 | |
---|
[df47e2f] | 20 | # Allow program name tansformation |
---|
[6363ad1] | 21 | # will fill program_transform_name with appropriate sed regex |
---|
[df47e2f] | 22 | AC_ARG_PROGRAM |
---|
| 23 | |
---|
| 24 | #Trasforming cc1 will break compilation |
---|
[65e9bc1] | 25 | if test "${program_transform_name}" = ""; then |
---|
[6363ad1] | 26 | AC_MSG_ERROR([Program transform not supported. |
---|
| 27 | Use --with-cfa-name='[[Desired name here]]' instead]) |
---|
[df47e2f] | 28 | fi |
---|
| 29 | |
---|
[796cea3] | 30 | AC_ARG_WITH(cfa-name, |
---|
| 31 | [ --with-cfa-name=NAME NAME too which cfa will be installed], |
---|
| 32 | cfa_name=$withval, cfa_name="cfa") |
---|
| 33 | |
---|
[df47e2f] | 34 | #Define the new name of the installed command |
---|
| 35 | AC_SUBST(CFA_NAME, ${cfa_name}) |
---|
| 36 | |
---|
[65c61ec] | 37 | rm -f version |
---|
[2042d41] | 38 | echo ${PACKAGE_VERSION} > version # file containing version number for other tools |
---|
[65c61ec] | 39 | chmod ugo-w version |
---|
[2042d41] | 40 | ver_major=`cut -d '.' -f1 version` # subdivide version number into components at periods |
---|
| 41 | ver_minor=`cut -d '.' -f2 version` |
---|
| 42 | ver_patch=`cut -d '.' -f3 version` |
---|
| 43 | ver_build=`cut -d '.' -f4 version` |
---|
[47a8d17] | 44 | |
---|
[4b1afb6] | 45 | # AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/version']) |
---|
[47a8d17] | 46 | AC_DEFINE_UNQUOTED(CFA_VERSION_MAJOR, ${ver_major}, [Major version number.]) |
---|
| 47 | AC_DEFINE_UNQUOTED(CFA_VERSION_MINOR, ${ver_minor}, [Minor version number.]) |
---|
| 48 | AC_DEFINE_UNQUOTED(CFA_VERSION_PATCH, ${ver_patch}, [Patch version number.]) |
---|
| 49 | AC_DEFINE_UNQUOTED(CFA_VERSION_BUILD, ${ver_build}, [Build version number.]) |
---|
[4b1afb6] | 50 | AC_DEFINE_UNQUOTED(CFA_VERSION_SHORT, ["${ver_major}"], [Major]) |
---|
| 51 | AC_DEFINE_UNQUOTED(CFA_VERSION, ["${ver_major}.${ver_minor}"], [Major.Minor]) |
---|
| 52 | AC_DEFINE_UNQUOTED(CFA_VERSION_LONG, ["${ver_major}.${ver_minor}.${ver_patch}"], [Major.Minor.Patch]) |
---|
| 53 | AC_DEFINE_UNQUOTED(CFA_VERSION_FULL, ["${ver_major}.${ver_minor}.${ver_patch}.${ver_build}"], [Major.Minor.Patch.Build]) |
---|
[ec129c4] | 54 | |
---|
[5d6ce1f] | 55 | # Installation paths |
---|
| 56 | |
---|
[ef7d253] | 57 | AC_ARG_WITH(backend-compiler, |
---|
| 58 | [ --with-backend-compiler=PROGRAM PROGRAM that performs the final code compilation (must be gcc-compatible) ], |
---|
[e24f13a] | 59 | backendcompiler=$withval, backendcompiler="") |
---|
[6e4b913] | 60 | if test "x$backendcompiler" != "x"; then |
---|
[e24f13a] | 61 | BACKEND_CC=${backendcompiler} |
---|
| 62 | else |
---|
[6e4b913] | 63 | AC_PATH_PROG(BACKEND_CC, gcc, []) # check gcc installed |
---|
[e24f13a] | 64 | if test "x$BACKEND_CC" = "x"; then |
---|
[00cc023] | 65 | AC_MSG_ERROR(some version of gcc is needed. Get it at ftp://ftp.gnu.org) |
---|
| 66 | exit 1 |
---|
| 67 | fi |
---|
[e24f13a] | 68 | fi |
---|
| 69 | AC_DEFINE_UNQUOTED(CFA_BACKEND_CC, "${BACKEND_CC}", [Location of include files.]) |
---|
| 70 | AC_SUBST(CFA_BACKEND_CC) |
---|
[5d6ce1f] | 71 | |
---|
[9def87a] | 72 | |
---|
| 73 | |
---|
| 74 | AC_ARG_ENABLE(target-release, AS_HELP_STRING([--enable-target-release], [Build and install the release target])) |
---|
| 75 | AC_ARG_ENABLE(target-debug, AS_HELP_STRING([--enable-target-debug], [Build and install the debug target])) |
---|
[facc44f] | 76 | AC_ARG_ENABLE(threading, AS_HELP_STRING([--enable-threading], [Build and install libcfa with threading support (Enabled by default)]), |
---|
| 77 | [case "${enableval}" in |
---|
[a62cbb3] | 78 | yes) build_threading="yes" ;; |
---|
[facc44f] | 79 | no) build_threading="no" ;; |
---|
| 80 | *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;; |
---|
| 81 | esac],[build_threading="yes"]) |
---|
[9def87a] | 82 | |
---|
| 83 | case "$enable_target_release" in |
---|
| 84 | yes) |
---|
| 85 | case "$enable_target_debug" in |
---|
| 86 | yes) |
---|
| 87 | build_release="yes" |
---|
| 88 | build_debug="yes" |
---|
| 89 | ;; |
---|
| 90 | no) |
---|
| 91 | build_release="yes" |
---|
| 92 | build_debug="no" |
---|
| 93 | ;; |
---|
| 94 | *) |
---|
| 95 | build_release="yes" |
---|
| 96 | build_debug="no" |
---|
| 97 | ;; |
---|
| 98 | esac |
---|
| 99 | ;; |
---|
| 100 | no) |
---|
| 101 | case "$enable_target_debug" in |
---|
| 102 | yes) |
---|
| 103 | build_release="no" |
---|
| 104 | build_debug="yes" |
---|
| 105 | ;; |
---|
| 106 | no) |
---|
[24f4671] | 107 | build_release="no" |
---|
| 108 | build_debug="no" |
---|
[9def87a] | 109 | ;; |
---|
| 110 | *) |
---|
| 111 | build_release="no" |
---|
| 112 | build_debug="yes" |
---|
| 113 | ;; |
---|
| 114 | esac |
---|
| 115 | ;; |
---|
| 116 | *) |
---|
| 117 | case "$enable_target_debug" in |
---|
| 118 | yes) |
---|
| 119 | build_release="no" |
---|
| 120 | build_debug="yes" |
---|
| 121 | ;; |
---|
| 122 | no) |
---|
| 123 | build_release="yes" |
---|
| 124 | build_debug="no" |
---|
| 125 | ;; |
---|
| 126 | *) |
---|
| 127 | build_release="yes" |
---|
| 128 | build_debug="yes" |
---|
| 129 | ;; |
---|
| 130 | esac |
---|
| 131 | ;; |
---|
| 132 | esac |
---|
| 133 | |
---|
| 134 | AM_CONDITIONAL([BUILD_RELEASE], [test "x$build_release" = "xyes"]) |
---|
| 135 | AM_CONDITIONAL([BUILD_DEBUG], [test "x$build_debug" = "xyes"]) |
---|
[24f4671] | 136 | AM_CONDITIONAL([BUILD_NO_LIB], [test "x$build_release$build_debug" = "xnono"]) |
---|
[facc44f] | 137 | AM_CONDITIONAL([BUILD_CONCURRENCY], [test "x$build_threading" = "xyes"]) |
---|
[9def87a] | 138 | |
---|
[5d6ce1f] | 139 | if test "x$prefix" = "xNONE"; then |
---|
[00cc023] | 140 | cfa_prefix=${ac_default_prefix} |
---|
[5d6ce1f] | 141 | else |
---|
[00cc023] | 142 | cfa_prefix=${prefix} |
---|
[ef7d253] | 143 | fi |
---|
[d3b7937] | 144 | AC_DEFINE_UNQUOTED(CFA_PREFIX, "${cfa_prefix}", [Location of cfa install.]) |
---|
[00cc023] | 145 | AC_SUBST(CFA_PREFIX, ${cfa_prefix}) |
---|
[5d6ce1f] | 146 | |
---|
| 147 | if test "$includedir" = '${prefix}/include'; then |
---|
[df47e2f] | 148 | cfa_incdir="${cfa_prefix}/include/${cfa_name}" |
---|
[5d6ce1f] | 149 | else |
---|
[faf8857] | 150 | cfa_incdir=${includedir} |
---|
[ef7d253] | 151 | fi |
---|
[5d6ce1f] | 152 | AC_DEFINE_UNQUOTED(CFA_INCDIR, "${cfa_incdir}", [Location of include files.]) |
---|
[00cc023] | 153 | AC_SUBST(CFA_INCDIR, ${cfa_incdir}) |
---|
[5d6ce1f] | 154 | |
---|
| 155 | if test "$bindir" = '${exec_prefix}/bin'; then |
---|
| 156 | cfa_bindir="${cfa_prefix}/bin" |
---|
| 157 | else |
---|
| 158 | cfa_bindir=${bindir} |
---|
[ef7d253] | 159 | fi |
---|
[5d6ce1f] | 160 | AC_DEFINE_UNQUOTED(CFA_BINDIR, "${cfa_bindir}", [Location of cfa command.]) |
---|
[00cc023] | 161 | AC_SUBST(CFA_BINDIR, ${cfa_bindir}) |
---|
[5d6ce1f] | 162 | |
---|
| 163 | if test "$libdir" = '${exec_prefix}/lib'; then |
---|
[df47e2f] | 164 | cfa_libdir="${cfa_prefix}/lib/${cfa_name}" |
---|
[5d6ce1f] | 165 | else |
---|
| 166 | cfa_libdir=${libdir} |
---|
[ef7d253] | 167 | fi |
---|
[5d6ce1f] | 168 | AC_DEFINE_UNQUOTED(CFA_LIBDIR, "${cfa_libdir}", [Location of cc1 and cfa-cpp commands.]) |
---|
[00cc023] | 169 | AC_SUBST(CFA_LIBDIR, ${cfa_libdir}) |
---|
[5d6ce1f] | 170 | |
---|
[3f414ef] | 171 | AC_CANONICAL_BUILD |
---|
[e4745d7a] | 172 | AC_CANONICAL_HOST |
---|
| 173 | AC_SUBST([MACHINE_TYPE],[$host_cpu]) |
---|
| 174 | |
---|
[3f414ef] | 175 | if ! test "$host_cpu" = "$build_cpu"; then |
---|
| 176 | case $host_cpu in |
---|
| 177 | i386) |
---|
| 178 | CFLAGS+="-m32" |
---|
| 179 | CXXFLAGS+="-m32" |
---|
| 180 | CFAFLAGS+="-m32" |
---|
| 181 | LDFLAGS+="-m32" |
---|
| 182 | ;; |
---|
| 183 | i686) |
---|
| 184 | CFLAGS+="-m32" |
---|
| 185 | CXXFLAGS+="-m32" |
---|
| 186 | CFAFLAGS+="-m32" |
---|
| 187 | LDFLAGS+="-m32" |
---|
| 188 | ;; |
---|
| 189 | x86_64) |
---|
| 190 | CFLAGS+="-m64" |
---|
| 191 | CXXFLAGS+="-m64" |
---|
| 192 | CFAFLAGS+="-m64" |
---|
| 193 | LDFLAGS+="-m64" |
---|
| 194 | ;; |
---|
| 195 | esac |
---|
| 196 | fi |
---|
| 197 | |
---|
| 198 | AC_DEFINE_UNQUOTED(CFA_FLAGS, "${CFAFLAGS}", [compilation flags for cfa libraries and test programs.]) |
---|
| 199 | AC_SUBST(CFA_FLAGS, ${CFAFLAGS}) |
---|
| 200 | |
---|
[5d6ce1f] | 201 | # Checks for programs. |
---|
| 202 | AC_PROG_CXX |
---|
| 203 | AC_PROG_CC |
---|
[8e5724e] | 204 | AM_PROG_AS |
---|
[00cc023] | 205 | AM_PROG_CC_C_O # deprecated |
---|
[c3a4385] | 206 | # These are often not installed and people miss seeing the "no", so stop the configure. |
---|
[56c3935] | 207 | AC_PROG_YACC |
---|
[c3a4385] | 208 | if test "${YACC}" = "yacc" ; then echo "Error: bison required." ; exit 1 ; fi |
---|
[56c3935] | 209 | AC_PROG_LEX |
---|
[c3a4385] | 210 | if test "${LEX}" = "lex" ; then echo "Error: flex required." ; exit 1 ; fi |
---|
[5d6ce1f] | 211 | AC_PROG_INSTALL |
---|
| 212 | AC_PROG_MAKE_SET |
---|
[00cc023] | 213 | AC_PROG_RANLIB |
---|
[5d6ce1f] | 214 | |
---|
| 215 | # Checks for libraries. |
---|
| 216 | |
---|
| 217 | # Checks for header files. |
---|
| 218 | AC_FUNC_ALLOCA |
---|
| 219 | AC_CHECK_HEADERS([fenv.h float.h inttypes.h libintl.h limits.h malloc.h stddef.h stdlib.h string.h unistd.h]) |
---|
| 220 | |
---|
| 221 | # Checks for typedefs, structures, and compiler characteristics. |
---|
| 222 | AC_HEADER_STDBOOL |
---|
| 223 | AC_C_INLINE |
---|
| 224 | AC_TYPE_INT16_T |
---|
| 225 | AC_TYPE_INT32_T |
---|
| 226 | AC_TYPE_INT8_T |
---|
| 227 | AC_C_RESTRICT |
---|
| 228 | AC_TYPE_SIZE_T |
---|
| 229 | AC_TYPE_UINT16_T |
---|
| 230 | AC_TYPE_UINT32_T |
---|
| 231 | AC_TYPE_UINT8_T |
---|
| 232 | |
---|
| 233 | # Checks for library functions. |
---|
| 234 | AC_CHECK_FUNCS([memset putenv strchr strtol]) |
---|
| 235 | |
---|
[00cc023] | 236 | AC_CONFIG_FILES([ |
---|
| 237 | Makefile |
---|
[6e7e2b36] | 238 | src/driver/Makefile |
---|
[00cc023] | 239 | src/Makefile |
---|
[ac93b228] | 240 | src/benchmark/Makefile |
---|
[00cc023] | 241 | src/examples/Makefile |
---|
[ef7d253] | 242 | src/tests/Makefile |
---|
[375a068] | 243 | src/prelude/Makefile |
---|
[6e7e2b36] | 244 | src/libcfa/Makefile |
---|
[00cc023] | 245 | ]) |
---|
[5d6ce1f] | 246 | |
---|
| 247 | AC_OUTPUT |
---|
[7e91d4f] | 248 | |
---|
[9def87a] | 249 | AM_COND_IF([BUILD_RELEASE], |
---|
| 250 | [AM_COND_IF([BUILD_DEBUG], |
---|
| 251 | [AC_MSG_NOTICE(Building libcfa for target: release & debug)], |
---|
| 252 | [AC_MSG_NOTICE(Building libcfa for target: release)])], |
---|
[24f4671] | 253 | [AM_COND_IF([BUILD_DEBUG], |
---|
| 254 | [AC_MSG_NOTICE(Building libcfa for target: debug)], |
---|
| 255 | [AC_MSG_NOTICE(Running cfa without libcfa)])]) |
---|
[9def87a] | 256 | |
---|
[5d6ce1f] | 257 | # Final text |
---|
| 258 | AC_MSG_RESULT(Cforall configuraton completed. Type "make -j 8 install".) |
---|