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