📄 lang.m4
字号:
# This file is part of Autoconf. -*- Autoconf -*-# Programming languages support.# Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006 Free Software# Foundation, Inc.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA# 02110-1301, USA.## As a special exception, the Free Software Foundation gives unlimited# permission to copy, distribute and modify the configure scripts that# are the output of Autoconf. You need not follow the terms of the GNU# General Public License when using or distributing such scripts, even# though portions of the text of Autoconf appear in them. The GNU# General Public License (GPL) does govern all other use of the material# that constitutes the Autoconf program.## Certain portions of the Autoconf source text are designed to be copied# (in certain cases, depending on the input) into the output of# Autoconf. We call these the "data" portions. The rest of the Autoconf# source text consists of comments plus executable code that decides which# of the data portions to output in any given case. We call these# comments and executable code the "non-data" portions. Autoconf never# copies any of the non-data portions into its output.## This special exception to the GPL applies to versions of Autoconf# released by the Free Software Foundation. When you make and# distribute a modified version of Autoconf, you may extend this special# exception to the GPL to apply to your modified version as well, *unless*# your modified version has the potential to copy into its output some# of the text that was the non-data portion of the version that you started# with. (In other words, unless your change moves or copies text from# the non-data portions to the data portions.) If your modification has# such potential, you must delete any notice of this special exception# to the GPL from your modified version.## Written by David MacKenzie, with help from# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,# Roland McGrath, Noah Friedman, david d zuhn, and many others.# Table of Contents:## 1. Language selection# and routines to produce programs in a given language.# a. generic routines# b. C# c. C++# d. Fortran 77## 2. Producing programs in a given language.# a. generic routines# b. C# c. C++# d. Fortran 77## 3. Looking for a compiler# And possibly the associated preprocessor.# a. Generic routines.# b. C# c. C++# d. Fortran 77## 4. Compilers' characteristics.# a. Generic routines.# b. C# c. C++# d. Fortran 77## ----------------------- #### 1. Language selection. #### ----------------------- ### -------------------------------- ## 1a. Generic language selection. ## -------------------------------- ## AC_LANG_CASE(LANG1, IF-LANG1, LANG2, IF-LANG2, ..., DEFAULT)# ------------------------------------------------------------# Expand into IF-LANG1 if the current language is LANG1 etc. else# into default.m4_define([AC_LANG_CASE],[m4_case(_AC_LANG, $@)])# _AC_LANG_DISPATCH(MACRO, LANG, ARGS)# ------------------------------------# Call the specialization of MACRO for LANG with ARGS. Complain if# unavailable.m4_define([_AC_LANG_DISPATCH],[m4_ifdef([$1($2)], [m4_indir([$1($2)], m4_shiftn(2, $@))], [AC_FATAL([$1: unknown language: $2])])])# _AC_LANG_SET(OLD, NEW)# ----------------------# Output the shell code needed to switch from OLD language to NEW language.# Do not try to optimize like this:## m4_defun([_AC_LANG_SET],# [m4_if([$1], [$2], [],# [_AC_LANG_DISPATCH([AC_LANG], [$2])])])## as it can introduce differences between the sh-current language and the# m4-current-language when m4_require is used. Something more subtle# might be possible, but at least for the time being, play it safe.m4_defun([_AC_LANG_SET],[_AC_LANG_DISPATCH([AC_LANG], [$2])])# AC_LANG(LANG)# -------------# Set the current language to LANG.m4_defun([AC_LANG],[_AC_LANG_SET(m4_ifdef([_AC_LANG], [m4_defn([_AC_LANG])]), [$1])dnlm4_define([_AC_LANG], [$1])])# AC_LANG_PUSH(LANG)# ------------------# Save the current language, and use LANG.m4_defun([AC_LANG_PUSH],[_AC_LANG_SET(m4_ifdef([_AC_LANG], [m4_defn([_AC_LANG])]), [$1])dnlm4_pushdef([_AC_LANG], [$1])])# AC_LANG_POP([LANG])# -------------------# If given, check that the current language is LANG, and restore the# previous language.m4_defun([AC_LANG_POP],[m4_ifval([$1], [m4_if([$1], m4_defn([_AC_LANG]), [], [m4_fatal([$0($1): unexpected current language: ]m4_defn([_AC_LANG]))])])dnlm4_pushdef([$0 OLD], m4_defn([_AC_LANG]))dnlm4_popdef([_AC_LANG])dnl_AC_LANG_SET(m4_defn([$0 OLD]), m4_defn([_AC_LANG]))dnlm4_popdef([$0 OLD])dnl])# AC_LANG_SAVE# ------------# Save the current language, but don't change language.AU_DEFUN([AC_LANG_SAVE],[[AC_LANG_SAVE]],[Instead of using `AC_LANG', `AC_LANG_SAVE', and `AC_LANG_RESTORE',you should use `AC_LANG_PUSH' and `AC_LANG_POP'.])AC_DEFUN([AC_LANG_SAVE],[m4_pushdef([_AC_LANG], _AC_LANG)dnlAC_DIAGNOSE([obsolete], [The macro `AC_LANG_SAVE' is obsolete.You should run autoupdate.])])# AC_LANG_RESTORE# ---------------# Restore the current language from the stack.AU_DEFUN([AC_LANG_RESTORE], [AC_LANG_POP($@)])# _AC_LANG_ABBREV# ---------------# Return a short signature of _AC_LANG which can be used in shell# variable names, or in M4 macro names.m4_defun([_AC_LANG_ABBREV],[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])# _AC_LANG_PREFIX# ---------------# Return a short (upper case) signature of _AC_LANG that is used to# prefix environment variables like FLAGS.m4_defun([_AC_LANG_PREFIX],[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])# AC_LANG_ASSERT(LANG)# --------------------# Current language must be LANG.m4_defun([AC_LANG_ASSERT],[m4_if(_AC_LANG, $1, [], [m4_fatal([$0: current language is not $1: ] _AC_LANG)])])## ---------------------- #### 2.Producing programs. #### ---------------------- ### ---------------------- ## 2a. Generic routines. ## ---------------------- ## AC_LANG_CONFTEST(BODY)# ----------------------# Save the BODY in `conftest.$ac_ext'. Add a trailing new line.AC_DEFUN([AC_LANG_CONFTEST],[cat >conftest.$ac_ext <<_ACEOF$1_ACEOF])# AC_LANG_SOURCE(BODY)# --------------------# Produce a valid source for the current language, which includes the# BODY, and as much as possible `confdefs.h'.AC_DEFUN([AC_LANG_SOURCE],[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])# AC_LANG_PROGRAM([PROLOGUE], [BODY])# -----------------------------------# Produce a valid source for the current language. Prepend the# PROLOGUE (typically CPP directives and/or declarations) to an# execution the BODY (typically glued inside the `main' function, or# equivalent).AC_DEFUN([AC_LANG_PROGRAM],[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])# AC_LANG_CALL(PROLOGUE, FUNCTION)# --------------------------------# Call the FUNCTION.AC_DEFUN([AC_LANG_CALL],[m4_ifval([$2], [], [m4_warn([syntax], [$0: no function given])])dnl_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])# AC_LANG_FUNC_LINK_TRY(FUNCTION)# -------------------------------# Produce a source which links correctly iff the FUNCTION exists.AC_DEFUN([AC_LANG_FUNC_LINK_TRY],[m4_ifval([$1], [], [m4_warn([syntax], [$0: no function given])])dnl_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])# AC_LANG_BOOL_COMPILE_TRY(PROLOGUE, EXPRESSION)# ----------------------------------------------# Produce a program that compiles with success iff the boolean EXPRESSION# evaluates to true at compile time.AC_DEFUN([AC_LANG_BOOL_COMPILE_TRY],[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])# AC_LANG_INT_SAVE(PROLOGUE, EXPRESSION)# --------------------------------------# Produce a program that saves the runtime evaluation of the integer# EXPRESSION into `conftest.val'.AC_DEFUN([AC_LANG_INT_SAVE],[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])## -------------------------------------------- #### 3. Looking for Compilers and Preprocessors. #### -------------------------------------------- ### ----------------------------------------------------- ## 3a. Generic routines in compilers and preprocessors. ## ----------------------------------------------------- ## AC_LANG_COMPILER# ----------------# Find a compiler for the current LANG. Be sure to be run before# AC_LANG_PREPROC.## Note that because we might AC_REQUIRE `AC_LANG_COMPILER(C)' for# instance, the latter must be AC_DEFUN'd, not just define'd.m4_define([AC_LANG_COMPILER],[AC_BEFORE([AC_LANG_COMPILER(]_AC_LANG[)], [AC_LANG_PREPROC(]_AC_LANG[)])dnl_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])# AC_LANG_COMPILER_REQUIRE# ------------------------# Ensure we have a compiler for the current LANG.AC_DEFUN([AC_LANG_COMPILER_REQUIRE],[m4_require([AC_LANG_COMPILER(]_AC_LANG[)], [AC_LANG_COMPILER])])# _AC_LANG_COMPILER_GNU# ---------------------# Check whether the compiler for the current language is GNU.## It doesn't seem necessary right now to have a different source# according to the current language, since this works fine. Some day# it might be needed. Nevertheless, pay attention to the fact that# the position of `choke me' on the seventh column is meant: otherwise# some Fortran compilers (e.g., SGI) might consider it's a# continuation line, and warn instead of reporting an error.m4_define([_AC_LANG_COMPILER_GNU],[AC_CACHE_CHECK([whether we are using the GNU _AC_LANG compiler], [ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu],[_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __GNUC__ choke me#endif]])], [ac_compiler_gnu=yes], [ac_compiler_gnu=no])ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu=$ac_compiler_gnu])])# _AC_LANG_COMPILER_GNU# AC_LANG_PREPROC# ---------------# Find a preprocessor for the current language. Note that because we# might AC_REQUIRE `AC_LANG_PREPROC(C)' for instance, the latter must# be AC_DEFUN'd, not just define'd. Since the preprocessor depends# upon the compiler, look for the compiler.m4_define([AC_LANG_PREPROC],[AC_LANG_COMPILER_REQUIRE()dnl_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -