3 AT_BANNER([C low level compiling/preprocessing macros.])
5 # Copyright (C) 2000-2006, 2008-2014 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)
127 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>]])],
128 [AC_DEFINE([HAVE_STDIO_H], [1], [Define if you have stdio.h])])
129 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <autoconf_io.h>]])],
130 [AC_DEFINE([HAVE_AUTOCONF_IO_H], [1], [Define if you have autoconf_io.h])])
133 [/* #undef HAVE_AUTOCONF_IO_H */
134 #define HAVE_STDIO_H 1
140 ## ------------------------------ ##
141 ## AC_PROG_CPP without warnings. ##
142 ## ------------------------------ ##
144 AT_SETUP([AC_PROG_CPP without warnings])
146 # Ignore if the cpp in $PATH doesn't work
147 AT_CHECK([[echo '#include <stdio.h>' | cpp || exit 77]],
148 [], [ignore], [ignore])
150 # A cpp which exit status is meaningless.
162 test "x$ac_c_preproc_warn_flag" != xyes &&
163 AC_MSG_ERROR([failed to detect preprocessor warning option])
166 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>]])],
167 [AC_DEFINE([HAVE_STDIO_H], [1], [Define if you have stdio.h])])
168 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <autoconf_io.h>]])],
169 [AC_DEFINE([HAVE_AUTOCONF_IO_H], [1], [Define if you have autoconf_io.h])])
173 [/* #undef HAVE_AUTOCONF_IO_H */
174 #define HAVE_STDIO_H 1
181 ## -------------------- ##
182 ## AC_PROG_CPP via CC. ##
183 ## -------------------- ##
186 # It's Ok for strict preprocessors to produce warnings.
188 AT_SETUP([AC_PROG_CPP via CC])
190 # Ignore if the cpp in $PATH doesn't work
191 AT_CHECK([[echo '#include <stdio.h>' | cpp || exit 77]],
192 [], [ignore], [ignore])
196 echo "Annoying copyright message" >&2
202 # We go through the following contortions, in order to have the
203 # configure script go down the same codepaths as it would during a
204 # normal CPP selection check. If we explicitly set CPP, it goes down
205 # a different codepath.
210 # The test $CC compiler should have been selected.
211 test "$CPP" != "$CC -E" &&
212 AC_MSG_ERROR([error messages on stderr cause the preprocessor selection to fail])
215 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>]])],
216 [AC_DEFINE([HAVE_STDIO_H], [1], [Define if you have stdio.h])])
217 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <autoconf_io.h>]])],
218 [AC_DEFINE([HAVE_AUTOCONF_IO_H], [1], [Define if you have autoconf_io.h])])
222 [/* #undef HAVE_AUTOCONF_IO_H */
223 #define HAVE_STDIO_H 1
229 ## ------------------------------------ ##
230 ## AC_NO_EXECUTABLES (working linker). ##
231 ## ------------------------------------ ##
233 AT_CHECK_MACRO([AC_NO_EXECUTABLES (working linker)],
239 ## ----------------------------------- ##
240 ## AC_NO_EXECUTABLES (broken linker). ##
241 ## ----------------------------------- ##
243 AT_CHECK_MACRO([AC_NO_EXECUTABLES (broken linker)],
244 [LDFLAGS=-lnosuchlibrary
250 ## -------------------------- ##
251 ## AC_USE_SYSTEM_EXTENSIONS. ##
252 ## -------------------------- ##
254 AT_SETUP([AC_USE_SYSTEM_EXTENSIONS])
256 # Some existing configure.ac mixed AC_AIX (now an alias for
257 # AC_USE_SYSTEM_EXTENSIONS) and AC_DEFINE([__EXTENSIONS__]), which
258 # broke autoheader in 2.62. Test that this is supported.
262 AC_DEFINE([__EXTENSIONS__], [1], [Manually defined for Solaris])
266 [[AC_USE_SYSTEM_EXTENSIONS
267 AC_DEFINE([__EXTENSIONS__], [1], [Manually defined for Solaris])
273 ## ----------------------- ##
274 ## AC_C_RESTRICT and C++. ##
275 ## ----------------------- ##
277 AT_SETUP([AC_C_RESTRICT and C++])
279 # In some compiler suites, the left hand doesn't know about everything
280 # the right hand does; or the user mixes the C compiler from one suite
281 # with the C++ compiler from another. In this case, Sun WorkShop CC
282 # not like the _Restrict accepted by cc.
284 AT_DATA([configure.ac],
289 AC_CONFIG_HEADERS([config.h])
290 AC_CONFIG_FILES([Makefile])
294 AT_DATA([Makefile.in],
298 CXXFLAGS = @CXXFLAGS@
299 CPPFLAGS = -I. @CPPFLAGS@
301 all: foo.$(OBJEXT) bar.$(OBJEXT)
303 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c cpp-works.cpp
305 $(CC) $(CPPFLAGS) $(CFLAGS) -c foo.c
306 bar.$(OBJEXT): bar.cpp
307 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c bar.cpp
311 [[#include <config.h>
313 int foo (int * restrict i1, int * restrict i2)
315 return i1[0] + i2[0];
321 AT_DATA([cpp-works.cpp],
322 [[// This file is just to test whether we have a working C++ compiler at all
323 class foo { int x; };
328 AT_CHECK([autoheader])
329 AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
330 AT_CHECK([${MAKE-make} cpp-works || exit 77], [], [ignore], [ignore])
331 AT_CHECK([${MAKE-make}], [], [ignore], [ignore])
336 ## ---------------- ##
337 ## AC_OPENMP and C. ##
338 ## ---------------- ##
340 AT_SETUP([AC_OPENMP and C])
342 AT_DATA([configure.ac],
346 if test "X$ac_cv_prog_c_openmp" = Xunsupported; then
349 CFLAGS="$CFLAGS $OPENMP_CFLAGS"
350 CPPFLAGS="$CPPFLAGS $OPENMP_CFLAGS"
351 AC_CONFIG_FILES([Makefile])
355 AT_DATA([Makefile.in],
356 [[foo@EXEEXT@: foo.@OBJEXT@
357 @CC@ @CFLAGS@ @LDFLAGS@ -o $@ foo.@OBJEXT@
360 @CC@ @CPPFLAGS@ @CFLAGS@ -c foo.c
374 int id = omp_get_thread_num ();
375 printf ("hello omp world from %d\n", id);
383 AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
384 AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
385 AT_CHECK([$MAKE], [], [ignore], [ignore])
390 ## ------------------ ##
391 ## AC_OPENMP anc C++. ##
392 ## ------------------ ##
394 AT_SETUP([AC_OPENMP and C++])
396 AT_DATA([configure.ac],
401 if test "X$ac_cv_prog_cxx_openmp" = Xunsupported; then
404 CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
405 CPPFLAGS="$CPPFLAGS $OPENMP_CXXFLAGS"
406 AC_CONFIG_FILES([Makefile])
410 AT_DATA([Makefile.in],
411 [[foo@EXEEXT@: foo.@OBJEXT@
412 @CXX@ @CXXFLAGS@ @LDFLAGS@ -o $@ foo.@OBJEXT@
414 foo.@OBJEXT@: foo.cpp
415 @CXX@ @CPPFLAGS@ @CXXFLAGS@ -c foo.cpp
426 AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
427 AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
428 AT_CHECK([$MAKE], [], [ignore], [ignore])