1# This file is part of Autoconf.                       -*- Autoconf -*-
2# Programming languages support.
3# Copyright (C) 2000-2002, 2004-2012 Free Software Foundation, Inc.
4
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.
10#
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.
15#
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.
19#
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 <http://www.gnu.org/licenses/>.
24
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.
28
29
30# Table of Contents:
31#
32# 1. Language selection
33#    and routines to produce programs in a given language.
34#
35# 2. Producing programs in a given language.
36#
37# 3. Looking for a compiler
38#    And possibly the associated preprocessor.
39#
40#    3a. Computing EXEEXT and OBJEXT.
41#
42# 4. Compilers' characteristics.
43
44
45
46## ----------------------- ##
47## 1. Language selection.  ##
48## ----------------------- ##
49
50
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.
55m4_define([AC_LANG_CASE],
56[m4_case(_AC_LANG, $@)])
57
58
59# _AC_LANG_DISPATCH(MACRO, LANG, ARGS)
60# ------------------------------------
61# Call the specialization of MACRO for LANG with ARGS.  Complain if
62# unavailable.
63m4_define([_AC_LANG_DISPATCH],
64[m4_ifdef([$1($2)],
65       [m4_indir([$1($2)], m4_shift2($@))],
66       [m4_fatal([$1: unknown language: $2])])])
67
68
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:
73#
74# m4_defun([_AC_LANG_SET],
75# [m4_if([$1], [$2], [],
76#        [_AC_LANG_DISPATCH([AC_LANG], [$2])])])
77#
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.
81m4_defun([_AC_LANG_SET],
82[_AC_LANG_DISPATCH([AC_LANG], [$2])])
83
84
85# AC_LANG(LANG)
86# -------------
87# Set the current language to LANG.
88m4_defun([AC_LANG],
89[_AC_LANG_SET(m4_ifdef([_AC_LANG], [m4_defn([_AC_LANG])]),
90	      [$1])dnl
91m4_define([_AC_LANG], [$1])])
92
93
94# AC_LANG_PUSH(LANG)
95# ------------------
96# Save the current language, and use LANG.
97m4_defun([AC_LANG_PUSH],
98[_AC_LANG_SET(m4_ifdef([_AC_LANG], [m4_defn([_AC_LANG])]),
99	      [$1])dnl
100m4_pushdef([_AC_LANG], [$1])])
101
102
103# AC_LANG_POP([LANG])
104# -------------------
105# If given, check that the current language is LANG, and restore the
106# previous language.
107m4_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
111m4_pushdef([$0 OLD], m4_defn([_AC_LANG]))dnl
112m4_popdef([_AC_LANG])dnl
113_AC_LANG_SET(m4_defn([$0 OLD]), m4_defn([_AC_LANG]))dnl
114m4_popdef([$0 OLD])dnl
115])
116
117
118# AC_LANG_SAVE
119# ------------
120# Save the current language, but don't change language.
121AU_DEFUN([AC_LANG_SAVE],
122[[AC_LANG_SAVE]],
123[Instead of using `AC_LANG', `AC_LANG_SAVE', and `AC_LANG_RESTORE',
124you should use `AC_LANG_PUSH' and `AC_LANG_POP'.])
125AC_DEFUN([AC_LANG_SAVE],
126[m4_pushdef([_AC_LANG], _AC_LANG)dnl
127AC_DIAGNOSE([obsolete], [The macro `AC_LANG_SAVE' is obsolete.
128You should run autoupdate.])])
129
130
131# AC_LANG_RESTORE
132# ---------------
133# Restore the current language from the stack.
134AU_DEFUN([AC_LANG_RESTORE], [AC_LANG_POP($@)])
135
136
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.
141m4_defun([_AC_LANG_ABBREV],
142[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
143
144
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.
149m4_defun([_AC_LANG_PREFIX],
150[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
151
152
153# AC_LANG_ASSERT(LANG)
154# --------------------
155# Current language must be LANG.
156m4_defun([AC_LANG_ASSERT],
157[m4_if(_AC_LANG, $1, [],
158       [m4_fatal([$0: current language is not $1: ] _AC_LANG)])])
159
160
161
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).
169m4_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)])])])
184
185## ----------------------- ##
186## 2. Producing programs.  ##
187## ----------------------- ##
188
189
190# AC_LANG_CONFTEST(BODY)
191# ----------------------
192# Save the BODY in `conftest.$ac_ext'.  Add a trailing new line.
193AC_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])])
198
199
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.
207m4_define([AC_LANG_CONFTEST()],
208[cat > conftest.$ac_ext <<_ACEOF
209AC_LANG_DEFINES_PROVIDED[]$1
210_ACEOF])
211
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.
216m4_define([AC_LANG_DEFINES_PROVIDED],
217[m4_define([_$0])])
218
219
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'.
224AC_DEFUN([AC_LANG_SOURCE],
225[AC_LANG_DEFINES_PROVIDED[]_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
226
227
228# AC_LANG_SOURCE()(BODY)
229# ----------------------
230# Default implementation of AC_LANG_SOURCE.
231m4_define([AC_LANG_SOURCE()],
232[$1])
233
234
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).
241AC_DEFUN([AC_LANG_PROGRAM],
242[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
243
244
245# _AC_LANG_NULL_PROGRAM()()
246# -------------------------
247# Default implementation of AC_LANG_NULL_PROGRAM
248m4_define([_AC_LANG_NULL_PROGRAM()],
249[AC_LANG_PROGRAM([], [])])
250
251
252# _AC_LANG_NULL_PROGRAM
253# ---------------------
254# Produce valid source for the current language that does
255# nothing.
256AC_DEFUN([_AC_LANG_NULL_PROGRAM],
257[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
258
259
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.)
265AC_DEFUN([_AC_LANG_IO_PROGRAM],
266[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
267
268
269# AC_LANG_CALL(PROLOGUE, FUNCTION)
270# --------------------------------
271# Call the FUNCTION.
272AC_DEFUN([AC_LANG_CALL],
273[m4_ifval([$2], [], [m4_warn([syntax], [$0: no function given])])dnl
274_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
275
276
277# AC_LANG_FUNC_LINK_TRY(FUNCTION)
278# -------------------------------
279# Produce a source which links correctly iff the FUNCTION exists.
280AC_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, $@)])
283
284
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.
289AC_DEFUN([AC_LANG_BOOL_COMPILE_TRY],
290[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
291
292
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'.
297AC_DEFUN([AC_LANG_INT_SAVE],
298[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
299
300
301# _AC_CC
302# ------
303# The variable name of the compiler.
304m4_define([_AC_CC],
305[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
306
307
308## -------------------------------------------- ##
309## 3. Looking for Compilers and Preprocessors.  ##
310## -------------------------------------------- ##
311
312
313# AC_LANG_COMPILER
314# ----------------
315# Find a compiler for the current LANG.  Be sure to be run before
316# AC_LANG_PREPROC.
317#
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.
320m4_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, $@)])
324
325
326# AC_LANG_COMPILER_REQUIRE
327# ------------------------
328# Ensure we have a compiler for the current LANG.
329AC_DEFUN([AC_LANG_COMPILER_REQUIRE],
330[m4_require([AC_LANG_COMPILER(]_AC_LANG[)],
331	    [AC_LANG_COMPILER])])
332
333
334
335# _AC_LANG_COMPILER_GNU
336# ---------------------
337# Check whether the compiler for the current language is GNU.
338#
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.
345m4_define([_AC_LANG_COMPILER_GNU],
346[AC_CACHE_CHECK([whether we are using the GNU _AC_LANG compiler],
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])
354ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu=$ac_compiler_gnu
355])])# _AC_LANG_COMPILER_GNU
356
357
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.
364m4_define([AC_LANG_PREPROC],
365[AC_LANG_COMPILER_REQUIRE()dnl
366_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
367
368
369# AC_LANG_PREPROC_REQUIRE
370# -----------------------
371# Ensure we have a preprocessor for the current language.
372AC_DEFUN([AC_LANG_PREPROC_REQUIRE],
373[m4_require([AC_LANG_PREPROC(]_AC_LANG[)],
374	    [AC_LANG_PREPROC])])
375
376
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?).
381AC_DEFUN([AC_REQUIRE_CPP],
382[AC_LANG_PREPROC_REQUIRE])
383
384
385
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.
392#
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.
397#
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.
402#
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.
406AC_DEFUN_ONCE([AC_NO_EXECUTABLES],
407[m4_divert_push([KILL])
408m4_divert_text([DEFAULTS], [ac_no_link=no])
409
410AC_BEFORE([$0], [_AC_COMPILER_EXEEXT])
411AC_BEFORE([$0], [AC_LINK_IFELSE])
412
413m4_define([_AC_COMPILER_EXEEXT],
414[AC_LANG_CONFTEST([_AC_LANG_NULL_PROGRAM])
415if _AC_DO_VAR(ac_link); then
416  ac_no_link=no
417  ]m4_defn([_AC_COMPILER_EXEEXT])[
418else
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
427fi
428])
429
430m4_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])
433fi
434]m4_defn([AC_LINK_IFELSE]))
435
436m4_divert_pop()dnl
437])# AC_NO_EXECUTABLES
438
439
440
441# --------------------------------- #
442# 3a. Computing EXEEXT and OBJEXT.  #
443# --------------------------------- #
444
445
446# Files to ignore
447# ---------------
448# Ignore .d files produced by CFLAGS=-MD.
449#
450# On UWIN (which uses a cc wrapper for MSVC), the compiler also generates
451# a .pdb file
452#
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'.
456#
457# - *.bb, *.bbg
458#   Created per object by GCC when given -ftest-coverage.
459#
460# - *.xSYM
461#   Created on BeOS.  Seems to be per executable.
462#
463# - *.map, *.inf
464#   Created by the Green Hills compiler.
465#
466# - *.dSYM
467#   Directory created on Mac OS X Leopard.
468
469
470# _AC_COMPILER_OBJEXT_REJECT
471# --------------------------
472# Case/esac pattern matching the files to be ignored when looking for
473# compiled object files.
474m4_define([_AC_COMPILER_OBJEXT_REJECT],
475[*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM])
476
477
478# _AC_COMPILER_EXEEXT_REJECT
479# --------------------------
480# Case/esac pattern matching the files to be ignored when looking for
481# compiled executables.
482m4_define([_AC_COMPILER_EXEEXT_REJECT],
483[_AC_COMPILER_OBJEXT_REJECT | *.o | *.obj])
484
485
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.
490AC_DEFUN([AC_EXEEXT],   [])
491AC_DEFUN([AC_OBJEXT],   [])
492
493
494# _AC_COMPILER_EXEEXT_DEFAULT
495# ---------------------------
496# Check for the extension used for the default name for executables.
497#
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).
500#
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.
505#
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.
514#
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.
518#
519m4_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.
523AC_MSG_CHECKING([whether the _AC_LANG compiler works])
524ac_link_default=`AS_ECHO(["$ac_link"]) | sed ['s/ -o *conftest[^ ]*//']`
525
526# The possible output files:
527ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
528
529ac_rmfiles=
530for ac_file in $ac_files
531do
532  case $ac_file in
533    _AC_COMPILER_EXEEXT_REJECT ) ;;
534    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
535  esac
536done
537rm -f $ac_rmfiles
538
539AS_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.
545for ac_file in $ac_files ''
546do
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+set}" = set && 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
569done
570test "$ac_cv_exeext" = no && ac_cv_exeext=
571],
572      [ac_file=''])
573AS_IF([test -z "$ac_file"],
574[AC_MSG_RESULT([no])
575_AC_MSG_LOG_CONFTEST
576AC_MSG_FAILURE([_AC_LANG compiler cannot create executables], 77)],
577[AC_MSG_RESULT([yes])])
578AC_MSG_CHECKING([for _AC_LANG compiler default output file name])
579AC_MSG_RESULT([$ac_file])
580ac_exeext=$ac_cv_exeext
581])# _AC_COMPILER_EXEEXT_DEFAULT
582
583
584# _AC_COMPILER_EXEEXT_CROSS
585# -------------------------
586# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
587#
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.
595m4_define([_AC_COMPILER_EXEEXT_CROSS],
596[# Check that the compiler produces executables we can run.  If not, either
597# the compiler is broken, or we cross compile.
598AC_MSG_CHECKING([whether we are cross compiling])
599if test "$cross_compiling" != yes; then
600  _AC_DO_VAR(ac_link)
601  if _AC_DO_TOKENS([./conftest$ac_cv_exeext]); then
602    cross_compiling=no
603  else
604    if test "$cross_compiling" = maybe; then
605	cross_compiling=yes
606    else
607	AC_MSG_FAILURE([cannot run _AC_LANG compiled programs.
608If you meant to cross compile, use `--host'.])
609    fi
610  fi
611fi
612AC_MSG_RESULT([$cross_compiling])
613])# _AC_COMPILER_EXEEXT_CROSS
614
615
616# _AC_COMPILER_EXEEXT_O
617# ---------------------
618# Check for the extension used when `-o foo'.  Try to see if ac_cv_exeext,
619# as computed by _AC_COMPILER_EXEEXT_DEFAULT is OK.
620m4_define([_AC_COMPILER_EXEEXT_O],
621[AC_MSG_CHECKING([for suffix of executables])
622AS_IF([_AC_DO_VAR(ac_link)],
623[# If both `conftest.exe' and `conftest' are `present' (well, observable)
624# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
625# work properly (i.e., refer to `conftest.exe'), while it won't with
626# `rm'.
627for ac_file in conftest.exe conftest conftest.*; do
628  test -f "$ac_file" || continue
629  case $ac_file in
630    _AC_COMPILER_EXEEXT_REJECT ) ;;
631    *.* ) ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
632	  break;;
633    * ) break;;
634  esac
635done],
636	      [AC_MSG_FAILURE([cannot compute suffix of executables: cannot compile and link])])
637rm -f conftest conftest$ac_cv_exeext
638AC_MSG_RESULT([$ac_cv_exeext])
639])# _AC_COMPILER_EXEEXT_O
640
641
642# _AC_COMPILER_EXEEXT
643# -------------------
644# Check for the extension used for executables.  It compiles a test
645# executable.  If this is called, the executable extensions will be
646# automatically used by link commands run by the configure script.
647#
648# Note that some compilers (cross or not), strictly obey to `-o foo' while
649# the host requires `foo.exe', so we should not depend upon `-o' to
650# test EXEEXT.  But then, be sure not to destroy user files.
651#
652# Must be run before _AC_COMPILER_OBJEXT because _AC_COMPILER_EXEEXT_DEFAULT
653# checks whether the compiler works.
654#
655# Do not rename this macro; Automake decides whether EXEEXT is used
656# by checking whether `_AC_COMPILER_EXEEXT' has been expanded.
657#
658# See _AC_COMPILER_EXEEXT_CROSS for why we need _AC_LANG_IO_PROGRAM.
659m4_define([_AC_COMPILER_EXEEXT],
660[AC_LANG_CONFTEST([_AC_LANG_NULL_PROGRAM])
661ac_clean_files_save=$ac_clean_files
662ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
663_AC_COMPILER_EXEEXT_DEFAULT
664rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
665ac_clean_files=$ac_clean_files_save
666_AC_COMPILER_EXEEXT_O
667rm -f conftest.$ac_ext
668AC_SUBST([EXEEXT], [$ac_cv_exeext])dnl
669ac_exeext=$EXEEXT
670AC_LANG_CONFTEST([_AC_LANG_IO_PROGRAM])
671ac_clean_files="$ac_clean_files conftest.out"
672_AC_COMPILER_EXEEXT_CROSS
673rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
674ac_clean_files=$ac_clean_files_save
675])# _AC_COMPILER_EXEEXT
676
677
678# _AC_COMPILER_OBJEXT
679# -------------------
680# Check the object extension used by the compiler: typically `.o' or
681# `.obj'.  If this is called, some other behavior will change,
682# determined by ac_objext.
683#
684# This macro is called by AC_LANG_COMPILER, the latter being required
685# by the AC_COMPILE_IFELSE macros, so use _AC_COMPILE_IFELSE.  And in fact,
686# don't, since _AC_COMPILE_IFELSE needs to know ac_objext for the `test -s'
687# it includes.  So do it by hand.
688m4_define([_AC_COMPILER_OBJEXT],
689[AC_CACHE_CHECK([for suffix of object files], ac_cv_objext,
690[AC_LANG_CONFTEST([_AC_LANG_NULL_PROGRAM])
691rm -f conftest.o conftest.obj
692AS_IF([_AC_DO_VAR(ac_compile)],
693[for ac_file in conftest.o conftest.obj conftest.*; do
694  test -f "$ac_file" || continue;
695  case $ac_file in
696    _AC_COMPILER_OBJEXT_REJECT ) ;;
697    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
698       break;;
699  esac
700done],
701      [_AC_MSG_LOG_CONFTEST
702AC_MSG_FAILURE([cannot compute suffix of object files: cannot compile])])
703rm -f conftest.$ac_cv_objext conftest.$ac_ext])
704AC_SUBST([OBJEXT], [$ac_cv_objext])dnl
705ac_objext=$OBJEXT
706])# _AC_COMPILER_OBJEXT
707
708
709
710
711## ------------------------------- ##
712## 4. Compilers' characteristics.  ##
713## ------------------------------- ##
714
715# AC_LANG_WERROR
716# --------------
717# Treat warnings from the current language's preprocessor, compiler, and
718# linker as fatal errors.
719AC_DEFUN([AC_LANG_WERROR],
720[m4_divert_text([DEFAULTS], [ac_[]_AC_LANG_ABBREV[]_werror_flag=])
721ac_[]_AC_LANG_ABBREV[]_werror_flag=yes])# AC_LANG_WERROR
722