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_HEADERS([config.h:src/config.h.in]) |
---|
9 | AM_SILENT_RULES([yes]) |
---|
10 | |
---|
11 | m4_include([tools/build/cfa.m4]) |
---|
12 | |
---|
13 | # don't use the default CFLAGS as they unconditonnaly add -O2 |
---|
14 | : ${CFLAGS=""} |
---|
15 | : ${CXXFLAGS=""} |
---|
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 | # 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 | AC_ARG_WITH(bwlimit, |
---|
67 | [ --with-bwlimit=RATE RATE the maximum rate at which rsync will be limited when using distributed builds], |
---|
68 | [], []) |
---|
69 | |
---|
70 | AM_CONDITIONAL([ENABLE_DISTCC], [test x$enable_distcc = xyes]) |
---|
71 | HAS_DISTCC="False" |
---|
72 | |
---|
73 | if test x$enable_distcc = xyes; then |
---|
74 | CXX="distcc ${CXX}" |
---|
75 | LD="distcc ${LD} -lstdc++" |
---|
76 | HAS_DISTCC="True" |
---|
77 | echo "Enabling distributed builds" |
---|
78 | fi |
---|
79 | |
---|
80 | AC_SUBST(CXX) |
---|
81 | AC_SUBST(LD) |
---|
82 | AC_SUBST(HAS_DISTCC) |
---|
83 | |
---|
84 | #============================================================================== |
---|
85 | # Installation paths |
---|
86 | M4CFA_PARSE_PREFIX |
---|
87 | |
---|
88 | #============================================================================== |
---|
89 | # Create variables for commonly used targets |
---|
90 | |
---|
91 | TOP_SRCDIR="$(readlink -m $ac_confdir/)/" |
---|
92 | TOP_BUILDDIR="$(readlink -m $ac_pwd/)/" |
---|
93 | |
---|
94 | AC_DEFINE_UNQUOTED(TOP_SRCDIR, "$TOP_SRCDIR", [Top src directory]) |
---|
95 | AC_DEFINE_UNQUOTED(TOP_BUILDDIR, "$TOP_BUILDDIR", [Top build directory]) |
---|
96 | |
---|
97 | DRIVER_DIR=${TOP_BUILDDIR}driver/ |
---|
98 | CFACC=${DRIVER_DIR}cfa |
---|
99 | CFACC_INSTALL=${CFA_BINDIR}${CFA_NAME} |
---|
100 | CFACPP=${DRIVER_DIR}cfa-cpp |
---|
101 | AC_SUBST(DRIVER_DIR) |
---|
102 | AC_SUBST(CFACC) |
---|
103 | AC_SUBST(CFACC_INSTALL) |
---|
104 | AC_SUBST(CFACPP) |
---|
105 | |
---|
106 | #============================================================================== |
---|
107 | # Flag variables needed to build in tree |
---|
108 | LIBCFA_SRC='${TOP_SRCDIR}/libcfa/src' |
---|
109 | BUILD_IN_TREE_FLAGS="-XCFA -t -B${DRIVER_DIR}" |
---|
110 | AC_SUBST(BUILD_IN_TREE_FLAGS) |
---|
111 | |
---|
112 | #============================================================================== |
---|
113 | # handle the list of hosts to build for |
---|
114 | for var in $ac_configure_args |
---|
115 | do |
---|
116 | #strip quotes surrouding values |
---|
117 | case $var in |
---|
118 | # skip cross compilation related arguments |
---|
119 | \'--host=*) ;; \'host_alias=*) ;; \'--build=*) ;; \'build_alias=*) ;; \'--target=*) ;; \'target_alias=*) ;; |
---|
120 | |
---|
121 | # skip the target hosts |
---|
122 | \'--with-target-hosts=*) ;; |
---|
123 | |
---|
124 | # skip gprofiler for libcfa |
---|
125 | \'--enable-gprofiler=*) ;; |
---|
126 | \'--disable-gprofiler) ;; |
---|
127 | |
---|
128 | # append all other arguments to the sub configure arguments |
---|
129 | *) LIBCFA_GENERAL_ARGS="${LIBCFA_GENERAL_ARGS} $var";; |
---|
130 | esac |
---|
131 | done |
---|
132 | |
---|
133 | #============================================================================== |
---|
134 | # handle the list of hosts to build for |
---|
135 | AC_CANONICAL_BUILD |
---|
136 | AC_CANONICAL_HOST |
---|
137 | |
---|
138 | if ! test "$host_cpu" = "$build_cpu"; then |
---|
139 | case $host_cpu in |
---|
140 | i386) |
---|
141 | HOST_FLAGS="-m32" |
---|
142 | ;; |
---|
143 | i686) |
---|
144 | HOST_FLAGS="-m32" |
---|
145 | ;; |
---|
146 | x86_64) |
---|
147 | HOST_FLAGS="-m64" |
---|
148 | ;; |
---|
149 | esac |
---|
150 | fi |
---|
151 | AC_SUBST(HOST_FLAGS) |
---|
152 | |
---|
153 | default_target="${host_cpu}:debug, ${host_cpu}:nodebug" |
---|
154 | AC_ARG_WITH(target-hosts, |
---|
155 | [ --with-target-hosts=HOSTS HOSTS comma seperated list of hosts to build for, format ARCH:[debug|nodebug|nolib]], |
---|
156 | target_hosts=$withval, target_hosts=${default_target}) |
---|
157 | |
---|
158 | AC_ARG_ENABLE(gprofiler, |
---|
159 | [ --enable-gprofiler whether or not to enable gprofiler tools (if available)], |
---|
160 | enable_gprofiler=$enableval, enable_gprofiler=yes) |
---|
161 | |
---|
162 | AC_ARG_ENABLE(demangler, |
---|
163 | [ --enable-demangler whether or not to build the demangler (executable and library)], |
---|
164 | enable_demangler=$enableval, enable_demangler=yes) |
---|
165 | |
---|
166 | AC_SUBST(TARGET_HOSTS, ${target_hosts}) |
---|
167 | |
---|
168 | LIBCFA_PATHS="DRIVER_DIR=${DRIVER_DIR}" |
---|
169 | |
---|
170 | for i in $(echo $target_hosts | sed "s/,/ /g") |
---|
171 | do |
---|
172 | # call your procedure/other scripts here below |
---|
173 | arch_name=$(echo $i | sed -r "s/:(.*)//g") |
---|
174 | lib_config=$(echo $i | sed -r "s/(.*)://g") |
---|
175 | |
---|
176 | case $lib_config in |
---|
177 | "nodebug") ;; |
---|
178 | "debug") ;; |
---|
179 | "nolib") ;; |
---|
180 | "profile") ;; |
---|
181 | *) |
---|
182 | >&2 echo "Configuration must be 'debug', 'nodebug' or 'nolib'" |
---|
183 | exit 1 |
---|
184 | ;; |
---|
185 | esac |
---|
186 | |
---|
187 | M4CFA_CANNON_CPU([${arch_name}]) |
---|
188 | lib_arch=${cannon_arch_name} |
---|
189 | lib_dir="libcfa/${lib_arch}-${lib_config}" |
---|
190 | |
---|
191 | LIBCFA_TARGET_DIRS="${LIBCFA_TARGET_DIRS} ${lib_dir}" |
---|
192 | LIBCFA_TARGET_MAKEFILES="${LIBCFA_TARGET_MAKEFILES} ${lib_dir}/Makefile" |
---|
193 | |
---|
194 | mkdir -p ${lib_dir} |
---|
195 | echo -n "${LIBCFA_GENERAL_ARGS} " > ${lib_dir}/config.data |
---|
196 | echo -n "${LIBCFA_PATHS} " >> ${lib_dir}/config.data |
---|
197 | echo -n "ARCHITECTURE=${lib_arch} " >> ${lib_dir}/config.data |
---|
198 | echo -n "CONFIGURATION=${lib_config} " >> ${lib_dir}/config.data |
---|
199 | echo -n "CFA_VERSION=${ver_major}:${ver_minor}:${ver_patch}" >> ${lib_dir}/config.data |
---|
200 | done |
---|
201 | |
---|
202 | AC_SUBST(LIBCFA_TARGET_DIRS) |
---|
203 | AC_SUBST(LIBCFA_TARGET_MAKEFILES) |
---|
204 | |
---|
205 | M4CFA_CANNON_CPU([${host_cpu}]) |
---|
206 | AC_DEFINE_UNQUOTED(CFA_DEFAULT_CPU, "$cannon_arch_name", [Default cpu to use if neither -m32 or -m64 are defined.]) |
---|
207 | AC_DEFINE_UNQUOTED(CFA_64_CPU, "x64", [CPU to use if the -m64 flags is given.]) |
---|
208 | AC_DEFINE_UNQUOTED(CFA_32_CPU, "x86", [CPU to use if the -m32 flags is given.]) |
---|
209 | |
---|
210 | #============================================================================== |
---|
211 | # CAFLAGS |
---|
212 | AC_DEFINE_UNQUOTED(CFA_FLAGS, "${CFAFLAGS}", [compilation flags for cfa libraries and test programs.]) |
---|
213 | AC_SUBST(CFA_FLAGS, ${CFAFLAGS}) |
---|
214 | |
---|
215 | #============================================================================== |
---|
216 | # Checks for programs. |
---|
217 | AC_PROG_CXX |
---|
218 | AC_PROG_CC |
---|
219 | AM_PROG_AS |
---|
220 | # These are often not installed and people miss seeing the "no", so stop the configure. |
---|
221 | AC_PROG_YACC |
---|
222 | if test "${YACC}" = "yacc" ; then echo "Error: bison required." ; exit 1 ; fi |
---|
223 | AC_PROG_LEX |
---|
224 | if test "${LEX}" = "lex" ; then echo "Error: flex required." ; exit 1 ; fi |
---|
225 | AC_PROG_LIBTOOL |
---|
226 | AC_PROG_INSTALL |
---|
227 | |
---|
228 | # Checks for libraries. |
---|
229 | AC_CHECK_LIB([fibre], [Fibre::yield], [HAVE_LIBFIBRE=1], [HAVE_LIBFIBRE=0]) |
---|
230 | AM_CONDITIONAL([WITH_LIBFIBRE], [test "$HAVE_LIBFIBRE" -eq 1]) |
---|
231 | |
---|
232 | AC_CHECK_LIB([profiler], [ProfilingIsEnabledForAllThreads], [HAVE_LIBPROFILER=1], [HAVE_LIBPROFILER=0]) |
---|
233 | AM_CONDITIONAL([WITH_LIBPROFILER], [test "x$enable_gprofiler" = "xyes" -a "$HAVE_LIBPROFILER" -eq 1]) |
---|
234 | |
---|
235 | AC_CHECK_LIB([tcmalloc], [malloc], [HAVE_LIBTCMALLOC=1], [HAVE_LIBTCMALLOC=0]) |
---|
236 | AM_CONDITIONAL([WITH_LIBTCMALLOC], [test "x$enable_gprofiler" = "xyes" -a "$HAVE_LIBTCMALLOC" -eq 1]) |
---|
237 | |
---|
238 | # conditionnally build the demangler |
---|
239 | if test "x$enable_demangler" == xyes; then |
---|
240 | LIBDEMANGLE="libdemangle.a" |
---|
241 | DEMANGLER="demangler" |
---|
242 | else |
---|
243 | LIBDEMANGLE="" |
---|
244 | DEMANGLER="" |
---|
245 | fi |
---|
246 | AC_SUBST([LIBDEMANGLE]) |
---|
247 | AC_SUBST([DEMANGLER]) |
---|
248 | |
---|
249 | # Checks for header files. |
---|
250 | AC_CHECK_HEADERS([libintl.h malloc.h unistd.h], [], [echo "Error: Missing required header"; exit 1]) |
---|
251 | |
---|
252 | # Checks for typedefs, structures, and compiler characteristics. |
---|
253 | AC_CHECK_TYPES([_Float32], AC_DEFINE([HAVE_KEYWORDS_FLOATXX], [], [Have keywords _FloatXX.]), [], [[]]) |
---|
254 | |
---|
255 | # Checks for compiler flags. |
---|
256 | M4CFA_CHECK_COMPILE_FLAG([-Wcast-function-type], AC_DEFINE([HAVE_CAST_FUNCTION_TYPE], [], [Have compiler warning cast-function-type.])) |
---|
257 | |
---|
258 | #============================================================================== |
---|
259 | # backend compiler implementation |
---|
260 | AC_DEFINE_UNQUOTED(CFA_BACKEND_CC, "${CC}", [Backend compiler to use.]) |
---|
261 | AC_SUBST(CFA_BACKEND_CC) |
---|
262 | |
---|
263 | #============================================================================== |
---|
264 | AC_CONFIG_FILES([ |
---|
265 | Makefile |
---|
266 | driver/Makefile |
---|
267 | src/Makefile |
---|
268 | benchmark/Makefile |
---|
269 | tests/Makefile |
---|
270 | longrun_tests/Makefile |
---|
271 | tools/Makefile |
---|
272 | tools/prettyprinter/Makefile |
---|
273 | ]) |
---|
274 | |
---|
275 | AC_CONFIG_LINKS([tests/test.py:tests/test.py]) |
---|
276 | |
---|
277 | AC_OUTPUT(tests/config.py) |
---|
278 | |
---|
279 | # Final text |
---|
280 | AC_MSG_RESULT(Cforall configuraton completed. Type "make -j 8 install".) |
---|