3 AT_BANNER([C low level compiling/preprocessing macros.])
5 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009,
6 # 2010 Free Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # Since the macros which compile are required by most tests, check
23 # them first. But remember that looking for a compiler is even more
24 # primitive, so check those first.
31 # As far as we know only `foo', `foo.exe' are possible executable,
32 # and `foo.o', `foo.obj' are possible object files. Autoconf must not
33 # know that, but it is OK for the test suite to take this into account.
34 AT_CHECK_MACRO([Extensions],
38 * ) AC_MSG_ERROR([suspicious executable suffix: $ac_exeext]);;
43 * ) AC_MSG_ERROR([suspicious object suffix: $ac_objext]);;
49 ## -------------------------- ##
50 ## Broken/missing compilers. ##
51 ## -------------------------- ##
54 # Check that Autoconf correctly diagnoses broken compilers, and in
55 # particular, if it does not exit 77, the test suite is in trouble...
56 # FIXME: Once a precise message decided, check stderr of configure.
57 AT_SETUP([Broken/missing compilers])
59 AT_DATA([configure.ac],
66 AT_CHECK_CONFIGURE([], 77, ignore, ignore)
75 # GCC supports `const', `typeof', and `volatile'.
76 AT_CHECK_MACRO([C keywords],
81 case $GCC,$ac_cv_c_const,$ac_cv_c_typeof,$ac_cv_c_volatile in
83 AC_MSG_ERROR([failed to detect `const', `typeof', or `volatile' support]);;
89 ## --------------------------------- ##
90 ## AC_PROG_CPP requires AC_PROG_CC. ##
91 ## --------------------------------- ##
93 # Must invoke AC_PROG_CC.
94 AT_CHECK_MACRO([AC_PROG_CPP requires AC_PROG_CC],
97 AC_MSG_ERROR([looked for a C preprocessor without looking for a compiler])
102 ## --------------------------- ##
103 ## AC_PROG_CPP with warnings. ##
104 ## --------------------------- ##
107 # It's Ok for strict preprocessors to produce warnings.
109 AT_SETUP([AC_PROG_CPP with warnings])
121 # If the preprocessor is not strict, just ignore
122 test "x$ac_c_preproc_warn_flag" = xyes &&
123 AC_MSG_ERROR([preprocessor has no warning option], 77)
127 AC_CHECK_HEADERS(stdio.h autoconf_io.h, [], [], [-])]])
130 [/* #undef HAVE_AUTOCONF_IO_H */
131 #define HAVE_STDIO_H 1
137 ## ------------------------------ ##
138 ## AC_PROG_CPP without warnings. ##
139 ## ------------------------------ ##
141 AT_SETUP([AC_PROG_CPP without warnings])
143 # Ignore if /lib/cpp doesn't work
144 AT_CHECK([[echo '#include <stdio.h>' | /lib/cpp || exit 77]],
145 [], [ignore], [ignore])
147 # A cpp which exit status is meaningless.
159 test "x$ac_c_preproc_warn_flag" != xyes &&
160 AC_MSG_ERROR([failed to detect preprocessor warning option])
163 AC_CHECK_HEADERS(stdio.h autoconf_io.h, [], [], [-])]])
166 [/* #undef HAVE_AUTOCONF_IO_H */
167 #define HAVE_STDIO_H 1
174 ## -------------------- ##
175 ## AC_PROG_CPP via CC. ##
176 ## -------------------- ##
179 # It's Ok for strict preprocessors to produce warnings.
181 AT_SETUP([AC_PROG_CPP via CC])
183 # Ignore if /lib/cpp doesn't work
184 AT_CHECK([[echo '#include <stdio.h>' | /lib/cpp || exit 77]],
185 [], [ignore], [ignore])
189 echo "Annoying copyright message" >&2
195 # We go through the following contortions, in order to have the
196 # configure script go down the same codepaths as it would during a
197 # normal CPP selection check. If we explicitly set CPP, it goes down
198 # a different codepath.
203 # The test $CC compiler should have been selected.
204 test "$CPP" != "$CC -E" &&
205 AC_MSG_ERROR([error messages on stderr cause the preprocessor selection to fail])
208 AC_CHECK_HEADERS(stdio.h autoconf_io.h, [], [], [-])]])
211 [/* #undef HAVE_AUTOCONF_IO_H */
212 #define HAVE_STDIO_H 1
218 ## ------------------------------------ ##
219 ## AC_NO_EXECUTABLES (working linker). ##
220 ## ------------------------------------ ##
222 AT_CHECK_MACRO([AC_NO_EXECUTABLES (working linker)],
228 ## ----------------------------------- ##
229 ## AC_NO_EXECUTABLES (broken linker). ##
230 ## ----------------------------------- ##
232 AT_CHECK_MACRO([AC_NO_EXECUTABLES (broken linker)],
233 [LDFLAGS=-lnosuchlibrary
239 ## -------------------------- ##
240 ## AC_USE_SYSTEM_EXTENSIONS. ##
241 ## -------------------------- ##
243 AT_SETUP([AC_USE_SYSTEM_EXTENSIONS])
245 # Some existing configure.ac mixed AC_AIX (now an alias for
246 # AC_USE_SYSTEM_EXTENSIONS) and AC_DEFINE([__EXTENSIONS__]), which
247 # broke autoheader in 2.62. Test that this is supported.
251 AC_DEFINE([__EXTENSIONS__], [1], [Manually defined for Solaris])
255 [[AC_USE_SYSTEM_EXTENSIONS
256 AC_DEFINE([__EXTENSIONS__], [1], [Manually defined for Solaris])
262 ## ----------------------- ##
263 ## AC_C_RESTRICT and C++. ##
264 ## ----------------------- ##
266 AT_SETUP([AC_C_RESTRICT and C++])
268 # In some compiler suites, the left hand doesn't know about everything
269 # the right hand does; or the user mixes the C compiler from one suite
270 # with the C++ compiler from another. In this case, Sun WorkShop CC
271 # not like the _Restrict accepted by cc.
273 AT_DATA([configure.ac],
278 AC_CONFIG_HEADERS([config.h])
279 AC_CONFIG_FILES([Makefile])
283 AT_DATA([Makefile.in],
287 CXXFLAGS = @CXXFLAGS@
288 CPPFLAGS = -I. @CPPFLAGS@
290 all: foo.$(OBJEXT) bar.$(OBJEXT)
292 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c cpp-works.cpp
294 $(CC) $(CPPFLAGS) $(CFLAGS) -c foo.c
295 bar.$(OBJEXT): bar.cpp
296 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c bar.cpp
300 [[#include <config.h>
302 int foo (int * restrict i1, int * restrict i2)
304 return i1[0] + i2[0];
310 AT_DATA([cpp-works.cpp],
311 [[// This file is just to test whether we have a working C++ compiler at all
312 class foo { int x; };
317 AT_CHECK([autoheader])
318 AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
319 AT_CHECK([${MAKE-make} cpp-works || exit 77], [], [ignore], [ignore])
320 AT_CHECK([${MAKE-make}], [], [ignore], [ignore])
325 ## ---------------- ##
326 ## AC_OPENMP and C. ##
327 ## ---------------- ##
329 AT_SETUP([AC_OPENMP and C])
331 AT_DATA([configure.ac],
335 if test "X$ac_cv_prog_c_openmp" = Xunsupported; then
338 CFLAGS="$CFLAGS $OPENMP_CFLAGS"
339 CPPFLAGS="$CPPFLAGS $OPENMP_CFLAGS"
340 AC_CONFIG_FILES([Makefile])
344 AT_DATA([Makefile.in],
345 [[foo@EXEEXT@: foo.@OBJEXT@
346 @CC@ @CFLAGS@ @LDFLAGS@ -o $@ foo.@OBJEXT@
349 @CC@ @CPPFLAGS@ @CFLAGS@ -c foo.c
363 int id = omp_get_thread_num ();
364 printf ("hello omp world from %d\n", id);
372 AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
373 AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
374 AT_CHECK([$MAKE], [], [ignore], [ignore])
379 ## ------------------ ##
380 ## AC_OPENMP anc C++. ##
381 ## ------------------ ##
383 AT_SETUP([AC_OPENMP and C++])
385 AT_DATA([configure.ac],
390 if test "X$ac_cv_prog_cxx_openmp" = Xunsupported; then
393 CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
394 CPPFLAGS="$CPPFLAGS $OPENMP_CXXFLAGS"
395 AC_CONFIG_FILES([Makefile])
399 AT_DATA([Makefile.in],
400 [[foo@EXEEXT@: foo.@OBJEXT@
401 @CXX@ @CXXFLAGS@ @LDFLAGS@ -o $@ foo.@OBJEXT@
403 foo.@OBJEXT@: foo.cpp
404 @CXX@ @CPPFLAGS@ @CXXFLAGS@ -c foo.cpp
415 AT_CHECK([env ACLOCAL=true autoreconf -vi], [], [ignore], [ignore])
416 AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
417 AT_CHECK([$MAKE], [], [ignore], [ignore])