3 AT_BANNER([C low level compiling/preprocessing macros.])
5 # Copyright (C) 2000-2006, 2008-2013 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # Since the macros which compile are required by most tests, check
22 # them first. But remember that looking for a compiler is even more
23 # primitive, so check those first.
30 # As far as we know only `foo', `foo.exe' are possible executable,
31 # and `foo.o', `foo.obj' are possible object files. Autoconf must not
32 # know that, but it is OK for the test suite to take this into account.
33 AT_CHECK_MACRO([Extensions],
37 * ) AC_MSG_ERROR([suspicious executable suffix: $ac_exeext]);;
42 * ) AC_MSG_ERROR([suspicious object suffix: $ac_objext]);;
48 ## -------------------------- ##
49 ## Broken/missing compilers. ##
50 ## -------------------------- ##
53 # Check that Autoconf correctly diagnoses broken compilers, and in
54 # particular, if it does not exit 77, the test suite is in trouble...
55 # FIXME: Once a precise message decided, check stderr of configure.
56 AT_SETUP([Broken/missing compilers])
58 AT_DATA([configure.ac],
65 AT_CHECK_CONFIGURE([], 77, ignore, ignore)
74 # GCC supports `const', `typeof', and `volatile'.
75 AT_CHECK_MACRO([C keywords],
80 case $GCC,$ac_cv_c_const,$ac_cv_c_typeof,$ac_cv_c_volatile in
82 AC_MSG_ERROR([failed to detect `const', `typeof', or `volatile' support]);;
88 ## --------------------------------- ##
89 ## AC_PROG_CPP requires AC_PROG_CC. ##
90 ## --------------------------------- ##
92 # Must invoke AC_PROG_CC.
93 AT_CHECK_MACRO([AC_PROG_CPP requires AC_PROG_CC],
96 AC_MSG_ERROR([looked for a C preprocessor without looking for a compiler])
101 ## --------------------------- ##
102 ## AC_PROG_CPP with warnings. ##
103 ## --------------------------- ##
106 # It's Ok for strict preprocessors to produce warnings.
108 AT_SETUP([AC_PROG_CPP with warnings])
120 # If the preprocessor is not strict, just ignore
121 test "x$ac_c_preproc_warn_flag" = xyes &&
122 AC_MSG_ERROR([preprocessor has no warning option], 77)
126 AC_CHECK_HEADERS(stdio.h autoconf_io.h, [], [], [-])]])
129 [/* #undef HAVE_AUTOCONF_IO_H */
130 #define HAVE_STDIO_H 1
136 ## ------------------------------ ##
137 ## AC_PROG_CPP without warnings. ##
138 ## ------------------------------ ##
140 AT_SETUP([AC_PROG_CPP without warnings])
142 # Ignore if /lib/cpp doesn't work
143 AT_CHECK([[echo '#include <stdio.h>' | /lib/cpp || exit 77]],
144 [], [ignore], [ignore])
146 # A cpp which exit status is meaningless.
158 test "x$ac_c_preproc_warn_flag" != xyes &&
159 AC_MSG_ERROR([failed to detect preprocessor warning option])
162 AC_CHECK_HEADERS(stdio.h autoconf_io.h, [], [], [-])]])
165 [/* #undef HAVE_AUTOCONF_IO_H */
166 #define HAVE_STDIO_H 1
173 ## -------------------- ##
174 ## AC_PROG_CPP via CC. ##
175 ## -------------------- ##
178 # It's Ok for strict preprocessors to produce warnings.
180 AT_SETUP([AC_PROG_CPP via CC])
182 # Ignore if /lib/cpp doesn't work
183 AT_CHECK([[echo '#include <stdio.h>' | /lib/cpp || exit 77]],
184 [], [ignore], [ignore])
188 echo "Annoying copyright message" >&2
194 # We go through the following contortions, in order to have the
195 # configure script go down the same codepaths as it would during a
196 # normal CPP selection check. If we explicitly set CPP, it goes down
197 # a different codepath.
202 # The test $CC compiler should have been selected.
203 test "$CPP" != "$CC -E" &&
204 AC_MSG_ERROR([error messages on stderr cause the preprocessor selection to fail])
207 AC_CHECK_HEADERS(stdio.h autoconf_io.h, [], [], [-])]])
210 [/* #undef HAVE_AUTOCONF_IO_H */
211 #define HAVE_STDIO_H 1
217 ## ------------------------------------ ##
218 ## AC_NO_EXECUTABLES (working linker). ##
219 ## ------------------------------------ ##
221 AT_CHECK_MACRO([AC_NO_EXECUTABLES (working linker)],
227 ## ----------------------------------- ##
228 ## AC_NO_EXECUTABLES (broken linker). ##
229 ## ----------------------------------- ##
231 AT_CHECK_MACRO([AC_NO_EXECUTABLES (broken linker)],
232 [LDFLAGS=-lnosuchlibrary
238 ## -------------------------- ##
239 ## AC_USE_SYSTEM_EXTENSIONS. ##
240 ## -------------------------- ##
242 AT_SETUP([AC_USE_SYSTEM_EXTENSIONS])
244 # Some existing configure.ac mixed AC_AIX (now an alias for
245 # AC_USE_SYSTEM_EXTENSIONS) and AC_DEFINE([__EXTENSIONS__]), which
246 # broke autoheader in 2.62. Test that this is supported.
250 AC_DEFINE([__EXTENSIONS__], [1], [Manually defined for Solaris])
254 [[AC_USE_SYSTEM_EXTENSIONS
255 AC_DEFINE([__EXTENSIONS__], [1], [Manually defined for Solaris])
261 ## ----------------------- ##
262 ## AC_C_RESTRICT and C++. ##
263 ## ----------------------- ##
265 AT_SETUP([AC_C_RESTRICT and C++])
267 # In some compiler suites, the left hand doesn't know about everything
268 # the right hand does; or the user mixes the C compiler from one suite
269 # with the C++ compiler from another. In this case, Sun WorkShop CC
270 # not like the _Restrict accepted by cc.
272 AT_DATA([configure.ac],
277 AC_CONFIG_HEADERS([config.h])
278 AC_CONFIG_FILES([Makefile])
282 AT_DATA([Makefile.in],
286 CXXFLAGS = @CXXFLAGS@
287 CPPFLAGS = -I. @CPPFLAGS@
289 all: foo.$(OBJEXT) bar.$(OBJEXT)
291 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c cpp-works.cpp
293 $(CC) $(CPPFLAGS) $(CFLAGS) -c foo.c
294 bar.$(OBJEXT): bar.cpp
295 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c bar.cpp
299 [[#include <config.h>
301 int foo (int * restrict i1, int * restrict i2)
303 return i1[0] + i2[0];
309 AT_DATA([cpp-works.cpp],
310 [[// This file is just to test whether we have a working C++ compiler at all
311 class foo { int x; };
316 AT_CHECK([autoheader])
317 AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
318 AT_CHECK([${MAKE-make} cpp-works || exit 77], [], [ignore], [ignore])
319 AT_CHECK([${MAKE-make}], [], [ignore], [ignore])
324 ## ---------------- ##
325 ## AC_OPENMP and C. ##
326 ## ---------------- ##
328 AT_SETUP([AC_OPENMP and C])
330 AT_DATA([configure.ac],
334 if test "X$ac_cv_prog_c_openmp" = Xunsupported; then
337 CFLAGS="$CFLAGS $OPENMP_CFLAGS"
338 CPPFLAGS="$CPPFLAGS $OPENMP_CFLAGS"
339 AC_CONFIG_FILES([Makefile])
343 AT_DATA([Makefile.in],
344 [[foo@EXEEXT@: foo.@OBJEXT@
345 @CC@ @CFLAGS@ @LDFLAGS@ -o $@ foo.@OBJEXT@
348 @CC@ @CPPFLAGS@ @CFLAGS@ -c foo.c
362 int id = omp_get_thread_num ();
363 printf ("hello omp world from %d\n", id);
371 AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
372 AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
373 AT_CHECK([$MAKE], [], [ignore], [ignore])
378 ## ------------------ ##
379 ## AC_OPENMP anc C++. ##
380 ## ------------------ ##
382 AT_SETUP([AC_OPENMP and C++])
384 AT_DATA([configure.ac],
389 if test "X$ac_cv_prog_cxx_openmp" = Xunsupported; then
392 CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
393 CPPFLAGS="$CPPFLAGS $OPENMP_CXXFLAGS"
394 AC_CONFIG_FILES([Makefile])
398 AT_DATA([Makefile.in],
399 [[foo@EXEEXT@: foo.@OBJEXT@
400 @CXX@ @CXXFLAGS@ @LDFLAGS@ -o $@ foo.@OBJEXT@
402 foo.@OBJEXT@: foo.cpp
403 @CXX@ @CPPFLAGS@ @CXXFLAGS@ -c foo.cpp
414 AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
415 AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
416 AT_CHECK([$MAKE], [], [ignore], [ignore])