📄 c.m4
字号:
# This file is part of Autoconf. -*- Autoconf -*-# Programming languages support.# Copyright (C) 2001, 2002, 2003, 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# Akim Demaille, Paul Eggert,# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,# Roland McGrath, Noah Friedman, david d zuhn, and many others.# -------------------- ## 1b. The C language. ## -------------------- ## AC_LANG(C)# ----------# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.m4_define([AC_LANG(C)],[ac_ext=cac_cpp='$CPP $CPPFLAGS'ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'ac_compiler_gnu=$ac_cv_c_compiler_gnu])# AC_LANG_C# ---------AU_DEFUN([AC_LANG_C], [AC_LANG(C)])# _AC_LANG_ABBREV(C)# ------------------m4_define([_AC_LANG_ABBREV(C)], [c])# _AC_LANG_PREFIX(C)# ------------------m4_define([_AC_LANG_PREFIX(C)], [C])# ---------------------- ## 1c. The C++ language. ## ---------------------- ## AC_LANG(C++)# ------------# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.m4_define([AC_LANG(C++)],[ac_ext=cppac_cpp='$CXXCPP $CPPFLAGS'ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'ac_compiler_gnu=$ac_cv_cxx_compiler_gnu])# AC_LANG_CPLUSPLUS# -----------------AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)])# _AC_LANG_ABBREV(C++)# --------------------m4_define([_AC_LANG_ABBREV(C++)], [cxx])# _AC_LANG_PREFIX(C++)# --------------------m4_define([_AC_LANG_PREFIX(C++)], [CXX])# ------------------------------ ## 1d. The Objective C language. ## ------------------------------ ## AC_LANG(Objective C)# --------------------m4_define([AC_LANG(Objective C)],[ac_ext=mac_cpp='$OBJCPP $CPPFLAGS'ac_compile='$OBJC -c $OBJCFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'ac_link='$OBJC -o conftest$ac_exeext $OBJCFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'ac_compiler_gnu=$ac_cv_objc_compiler_gnu])# AC_LANG_OBJC# ------------AU_DEFUN([AC_LANG_OBJC], [AC_LANG(Objective C)])# _AC_LANG_ABBREV(Objective C)# ----------------------------m4_define([_AC_LANG_ABBREV(Objective C)], [objc])# _AC_LANG_PREFIX(Objective C)# ----------------------------m4_define([_AC_LANG_PREFIX(Objective C)], [OBJC])## ---------------------- #### 2.Producing programs. #### ---------------------- ### --------------- ## 2b. C sources. ## --------------- ## AC_LANG_SOURCE(C)(BODY)# -----------------------# We can't use '#line $LINENO "configure"' here, since# Sun c89 (Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09)# rejects $LINENO greater than 32767, and some configure scripts# are longer than 32767 lines.m4_define([AC_LANG_SOURCE(C)],[/* confdefs.h. */_ACEOFcat confdefs.h >>conftest.$ac_extcat >>conftest.$ac_ext <<_ACEOF/* end confdefs.h. */$1])# AC_LANG_PROGRAM(C)([PROLOGUE], [BODY])# --------------------------------------m4_define([AC_LANG_PROGRAM(C)],[$1m4_ifdef([_AC_LANG_PROGRAM_C_F77_HOOKS], [_AC_LANG_PROGRAM_C_F77_HOOKS])[]dnlm4_ifdef([_AC_LANG_PROGRAM_C_FC_HOOKS], [_AC_LANG_PROGRAM_C_FC_HOOKS])[]dnlintmain (){dnl Do *not* indent the following line: there may be CPP directives.dnl Don't move the `;' right after for the same reason.$2 ; return 0;}])# AC_LANG_CALL(C)(PROLOGUE, FUNCTION)# -----------------------------------# Avoid conflicting decl of main.m4_define([AC_LANG_CALL(C)],[AC_LANG_PROGRAM([$1m4_if([$2], [main], ,[/* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */#ifdef __cplusplusextern "C"#endifchar $2 ();])], [return $2 ();])])# AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)# ----------------------------------# Don't include <ctype.h> because on OSF/1 3.0 it includes# <sys/types.h> which includes <sys/select.h> which contains a# prototype for select. Similarly for bzero.## This test used to merely assign f=$1 in main(), but that was# optimized away by HP unbundled cc A.05.36 for ia64 under +O3,# presumably on the basis that there's no need to do that store if the# program is about to exit. Conversely, the AIX linker optimizes an# unused external declaration that initializes f=$1. So this test# program has both an external initialization of f, and a use of f in# main that affects the exit status.#m4_define([AC_LANG_FUNC_LINK_TRY(C)],[AC_LANG_PROGRAM([/* Define $1 to an innocuous variant, in case <limits.h> declares $1. For example, HP-UX 11i <limits.h> declares gettimeofday. */#define $1 innocuous_$1/* System header to define __stub macros and hopefully few prototypes, which can conflict with char $1 (); below. Prefer <limits.h> to <assert.h> if __STDC__ is defined, since <limits.h> exists even on freestanding compilers. */#ifdef __STDC__# include <limits.h>#else# include <assert.h>#endif#undef $1/* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */#ifdef __cplusplusextern "C"#endifchar $1 ();/* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */#if defined __stub_$1 || defined __stub___$1choke me#endif], [return $1 ();])])# AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)# -------------------------------------------------# Return a program that is valid if EXPRESSION is nonzero.# EXPRESSION must be an integer constant expression.# Be sure to use this array to avoid `unused' warnings, which are even# errors with `-W error'.m4_define([AC_LANG_BOOL_COMPILE_TRY(C)],[AC_LANG_PROGRAM([$1], [static int test_array @<:@1 - 2 * !($2)@:>@;test_array @<:@0@:>@ = 0])])# AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)# -----------------------------------------# We need `stdio.h' to open a `FILE' and `stdlib.h' for `exit'.# But we include them only after the EXPRESSION has been evaluated.m4_define([AC_LANG_INT_SAVE(C)],[AC_LANG_PROGRAM([$1static long int longval () { return $2; }static unsigned long int ulongval () { return $2; }@%:@include <stdio.h>@%:@include <stdlib.h>],[ FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu\n", i); } return ferror (f) || fclose (f) != 0;])])# ----------------- ## 2c. C++ sources. ## ----------------- ## AC_LANG_SOURCE(C++)(BODY)# -------------------------m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])# AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])# ----------------------------------------m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])# AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)# -------------------------------------m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])# AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)# ------------------------------------m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])# AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)# ---------------------------------------------------m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])# AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)# -------------------------------------------m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])# ------------------------- ## 2d. Objective C sources. ## ------------------------- ## AC_LANG_SOURCE(Objective C)(BODY)# ---------------------------------m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(Objective C)])# AC_LANG_PROGRAM(Objective C)([PROLOGUE], [BODY])# ------------------------------------------------m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(Objective C)])# AC_LANG_CALL(Objective C)(PROLOGUE, FUNCTION)# ---------------------------------------------m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(Objective C)])# AC_LANG_FUNC_LINK_TRY(Objective C)(FUNCTION)# --------------------------------------------m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(Objective C)])# AC_LANG_BOOL_COMPILE_TRY(Objective C)(PROLOGUE, EXPRESSION)# -----------------------------------------------------------m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(Objective C)])# AC_LANG_INT_SAVE(Objective C)(PROLOGUE, EXPRESSION)# ---------------------------------------------------m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(Objective C)])## -------------------------------------------- #### 3. Looking for Compilers and Preprocessors. #### -------------------------------------------- ### -------------------- ## 3b. The C compiler. ## -------------------- ## _AC_ARG_VAR_CPPFLAGS# --------------------# Document and register CPPFLAGS, which is used by# AC_PROG_{CC, CPP, CXX, CXXCPP, OBJC, OBJCPP}.AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],[AC_ARG_VAR([CPPFLAGS], [C/C++/Objective C preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir>])])# _AC_ARG_VAR_LDFLAGS# -------------------# Document and register LDFLAGS, which is used by# AC_PROG_{CC, CXX, F77}.AC_DEFUN([_AC_ARG_VAR_LDFLAGS],[AC_ARG_VAR([LDFLAGS], [linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir>])])# AC_LANG_PREPROC(C)# -------------------# Find the C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.AC_DEFUN([AC_LANG_PREPROC(C)],[AC_REQUIRE([AC_PROG_CPP])])# _AC_PROG_PREPROC_WORKS_IFELSE(IF-WORKS, IF-NOT)# -----------------------------------------------# Check if $ac_cpp is a working preprocessor that can flag absent# includes either by the exit status or by warnings.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -