Prefer HTTPS to FTP and HTTP
[autoconf.git] / lib / autoconf / lang.m4
blob4ce403ba0f261c3923eba0bf0cc0648ac4753fd3
1 # This file is part of Autoconf.                       -*- Autoconf -*-
2 # Programming languages support.
3 # Copyright (C) 2000-2002, 2004-2017 Free Software Foundation, Inc.
5 # This file is part of Autoconf.  This program is free
6 # software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the
8 # Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # Under Section 7 of GPL version 3, you are granted additional
17 # permissions described in the Autoconf Configure Script Exception,
18 # version 3.0, as published by the Free Software Foundation.
20 # You should have received a copy of the GNU General Public License
21 # and a copy of the Autoconf Configure Script Exception along with
22 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
23 # respectively.  If not, see <https://www.gnu.org/licenses/>.
25 # Written by David MacKenzie, with help from
26 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
27 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
30 # Table of Contents:
32 # 1. Language selection
33 #    and routines to produce programs in a given language.
35 # 2. Producing programs in a given language.
37 # 3. Looking for a compiler
38 #    And possibly the associated preprocessor.
40 #    3a. Computing EXEEXT and OBJEXT.
42 # 4. Compilers' characteristics.
46 ## ----------------------- ##
47 ## 1. Language selection.  ##
48 ## ----------------------- ##
51 # AC_LANG_CASE(LANG1, IF-LANG1, LANG2, IF-LANG2, ..., DEFAULT)
52 # ------------------------------------------------------------
53 # Expand into IF-LANG1 if the current language is LANG1 etc. else
54 # into default.
55 m4_define([AC_LANG_CASE],
56 [m4_case(_AC_LANG, $@)])
59 # _AC_LANG_DISPATCH(MACRO, LANG, ARGS)
60 # ------------------------------------
61 # Call the specialization of MACRO for LANG with ARGS.  Complain if
62 # unavailable.
63 m4_define([_AC_LANG_DISPATCH],
64 [m4_ifdef([$1($2)],
65        [m4_indir([$1($2)], m4_shift2($@))],
66        [m4_fatal([$1: unknown language: $2])])])
69 # _AC_LANG_SET(OLD, NEW)
70 # ----------------------
71 # Output the shell code needed to switch from OLD language to NEW language.
72 # Do not try to optimize like this:
74 # m4_defun([_AC_LANG_SET],
75 # [m4_if([$1], [$2], [],
76 #        [_AC_LANG_DISPATCH([AC_LANG], [$2])])])
78 # as it can introduce differences between the sh-current language and the
79 # m4-current-language when m4_require is used.  Something more subtle
80 # might be possible, but at least for the time being, play it safe.
81 m4_defun([_AC_LANG_SET],
82 [_AC_LANG_DISPATCH([AC_LANG], [$2])])
85 # AC_LANG(LANG)
86 # -------------
87 # Set the current language to LANG.
88 m4_defun([AC_LANG],
89 [_AC_LANG_SET(m4_ifdef([_AC_LANG], [m4_defn([_AC_LANG])]),
90               [$1])dnl
91 m4_define([_AC_LANG], [$1])])
94 # AC_LANG_PUSH(LANG)
95 # ------------------
96 # Save the current language, and use LANG.
97 m4_defun([AC_LANG_PUSH],
98 [_AC_LANG_SET(m4_ifdef([_AC_LANG], [m4_defn([_AC_LANG])]),
99               [$1])dnl
100 m4_pushdef([_AC_LANG], [$1])])
103 # AC_LANG_POP([LANG])
104 # -------------------
105 # If given, check that the current language is LANG, and restore the
106 # previous language.
107 m4_defun([AC_LANG_POP],
108 [m4_ifval([$1],
109  [m4_if([$1], m4_defn([_AC_LANG]), [],
110   [m4_fatal([$0($1): unexpected current language: ]m4_defn([_AC_LANG]))])])dnl
111 m4_pushdef([$0 OLD], m4_defn([_AC_LANG]))dnl
112 m4_popdef([_AC_LANG])dnl
113 _AC_LANG_SET(m4_defn([$0 OLD]), m4_defn([_AC_LANG]))dnl
114 m4_popdef([$0 OLD])dnl
118 # AC_LANG_SAVE
119 # ------------
120 # Save the current language, but don't change language.
121 AU_DEFUN([AC_LANG_SAVE],
122 [[AC_LANG_SAVE]],
123 [Instead of using `AC_LANG', `AC_LANG_SAVE', and `AC_LANG_RESTORE',
124 you should use `AC_LANG_PUSH' and `AC_LANG_POP'.])
125 AC_DEFUN([AC_LANG_SAVE],
126 [m4_pushdef([_AC_LANG], _AC_LANG)dnl
127 AC_DIAGNOSE([obsolete], [The macro `AC_LANG_SAVE' is obsolete.
128 You should run autoupdate.])])
131 # AC_LANG_RESTORE
132 # ---------------
133 # Restore the current language from the stack.
134 AU_DEFUN([AC_LANG_RESTORE], [AC_LANG_POP($@)])
137 # _AC_LANG_ABBREV
138 # ---------------
139 # Return a short signature of _AC_LANG which can be used in shell
140 # variable names, or in M4 macro names.
141 m4_defun([_AC_LANG_ABBREV],
142 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
145 # _AC_LANG_PREFIX
146 # ---------------
147 # Return a short (upper case) signature of _AC_LANG that is used to
148 # prefix environment variables like FLAGS.
149 m4_defun([_AC_LANG_PREFIX],
150 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
153 # AC_LANG_ASSERT(LANG)
154 # --------------------
155 # Current language must be LANG.
156 m4_defun([AC_LANG_ASSERT],
157 [m4_if(_AC_LANG, $1, [],
158        [m4_fatal([$0: current language is not $1: ] _AC_LANG)])])
162 # AC_LANG_DEFINE(NAME, ABBREV, PREFIX, COMPILER-VAR, COPY-FROM, SHELL-VARS)
163 # -------------------------------------------------------------------------
164 # Define a language referenced by AC_LANG(NAME), with cache variable prefix
165 # ABBREV, Makefile variable prefix PREFIX and compiler variable COMPILER-VAR.
166 # AC_LANG(NAME) is defined to SHELL-VARS, other macros are copied from language
167 # COPY-FROM.  Even if COPY-FROM is empty, a default definition is provided for
168 # language-specific macros AC_LANG_SOURCE(NAME) and AC_LANG_CONFTEST(NAME).
169 m4_define([AC_LANG_DEFINE],
170 [m4_define([AC_LANG($1)], [$6])]
171 [m4_define([_AC_LANG_ABBREV($1)], [$2])]
172 [m4_define([_AC_LANG_PREFIX($1)], [$3])]
173 [m4_define([_AC_CC($1)], [$4])]
174 [m4_copy([AC_LANG_CONFTEST($5)], [AC_LANG_CONFTEST($1)])]
175 [m4_copy([AC_LANG_SOURCE($5)], [AC_LANG_SOURCE($1)])]
176 [m4_copy([_AC_LANG_NULL_PROGRAM($5)], [_AC_LANG_NULL_PROGRAM($1)])]
177 [m4_ifval([$5],
178 [m4_copy([AC_LANG_PROGRAM($5)], [AC_LANG_PROGRAM($1)])]
179 [m4_copy([AC_LANG_CALL($5)], [AC_LANG_CALL($1)])]
180 [m4_copy([AC_LANG_FUNC_LINK_TRY($5)], [AC_LANG_FUNC_LINK_TRY($1)])]
181 [m4_copy([AC_LANG_BOOL_COMPILE_TRY($5)], [AC_LANG_BOOL_COMPILE_TRY($1)])]
182 [m4_copy([AC_LANG_INT_SAVE($5)], [AC_LANG_INT_SAVE($1)])]
183 [m4_copy([_AC_LANG_IO_PROGRAM($5)], [_AC_LANG_IO_PROGRAM($1)])])])
185 ## ----------------------- ##
186 ## 2. Producing programs.  ##
187 ## ----------------------- ##
190 # AC_LANG_CONFTEST(BODY)
191 # ----------------------
192 # Save the BODY in `conftest.$ac_ext'.  Add a trailing new line.
193 AC_DEFUN([AC_LANG_CONFTEST],
194 [m4_pushdef([_AC_LANG_DEFINES_PROVIDED],
195   [m4_warn([syntax], [$0: no AC_LANG_SOURCE call detected in body])])]dnl
196 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]dnl
197 [[]_AC_LANG_DEFINES_PROVIDED[]m4_popdef([_AC_LANG_DEFINES_PROVIDED])])
200 # AC_LANG_CONFTEST()(BODY)
201 # ------------------------
202 # Default implementation of AC_LANG_CONFTEST.
203 # This version assumes that you can't inline confdefs.h into your
204 # language, and as such, it is safe to blindly call
205 # AC_LANG_DEFINES_PROVIDED.  Language-specific overrides should
206 # remove this call if AC_LANG_SOURCE does inline confdefs.h.
207 m4_define([AC_LANG_CONFTEST()],
208 [cat > conftest.$ac_ext <<_ACEOF
209 AC_LANG_DEFINES_PROVIDED[]$1
210 _ACEOF])
212 # AC_LANG_DEFINES_PROVIDED
213 # ------------------------
214 # Witness macro that all prior AC_DEFINE results have been output
215 # into the current expansion, to silence warning from AC_LANG_CONFTEST.
216 m4_define([AC_LANG_DEFINES_PROVIDED],
217 [m4_define([_$0])])
220 # AC_LANG_SOURCE(BODY)
221 # --------------------
222 # Produce a valid source for the current language, which includes the
223 # BODY, and as much as possible `confdefs.h'.
224 AC_DEFUN([AC_LANG_SOURCE],
225 [AC_LANG_DEFINES_PROVIDED[]_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
228 # AC_LANG_SOURCE()(BODY)
229 # ----------------------
230 # Default implementation of AC_LANG_SOURCE.
231 m4_define([AC_LANG_SOURCE()],
232 [$1])
235 # AC_LANG_PROGRAM([PROLOGUE], [BODY])
236 # -----------------------------------
237 # Produce a valid source for the current language.  Prepend the
238 # PROLOGUE (typically CPP directives and/or declarations) to an
239 # execution the BODY (typically glued inside the `main' function, or
240 # equivalent).
241 AC_DEFUN([AC_LANG_PROGRAM],
242 [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
245 # _AC_LANG_NULL_PROGRAM()()
246 # -------------------------
247 # Default implementation of AC_LANG_NULL_PROGRAM
248 m4_define([_AC_LANG_NULL_PROGRAM()],
249 [AC_LANG_PROGRAM([], [])])
252 # _AC_LANG_NULL_PROGRAM
253 # ---------------------
254 # Produce valid source for the current language that does
255 # nothing.
256 AC_DEFUN([_AC_LANG_NULL_PROGRAM],
257 [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
260 # _AC_LANG_IO_PROGRAM
261 # -------------------
262 # Produce valid source for the current language that creates
263 # a file.  (This is used when detecting whether executables
264 # work, e.g. to detect cross-compiling.)
265 AC_DEFUN([_AC_LANG_IO_PROGRAM],
266 [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
269 # AC_LANG_CALL(PROLOGUE, FUNCTION)
270 # --------------------------------
271 # Call the FUNCTION.
272 AC_DEFUN([AC_LANG_CALL],
273 [m4_ifval([$2], [], [m4_warn([syntax], [$0: no function given])])dnl
274 _AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
277 # AC_LANG_FUNC_LINK_TRY(FUNCTION)
278 # -------------------------------
279 # Produce a source which links correctly iff the FUNCTION exists.
280 AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
281 [m4_ifval([$1], [], [m4_warn([syntax], [$0: no function given])])dnl
282 _AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
285 # AC_LANG_BOOL_COMPILE_TRY(PROLOGUE, EXPRESSION)
286 # ----------------------------------------------
287 # Produce a program that compiles with success iff the boolean EXPRESSION
288 # evaluates to true at compile time.
289 AC_DEFUN([AC_LANG_BOOL_COMPILE_TRY],
290 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
293 # AC_LANG_INT_SAVE(PROLOGUE, EXPRESSION)
294 # --------------------------------------
295 # Produce a program that saves the runtime evaluation of the integer
296 # EXPRESSION into `conftest.val'.
297 AC_DEFUN([AC_LANG_INT_SAVE],
298 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
301 # _AC_CC
302 # ------
303 # The variable name of the compiler.
304 m4_define([_AC_CC],
305 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
308 ## -------------------------------------------- ##
309 ## 3. Looking for Compilers and Preprocessors.  ##
310 ## -------------------------------------------- ##
313 # AC_LANG_COMPILER
314 # ----------------
315 # Find a compiler for the current LANG.  Be sure to be run before
316 # AC_LANG_PREPROC.
318 # Note that because we might AC_REQUIRE `AC_LANG_COMPILER(C)' for
319 # instance, the latter must be AC_DEFUN'd, not just define'd.
320 m4_define([AC_LANG_COMPILER],
321 [AC_BEFORE([AC_LANG_COMPILER(]_AC_LANG[)],
322            [AC_LANG_PREPROC(]_AC_LANG[)])dnl
323 _AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
326 # AC_LANG_COMPILER_REQUIRE
327 # ------------------------
328 # Ensure we have a compiler for the current LANG.
329 AC_DEFUN([AC_LANG_COMPILER_REQUIRE],
330 [m4_require([AC_LANG_COMPILER(]_AC_LANG[)],
331             [AC_LANG_COMPILER])])
335 # _AC_LANG_COMPILER_GNU
336 # ---------------------
337 # Check whether the compiler for the current language is GNU.
339 # It doesn't seem necessary right now to have a different source
340 # according to the current language, since this works fine.  Some day
341 # it might be needed.  Nevertheless, pay attention to the fact that
342 # the position of `choke me' on the seventh column is meant: otherwise
343 # some Fortran compilers (e.g., SGI) might consider it's a
344 # continuation line, and warn instead of reporting an error.
345 m4_define([_AC_LANG_COMPILER_GNU],
346 [AC_CACHE_CHECK([whether the compiler supports GNU _AC_LANG],
347                 [ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu],
348 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __GNUC__
349        choke me
350 #endif
351 ]])],
352                    [ac_compiler_gnu=yes],
353                    [ac_compiler_gnu=no])
354 ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu=$ac_compiler_gnu
355 ])])# _AC_LANG_COMPILER_GNU
358 # AC_LANG_PREPROC
359 # ---------------
360 # Find a preprocessor for the current language.  Note that because we
361 # might AC_REQUIRE `AC_LANG_PREPROC(C)' for instance, the latter must
362 # be AC_DEFUN'd, not just define'd.  Since the preprocessor depends
363 # upon the compiler, look for the compiler.
364 m4_define([AC_LANG_PREPROC],
365 [AC_LANG_COMPILER_REQUIRE()dnl
366 _AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
369 # AC_LANG_PREPROC_REQUIRE
370 # -----------------------
371 # Ensure we have a preprocessor for the current language.
372 AC_DEFUN([AC_LANG_PREPROC_REQUIRE],
373 [m4_require([AC_LANG_PREPROC(]_AC_LANG[)],
374             [AC_LANG_PREPROC])])
377 # AC_REQUIRE_CPP
378 # --------------
379 # Require the preprocessor for the current language.
380 # FIXME: AU_ALIAS once AC_LANG is officially documented (2.51?).
381 AC_DEFUN([AC_REQUIRE_CPP],
382 [AC_LANG_PREPROC_REQUIRE])
386 # AC_NO_EXECUTABLES
387 # -----------------
388 # FIXME: The GCC team has specific needs which the current Autoconf
389 # framework cannot solve elegantly.  This macro implements a dirty
390 # hack until Autoconf is able to provide the services its users
391 # need.
393 # Several of the support libraries that are often built with GCC can't
394 # assume the tool-chain is already capable of linking a program: the
395 # compiler often expects to be able to link with some of such
396 # libraries.
398 # In several of these libraries, workarounds have been introduced to
399 # avoid the AC_PROG_CC_WORKS test, that would just abort their
400 # configuration.  The introduction of AC_EXEEXT, enabled either by
401 # libtool or by CVS autoconf, have just made matters worse.
403 # Unlike an earlier version of this macro, using AC_NO_EXECUTABLES does
404 # not disable link tests at autoconf time, but at configure time.
405 # This allows AC_NO_EXECUTABLES to be invoked conditionally.
406 AC_DEFUN_ONCE([AC_NO_EXECUTABLES],
407 [m4_divert_push([KILL])
408 m4_divert_text([DEFAULTS], [ac_no_link=no])
410 AC_BEFORE([$0], [_AC_COMPILER_EXEEXT])
411 AC_BEFORE([$0], [AC_LINK_IFELSE])
413 m4_define([_AC_COMPILER_EXEEXT],
414 [AC_LANG_CONFTEST([_AC_LANG_NULL_PROGRAM])
415 if _AC_DO_VAR(ac_link); then
416   ac_no_link=no
417   ]m4_defn([_AC_COMPILER_EXEEXT])[
418 else
419   rm -f -r a.out a.exe b.out conftest.$ac_ext conftest.o conftest.obj conftest.dSYM
420   ac_no_link=yes
421   # Setting cross_compile will disable run tests; it will
422   # also disable AC_CHECK_FILE but that's generally
423   # correct if we can't link.
424   cross_compiling=yes
425   EXEEXT=
426   _AC_COMPILER_EXEEXT_CROSS
430 m4_define([AC_LINK_IFELSE],
431 [if test x$ac_no_link = xyes; then
432   AC_MSG_ERROR([link tests are not allowed after AC@&t@_NO_EXECUTABLES])
434 ]m4_defn([AC_LINK_IFELSE]))
436 m4_divert_pop()dnl
437 ])# AC_NO_EXECUTABLES
441 # --------------------------------- #
442 # 3a. Computing EXEEXT and OBJEXT.  #
443 # --------------------------------- #
446 # Files to ignore
447 # ---------------
448 # Ignore .d files produced by CFLAGS=-MD.
450 # On UWIN (which uses a cc wrapper for MSVC), the compiler also generates
451 # a .pdb file
453 # When the w32 free Borland C++ command line compiler links a program
454 # (conftest.exe), it also produces a file named `conftest.tds' in
455 # addition to `conftest.obj'.
457 # - *.bb, *.bbg
458 #   Created per object by GCC when given -ftest-coverage.
460 # - *.xSYM
461 #   Created on BeOS.  Seems to be per executable.
463 # - *.map, *.inf
464 #   Created by the Green Hills compiler.
466 # - *.dSYM
467 #   Directory created on Mac OS X Leopard.
470 # _AC_COMPILER_OBJEXT_REJECT
471 # --------------------------
472 # Case/esac pattern matching the files to be ignored when looking for
473 # compiled object files.
474 m4_define([_AC_COMPILER_OBJEXT_REJECT],
475 [*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM])
478 # _AC_COMPILER_EXEEXT_REJECT
479 # --------------------------
480 # Case/esac pattern matching the files to be ignored when looking for
481 # compiled executables.
482 m4_define([_AC_COMPILER_EXEEXT_REJECT],
483 [_AC_COMPILER_OBJEXT_REJECT | *.o | *.obj])
486 # We must not AU define them, because autoupdate would then remove
487 # them, which is right, but Automake 1.4 would remove the support for
488 # $(EXEEXT) etc.
489 # FIXME: Remove this once Automake fixed.
490 AC_DEFUN([AC_EXEEXT],   [])
491 AC_DEFUN([AC_OBJEXT],   [])
494 # _AC_COMPILER_EXEEXT_DEFAULT
495 # ---------------------------
496 # Check for the extension used for the default name for executables.
498 # We do this in order to find out what is the extension we must add for
499 # creating executables (see _AC_COMPILER_EXEEXT's comments).
501 # On OpenVMS 7.1 system, the DEC C 5.5 compiler when called through a
502 # GNV (gnv.sourceforge.net) cc wrapper, produces the output file named
503 # `a_out.exe'.
504 # b.out is created by i960 compilers.
506 # Start with the most likely output file names, but:
507 # 1) Beware the clever `test -f' on Cygwin, try the DOS-like .exe names
508 # before the counterparts without the extension.
509 # 2) The algorithm is not robust to junk in `.', hence go to wildcards
510 # (conftest.*) only as a last resort.
511 # Beware of `expr' that may return `0' or `'.  Since this macro is
512 # the first one in touch with the compiler, it should also check that
513 # it compiles properly.
515 # The IRIX 6 linker writes into existing files which may not be
516 # executable, retaining their permissions.  Remove them first so a
517 # subsequent execution test works.
519 m4_define([_AC_COMPILER_EXEEXT_DEFAULT],
520 [# Try to create an executable without -o first, disregard a.out.
521 # It will help us diagnose broken compilers, and finding out an intuition
522 # of exeext.
523 AC_MSG_CHECKING([whether the _AC_LANG compiler works])
524 ac_link_default=`AS_ECHO(["$ac_link"]) | sed ['s/ -o *conftest[^ ]*//']`
526 # The possible output files:
527 ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
529 ac_rmfiles=
530 for ac_file in $ac_files
532   case $ac_file in
533     _AC_COMPILER_EXEEXT_REJECT ) ;;
534     * ) ac_rmfiles="$ac_rmfiles $ac_file";;
535   esac
536 done
537 rm -f $ac_rmfiles
539 AS_IF([_AC_DO_VAR(ac_link_default)],
540 [# Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
541 # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
542 # in a Makefile.  We should not override ac_cv_exeext if it was cached,
543 # so that the user can short-circuit this test for compilers unknown to
544 # Autoconf.
545 for ac_file in $ac_files ''
547   test -f "$ac_file" || continue
548   case $ac_file in
549     _AC_COMPILER_EXEEXT_REJECT )
550         ;;
551     [[ab]].out )
552         # We found the default executable, but exeext='' is most
553         # certainly right.
554         break;;
555     *.* )
556         if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no;
557         then :; else
558            ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
559         fi
560         # We set ac_cv_exeext here because the later test for it is not
561         # safe: cross compilers may not add the suffix if given an `-o'
562         # argument, so we may need to know it at that point already.
563         # Even if this section looks crufty: it has the advantage of
564         # actually working.
565         break;;
566     * )
567         break;;
568   esac
569 done
570 test "$ac_cv_exeext" = no && ac_cv_exeext=
572       [ac_file=''])
573 AS_IF([test -z "$ac_file"],
574 [AC_MSG_RESULT([no])
575 _AC_MSG_LOG_CONFTEST
576 AC_MSG_FAILURE([_AC_LANG compiler cannot create executables], 77)],
577 [AC_MSG_RESULT([yes])])
578 AC_MSG_CHECKING([for _AC_LANG compiler default output file name])
579 AC_MSG_RESULT([$ac_file])
580 ac_exeext=$ac_cv_exeext
581 ])# _AC_COMPILER_EXEEXT_DEFAULT
584 # _AC_COMPILER_EXEEXT_CROSS
585 # -------------------------
586 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
588 # It is not sufficient to run a no-op program -- this succeeds and gives
589 # a false negative when cross-compiling for the compute nodes on the
590 # IBM Blue Gene/L.  Instead, _AC_COMPILER_EXEEXT calls _AC_LANG_IO_PROGRAM
591 # to create a program that writes to a file, which is sufficient to
592 # detect cross-compiling on Blue Gene.  Note also that AC_COMPUTE_INT
593 # requires programs that create files when not cross-compiling, so it
594 # is safe and not a bad idea to check for this capability in general.
596 # Another false negative would occur on many modern linux distributions,
597 # which would have Wine run automatically for Windows binaries. This is
598 # a default configuration on several Debian-derivated distributions for
599 # instance (see `update-binfmts`).
600 # As a consequence the simple test program would run without errors,
601 # even though we are on an obvious cross-compilation case and further
602 # more complicated tests would fail.
603 m4_define([_AC_COMPILER_EXEEXT_CROSS],
604 [# Check that the compiler produces executables we can run.  If not, either
605 # the compiler is broken, or we cross compile.
606 AC_MSG_CHECKING([whether we are cross compiling])
607 if test "$cross_compiling" = maybe && test "x$build" != "x$host"; then
608   cross_compiling=yes
609 elif test "$cross_compiling" != yes; then
610   _AC_DO_VAR(ac_link)
611   if _AC_DO_TOKENS([./conftest$ac_cv_exeext]); then
612     cross_compiling=no
613   else
614     if test "$cross_compiling" = maybe; then
615         cross_compiling=yes
616     else
617         AC_MSG_FAILURE([cannot run _AC_LANG compiled programs.
618 If you meant to cross compile, use `--host'.])
619     fi
620   fi
622 AC_MSG_RESULT([$cross_compiling])
623 ])# _AC_COMPILER_EXEEXT_CROSS
626 # _AC_COMPILER_EXEEXT_O
627 # ---------------------
628 # Check for the extension used when `-o foo'.  Try to see if ac_cv_exeext,
629 # as computed by _AC_COMPILER_EXEEXT_DEFAULT is OK.
630 m4_define([_AC_COMPILER_EXEEXT_O],
631 [AC_MSG_CHECKING([for suffix of executables])
632 AS_IF([_AC_DO_VAR(ac_link)],
633 [# If both `conftest.exe' and `conftest' are `present' (well, observable)
634 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
635 # work properly (i.e., refer to `conftest.exe'), while it won't with
636 # `rm'.
637 for ac_file in conftest.exe conftest conftest.*; do
638   test -f "$ac_file" || continue
639   case $ac_file in
640     _AC_COMPILER_EXEEXT_REJECT ) ;;
641     *.* ) ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
642           break;;
643     * ) break;;
644   esac
645 done],
646               [AC_MSG_FAILURE([cannot compute suffix of executables: cannot compile and link])])
647 rm -f conftest conftest$ac_cv_exeext
648 AC_MSG_RESULT([$ac_cv_exeext])
649 ])# _AC_COMPILER_EXEEXT_O
652 # _AC_COMPILER_EXEEXT
653 # -------------------
654 # Check for the extension used for executables.  It compiles a test
655 # executable.  If this is called, the executable extensions will be
656 # automatically used by link commands run by the configure script.
658 # Note that some compilers (cross or not), strictly obey to `-o foo' while
659 # the host requires `foo.exe', so we should not depend upon `-o' to
660 # test EXEEXT.  But then, be sure not to destroy user files.
662 # Must be run before _AC_COMPILER_OBJEXT because _AC_COMPILER_EXEEXT_DEFAULT
663 # checks whether the compiler works.
665 # Do not rename this macro; Automake decides whether EXEEXT is used
666 # by checking whether `_AC_COMPILER_EXEEXT' has been expanded.
668 # See _AC_COMPILER_EXEEXT_CROSS for why we need _AC_LANG_IO_PROGRAM.
669 AC_DEFUN([_AC_COMPILER_EXEEXT],
670 [AC_LANG_CONFTEST([_AC_LANG_NULL_PROGRAM])
671 ac_clean_files_save=$ac_clean_files
672 ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
673 _AC_COMPILER_EXEEXT_DEFAULT
674 rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
675 ac_clean_files=$ac_clean_files_save
676 _AC_COMPILER_EXEEXT_O
677 rm -f conftest.$ac_ext
678 AC_SUBST([EXEEXT], [$ac_cv_exeext])dnl
679 ac_exeext=$EXEEXT
680 AC_LANG_CONFTEST([_AC_LANG_IO_PROGRAM])
681 ac_clean_files="$ac_clean_files conftest.out"
682 _AC_COMPILER_EXEEXT_CROSS
683 rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
684 ac_clean_files=$ac_clean_files_save
685 ])# _AC_COMPILER_EXEEXT
688 # _AC_COMPILER_OBJEXT
689 # -------------------
690 # Check the object extension used by the compiler: typically `.o' or
691 # `.obj'.  If this is called, some other behavior will change,
692 # determined by ac_objext.
694 # This macro is called by AC_LANG_COMPILER, the latter being required
695 # by the AC_COMPILE_IFELSE macros, so use _AC_COMPILE_IFELSE.  And in fact,
696 # don't, since _AC_COMPILE_IFELSE needs to know ac_objext for the `test -s'
697 # it includes.  So do it by hand.
698 m4_define([_AC_COMPILER_OBJEXT],
699 [AC_CACHE_CHECK([for suffix of object files], ac_cv_objext,
700 [AC_LANG_CONFTEST([_AC_LANG_NULL_PROGRAM])
701 rm -f conftest.o conftest.obj
702 AS_IF([_AC_DO_VAR(ac_compile)],
703 [for ac_file in conftest.o conftest.obj conftest.*; do
704   test -f "$ac_file" || continue;
705   case $ac_file in
706     _AC_COMPILER_OBJEXT_REJECT ) ;;
707     *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
708        break;;
709   esac
710 done],
711       [_AC_MSG_LOG_CONFTEST
712 AC_MSG_FAILURE([cannot compute suffix of object files: cannot compile])])
713 rm -f conftest.$ac_cv_objext conftest.$ac_ext])
714 AC_SUBST([OBJEXT], [$ac_cv_objext])dnl
715 ac_objext=$OBJEXT
716 ])# _AC_COMPILER_OBJEXT
721 ## ------------------------------- ##
722 ## 4. Compilers' characteristics.  ##
723 ## ------------------------------- ##
725 # AC_LANG_WERROR
726 # --------------
727 # Treat warnings from the current language's preprocessor, compiler, and
728 # linker as fatal errors.
729 AC_DEFUN([AC_LANG_WERROR],
730 [m4_divert_text([DEFAULTS], [ac_[]_AC_LANG_ABBREV[]_werror_flag=])
731 ac_[]_AC_LANG_ABBREV[]_werror_flag=yes])# AC_LANG_WERROR