📄 c.m4
字号:
CXXFLAGS="-O2" else CXXFLAGS= fifi[]dnl])# _AC_PROG_CXX_G# AC_PROG_CXX_C_O# ---------------# Test if the C++ compiler accepts the options `-c' and `-o'# simultaneously, and define `CXX_NO_MINUS_C_MINUS_O' if it does not.AC_DEFUN([AC_PROG_CXX_C_O],[AC_REQUIRE([AC_PROG_CXX])dnlAC_LANG_PUSH([C++])dnlAC_CACHE_CHECK([whether $CXX understands -c and -o together], [ac_cv_prog_cxx_c_o],[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])# We test twice because some compilers refuse to overwrite an existing# `.o' file with `-o', although they will create one.ac_try='$CXX $CXXFLAGS -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'rm -f conftest2.*if _AC_DO_VAR(ac_try) && test -f conftest2.$ac_objext && _AC_DO_VAR(ac_try); then ac_cv_prog_cxx_c_o=yeselse ac_cv_prog_cxx_c_o=nofirm -f conftest*])if test $ac_cv_prog_cxx_c_o = no; then AC_DEFINE(CXX_NO_MINUS_C_MINUS_O, 1, [Define to 1 if your C++ compiler doesn't accept -c and -o together.])fiAC_LANG_POP([C++])dnl])# AC_PROG_CXX_C_O# ------------------------------ ## 3d. The Objective C compiler. ## ------------------------------ ## AC_LANG_PREPROC(Objective C)# ----------------------------# Find the Objective C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.AC_DEFUN([AC_LANG_PREPROC(Objective C)],[AC_REQUIRE([AC_PROG_OBJCPP])])# AC_PROG_OBJCPP# --------------# Find a working Objective C preprocessor.AC_DEFUN([AC_PROG_OBJCPP],[AC_REQUIRE([AC_PROG_OBJC])dnlAC_ARG_VAR([OBJCPP], [Objective C preprocessor])dnl_AC_ARG_VAR_CPPFLAGS()dnlAC_LANG_PUSH(Objective C)dnlAC_MSG_CHECKING([how to run the Objective C preprocessor])if test -z "$OBJCPP"; then AC_CACHE_VAL(ac_cv_prog_OBJCPP, [dnl # Double quotes because OBJCPP needs to be expanded for OBJCPP in "$OBJC -E" "/lib/cpp" do _AC_PROG_PREPROC_WORKS_IFELSE([break]) done ac_cv_prog_OBJCPP=$OBJCPP ])dnl OBJCPP=$ac_cv_prog_OBJCPPelse ac_cv_prog_OBJCPP=$OBJCPPfiAC_MSG_RESULT([$OBJCPP])_AC_PROG_PREPROC_WORKS_IFELSE([], [AC_MSG_FAILURE([Objective C preprocessor "$OBJCPP" fails sanity check])])AC_SUBST(OBJCPP)dnlAC_LANG_POP(Objective C)dnl])# AC_PROG_OBJCPP# AC_LANG_COMPILER(Objective C)# -----------------------------# Find the Objective C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.AC_DEFUN([AC_LANG_COMPILER(Objective C)],[AC_REQUIRE([AC_PROG_OBJC])])# AC_PROG_OBJC([LIST-OF-COMPILERS])# ---------------------------------# LIST-OF-COMPILERS is a space separated list of Objective C compilers to# search for (if not specified, a default list is used). This just gives# the user an opportunity to specify an alternative search list for the# Objective C compiler.# objcc StepStone Objective-C compiler (also "standard" name for OBJC)# objc David Stes' POC. If you installed this, you likely want it.# cc Native C compiler (for instance, Apple).# CC You never know.AN_MAKEVAR([OBJC], [AC_PROG_OBJC])AN_PROGRAM([objcc], [AC_PROG_OBJC])AN_PROGRAM([objc], [AC_PROG_OBJC])AC_DEFUN([AC_PROG_OBJC],[AC_LANG_PUSH(Objective C)dnlAC_ARG_VAR([OBJC], [Objective C compiler command])dnlAC_ARG_VAR([OBJCFLAGS], [Objective C compiler flags])dnl_AC_ARG_VAR_LDFLAGS()dnl_AC_ARG_VAR_CPPFLAGS()dnl_AC_ARG_VAR_PRECIOUS([OBJC])dnlAC_CHECK_TOOLS(OBJC, [m4_default([$1], [gcc objcc objc cc CC])], gcc)# Provide some information about the compiler._AS_ECHO_LOG([checking for _AC_LANG compiler version])ac_compiler=`set X $ac_compile; echo $[2]`_AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])_AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])_AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])m4_expand_once([_AC_COMPILER_EXEEXT])[]dnlm4_expand_once([_AC_COMPILER_OBJEXT])[]dnl_AC_LANG_COMPILER_GNUGOBJC=`test $ac_compiler_gnu = yes && echo yes`_AC_PROG_OBJC_GAC_LANG_POP(Objective C)dnl])# AC_PROG_OBJC# _AC_PROG_OBJC_G# ---------------# Check whether -g works, even if OBJCFLAGS is set, in case the package# plays around with OBJCFLAGS (such as to build both debugging and# normal versions of a library), tasteless as that idea is.# Don't consider -g to work if it generates warnings when plain compiles don't.m4_define([_AC_PROG_OBJC_G],[ac_test_OBJCFLAGS=${OBJCFLAGS+set}ac_save_OBJCFLAGS=$OBJCFLAGSAC_CACHE_CHECK(whether $OBJC accepts -g, ac_cv_prog_objc_g, [ac_save_objc_werror_flag=$ac_objc_werror_flag ac_objc_werror_flag=yes ac_cv_prog_objc_g=no OBJCFLAGS="-g" _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ac_cv_prog_objc_g=yes], [OBJCFLAGS="" _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [], [ac_objc_werror_flag=$ac_save_objc_werror_flag OBJCFLAGS="-g" _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ac_cv_prog_objc_g=yes])])]) ac_objc_werror_flag=$ac_save_objc_werror_flag])if test "$ac_test_OBJCFLAGS" = set; then OBJCFLAGS=$ac_save_OBJCFLAGSelif test $ac_cv_prog_objc_g = yes; then if test "$GOBJC" = yes; then OBJCFLAGS="-g -O2" else OBJCFLAGS="-g" fielse if test "$GOBJC" = yes; then OBJCFLAGS="-O2" else OBJCFLAGS= fifi[]dnl])# _AC_PROG_OBJC_G## ------------------------------- #### 4. Compilers' characteristics. #### ------------------------------- ### -------------------------------- ## 4b. C compiler characteristics. ## -------------------------------- ## _AC_PROG_CC_C89 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])# ----------------------------------------------------------------# If the C compiler is not in ANSI C89 (ISO C90) mode by default, try# to add an option to output variable CC to make it so. This macro# tries various options that select ANSI C89 on some system or# another. It considers the compiler to be in ANSI C89 mode if it# handles function prototypes correctly.AC_DEFUN([_AC_PROG_CC_C89],[_AC_C_STD_TRY([c89],[[#include <stdarg.h>#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */struct buf { int x; };FILE * (*rcsopen) (struct buf *, struct stat *, int);static char *e (p, i) char **p; int i;{ return p[i];}static char *f (char * (*g) (char **, int), char **p, ...){ char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s;}/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */int osf4_cc_array ['\x00' == 0 ? 1 : -1];/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */#define FOO(x) 'x'int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];int test (int i, double x);struct s1 {int (*f) (int a);};struct s2 {int (*f) (double a);};int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);int argc;char **argv;]],[[return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];]],dnl Don't try gcc -ansi; that turns off useful extensions anddnl breaks some systems' header files.dnl AIX circa 2003 -qlanglvl=extc89dnl old AIX -qlanglvl=ansidnl Ultrix, OSF/1, Tru64 -stddnl HP-UX 10.20 and later -Aednl HP-UX older versions -Aa -D_HPUX_SOURCEdnl SVR4 -Xc -D__EXTENSIONS__[-qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"], [$1], [$2])[]dnl])# _AC_PROG_CC_C89# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)# --------------------------------------------------------------# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails,# try again with each compiler option in the space-separated OPTION-LIST; if one# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,# else ACTION-IF-UNAVAILABLE.AC_DEFUN([_AC_C_STD_TRY],[AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C]))AC_CACHE_VAL(ac_cv_prog_cc_$1,[ac_cv_prog_cc_$1=noac_save_CC=$CCAC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])for ac_arg in '' $4do CC="$ac_save_CC $ac_arg" _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg]) test "x$ac_cv_prog_cc_$1" != "xno" && breakdonerm -f conftest.$ac_extCC=$ac_save_CC])# AC_CACHE_VALcase "x$ac_cv_prog_cc_$1" in x) AC_MSG_RESULT([none needed]) ;; xno) AC_MSG_RESULT([unsupported]) ;; *) CC="$CC $ac_cv_prog_cc_$1" AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;esacAS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])])# _AC_C_STD_TRY# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])# ----------------------------------------------------------------# If the C compiler is not in ISO C99 mode by default, try to add an# option to output variable CC to make it so. This macro tries# various options that select ISO C99 on some system or another. It# considers the compiler to be in ISO C99 mode if it handles mixed# code and declarations, _Bool, inline and restrict.AC_DEFUN([_AC_PROG_CC_C99],[_AC_C_STD_TRY([c99],[[#include <stdarg.h>#include <stdbool.h>#include <stdlib.h>#include <wchar.h>#include <stdio.h>struct incomplete_array{ int datasize; double data[];};struct named_init { int number; const wchar_t *name; double average;};typedef const char *ccp;static inline inttest_restrict(ccp restrict text){ // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0;}// Check varargs and va_copy work.static voidtest_varargs(const char *format, ...){ va_list args; va_start(args, format); va_list args_copy; va_copy(args_copy, args); const char *str; int number; float fnumber; while (*format) { switch (*format++) { case 's': // string str = va_arg(args_copy, const char *); break; case 'd': // int number = va_arg(args_copy, int); break; case 'f': // float fnumber = (float) va_arg(args_copy, double); break; default: break; } } va_end(args_copy); va_end(args);}]],[[ // Check bool and long long datatypes. _Bool success = false; long long int bignum = -1234567890LL; unsigned long long int ubignum = 1234567890uLL; // Check restrict. if (test_restrict("String literal") != 0) success = true; char *restrict newvar = "Another string"; // Check varargs. test_varargs("s, d' f .", "string", 65, 34.234); // Check incomplete arrays work. struct incomplete_array *ia = malloc(sizeof(struct incomplete_array) + (sizeof(double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = (double) i * 1.234; // Check named initialisers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[43] = 543; // work around unused variable warnings return bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x';]],dnl Trydnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)dnl AIX -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99)dnl Intel ICC -c99dnl IRIX -c99dnl Solaris (unused because it causes the compiler to assume C99 semantics fordnl library functions, and this is invalid before Solaris 10: -xc99)dnl Tru64 -c99dnl with extended modes being tried first.[[-std=gnu99 -c99 -qlanglvl=extc99]], [$1], [$2])[]dnl])# _AC_PROG_CC_C99# AC_PROG_CC_C89
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -