📄 c.m4
字号:
# This file is part of Autoconf. -*- Autoconf -*-# Programming languages support.# Copyright (C) 2001, 2002 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., 59 Temple Place - Suite 330, Boston, MA# 02111-1307, 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.# -------------------- ## 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])# ---------------------- ## 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=ccac_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])## ---------------------- #### 2.Producing programs. #### ---------------------- ### --------------- ## 2b. C sources. ## --------------- ## AC_LANG_SOURCE(C)(BODY)# -----------------------# This sometimes fails to find confdefs.h, for some reason.# #line $LINENO "$[0]"m4_define([AC_LANG_SOURCE(C)],[#line $LINENO "configure"/* 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])[]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 gcc2 internal prototype to avoid an error. */#ifdef __cplusplusextern "C"#endif/* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */char $2 ();])], [$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 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.#m4_define([AC_LANG_FUNC_LINK_TRY(C)],[AC_LANG_PROGRAM([/* System header to define __stub macros and hopefully few prototypes, which can conflict with char $1 (); below. */#include <assert.h>/* Override any gcc2 internal prototype to avoid an error. */#ifdef __cplusplusextern "C"{#endif/* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */char $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___$1)choke me#elsechar (*f) () = $1;#endif#ifdef __cplusplus}#endif])])# AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, 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([$1long longval () { return $2; }unsigned long ulongval () { return $2; }@%:@include <stdio.h>@%:@include <stdlib.h>],[ FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); if (($2) < 0) { long i = longval (); if (i != ($2)) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); if (i != ($2)) exit (1); fprintf (f, "%lu\n", i); } exit (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++)])## -------------------------------------------- #### 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}.AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],[AC_ARG_VAR([CPPFLAGS], [C/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.# Set ac_cpp_err to a non-empty value if the preprocessor failed.# This macro is for all languages, not only C.AC_DEFUN([_AC_PROG_PREPROC_WORKS_IFELSE],[ac_preproc_ok=falsefor ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yesdo # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <assert.h> Syntax error]])], [], [# Broken: fails on valid input.continue]) # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])], [# Broken: success on invalid input.continue], [# Passes both tests.ac_preproc_ok=:break])done# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.rm -f conftest.err conftest.$ac_extAS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE# AC_PROG_CPP# -----------# Find a working C preprocessor.# We shouldn't have to require AC_PROG_CC, but this is due to the concurrency# between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CC.AN_MAKEVAR([CPP], [AC_PROG_CPP])AN_PROGRAM([cpp], [AC_PROG_CPP])AC_DEFUN([AC_PROG_CPP],[AC_REQUIRE([AC_PROG_CC])dnlAC_ARG_VAR([CPP], [C preprocessor])dnl_AC_ARG_VAR_CPPFLAGS()dnlAC_LANG_PUSH(C)dnlAC_MSG_CHECKING([how to run the C preprocessor])# On Suns, sometimes $CPP names a directory.if test -n "$CPP" && test -d "$CPP"; then CPP=fiif test -z "$CPP"; then AC_CACHE_VAL([ac_cv_prog_CPP], [dnl # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do _AC_PROG_PREPROC_WORKS_IFELSE([break])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -