📄 aclocal_cc.m4
字号:
dnldnl This is a replacement for AC_PROG_CC that does not prefer gcc anddnl that does not mess with CFLAGS. See acspecific.m4 for the original defn.dnldnl/*Ddnl PAC_PROG_CC - Find a working C compilerdnldnl Synopsis:dnl PAC_PROG_CCdnldnl Output Effect:dnl Sets the variable CC if it is not already setdnldnl Notes:dnl Unlike AC_PROG_CC, this does not prefer gcc and does not set CFLAGS.dnl It does check that the compiler can compile a simple C program.dnl It also sets the variable GCC to yes if the compiler is gcc. It doesdnl not yet check for some special options needed in particular for dnl parallel computers, such as -Tcray-t3e, or special options to getdnl full ANSI/ISO C, such as -Aa for HP.dnldnl D*/dnl 2.52 doesn't have AC_PROG_CC_GNUifdef([AC_PROG_CC_GNU],,[AC_DEFUN([AC_PROG_CC_GNU],)])AC_DEFUN(PAC_PROG_CC,[AC_PROVIDE([AC_PROG_CC])AC_CHECK_PROGS(CC, cc xlC xlc pgcc icc gcc )test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])PAC_PROG_CC_WORKSAC_PROG_CC_GNUif test "$ac_cv_prog_gcc" = yes; then GCC=yeselse GCC=fi])dnldnl/*Ddnl PAC_C_CHECK_COMPILER_OPTION - Check that a compiler option is accepteddnl without warning messagesdnldnl Synopsis:dnl PAC_C_CHECK_COMPILER_OPTION(optionname,action-if-ok,action-if-fail)dnldnl Output Effects:dnldnl If no actions are specified, a working value is added to 'COPTIONS'dnldnl Notes:dnl This is now careful to check that the output is different, since dnl some compilers are noisy.dnl dnl We are extra careful to prototype the functions in case compiler optionsdnl that complain about poor code are in effect.dnldnl Because this is a long script, we have ensured that you can pass a dnl variable containing the option name as the first argument.dnlD*/AC_DEFUN(PAC_C_CHECK_COMPILER_OPTION,[AC_MSG_CHECKING([that C compiler accepts option $1])save_CFLAGS="$CFLAGS"CFLAGS="$1 $CFLAGS"rm -f conftest.outecho 'int try(void);int try(void){return 0;}' > conftest2.cecho 'int main(void);int main(void){return 0;}' > conftest.cif ${CC-cc} $save_CFLAGS $CPPFLAGS -o conftest conftest.c $LDFLAGS >conftest.bas 2>&1 ; then if ${CC-cc} $CFLAGS $CPPFLAGS -o conftest conftest.c $LDFLAGS >conftest.out 2>&1 ; then if diff -b conftest.out conftest.bas >/dev/null 2>&1 ; then AC_MSG_RESULT(yes) AC_MSG_CHECKING([that routines compiled with $1 can be linked with ones compiled without $1]) /bin/rm -f conftest.out /bin/rm -f conftest.bas if ${CC-cc} -c $save_CFLAGS $CPPFLAGS conftest2.c >conftest2.out 2>&1 ; then if ${CC-cc} $CFLAGS $CPPFLAGS -o conftest conftest2.o conftest.c $LDFLAGS >conftest.bas 2>&1 ; then if ${CC-cc} $CFLAGS $CPPFLAGS -o conftest conftest2.o conftest.c $LDFLAGS >conftest.out 2>&1 ; then if diff -b conftest.out conftest.bas >/dev/null 2>&1 ; then AC_MSG_RESULT(yes) CFLAGS="$save_CFLAGS" ifelse($2,,COPTIONS="$COPTIONS $1",$2) elif test -s conftest.out ; then cat conftest.out >&AC_FD_CC AC_MSG_RESULT(no) CFLAGS="$save_CFLAGS" $3 else AC_MSG_RESULT(no) CFLAGS="$save_CFLAGS" $3 fi else if test -s conftest.out ; then cat conftest.out >&AC_FD_CC fi AC_MSG_RESULT(no) CFLAGS="$save_CFLAGS" $3 fi else # Could not link with the option! AC_MSG_RESULT(no) fi else if test -s conftest2.out ; then cat conftest.out >&AC_FD_CC fi AC_MSG_RESULT(no) CFLAGS="$save_CFLAGS" $3 fi else cat conftest.out >&AC_FD_CC AC_MSG_RESULT(no) $3 CFLAGS="$save_CFLAGS" fi else AC_MSG_RESULT(no) $3 if test -s conftest.out ; then cat conftest.out >&AC_FD_CC ; fi CFLAGS="$save_CFLAGS" fielse # Could not compile without the option! AC_MSG_RESULT(no)firm -f conftest*])dnldnl/*Ddnl PAC_C_OPTIMIZATION - Determine C options for producing optimized codednldnl Synopsisdnl PAC_C_OPTIMIZATION([action if found])dnldnl Output Effect:dnl Adds options to 'COPTIONS' if no other action is specifieddnl dnl Notes:dnl This is a temporary standin for compiler optimization.dnl It should try to match known systems to known compilers (checking, ofdnl course), and then falling back to some common defaults.dnl Note that many compilers will complain about -g and aggressivednl optimization. dnlD*/AC_DEFUN(PAC_C_OPTIMIZATION,[ for copt in "-O4 -Ofast" "-Ofast" "-fast" "-O3" "-xO3" "-O" ; do PAC_C_CHECK_COMPILER_OPTION($copt,found_opt=yes,found_opt=no) if test "$found_opt" = "yes" ; then ifelse($1,,COPTIONS="$COPTIONS $copt",$1) break fi done if test "$ac_cv_prog_gcc" = "yes" ; then for copt in "-fomit-frame-pointer" "-finline-functions" \ "-funroll-loops" ; do PAC_C_CHECK_COMPILER_OPTION($copt,found_opt=yes,found_opt=no) if test $found_opt = "yes" ; then ifelse($1,,COPTIONS="$COPTIONS $copt",$1) # no break because we're trying to add them all fi done # We could also look for architecture-specific gcc options fi])dnldnl/*Ddnl PAC_C_DEPENDS - Determine how to use the C compiler to generate dnl dependency informationdnldnl Synopsis:dnl PAC_C_DEPENDSdnldnl Output Effects:dnl Sets the following shell variables and call AC_SUBST for them:dnl+ C_DEPEND_OPT - Compiler options needed to create dependenciesdnl. C_DEPEND_OUT - Shell redirection for dependency file (may be empty)dnl. C_DEPEND_PREFIX - Empty (null) or true; this is used to handlednl systems that do not provide dependency informationdnl- C_DEPEND_MV - Command to move created dependency filednl Also creates a Depends file in the top directory (!).dnldnl In addition, the variable 'C_DEPEND_DIR' must be set to indicate thednl directory in which the dependency files should live. dnldnl Notes:dnl A typical Make rule that exploits this macro isdnl.vbdnl #dnl # Dependency processingdnl .SUFFIXES: .depdnl DEP_SOURCES = ${SOURCES:%.c=.dep/%.dep}dnl C_DEPEND_DIR = .depdnl Depends: ${DEP_SOURCES}dnl @-rm -f Dependsdnl cat .dep/*.dep >Dependsdnl .dep/%.dep:%.cdnl @if [ ! -d .dep ] ; then mkdir .dep ; fidnl @@C_DEPEND_PREFIX@ ${C_COMPILE} @C_DEPEND_OPT@ $< @C_DEPEND_OUT@dnl @@C_DEPEND_MV@dnldnl depends-clean:dnl @-rm -f *.dep ${srcdir}/*.dep Depends ${srcdir}/Dependsdnl @-touch Dependsdnl.vednldnl For each file 'foo.c', this creates a file 'foo.dep' and creates a filednl 'Depends' that contains all of the '*.dep' files.dnldnl For your convenience, the autoconf variable 'C_DO_DEPENDS' names a file dnl that may contain this code (you must have `dependsrule` or dnl `dependsrule.in` in the same directory as the other auxillery configure dnl scripts (set with dnl 'AC_CONFIG_AUX_DIR'). If you use `dependsrule.in`,dnl you must have `dependsrule` in 'AC_OUTPUT' before this `Makefile`.dnl dnlD*/dnl dnl Eventually, we can add an option to the C_DEPEND_MV to strip systemdnl includes, such as /usr/xxxx and /opt/xxxxdnlAC_DEFUN(PAC_C_DEPENDS,[AC_SUBST(C_DEPEND_OPT)AM_IGNORE(C_DEPEND_OPT)AC_SUBST(C_DEPEND_OUT)AM_IGNORE(C_DEPEND_OUT)AC_SUBST(C_DEPEND_MV)AM_IGNORE(C_DEPEND_MV)AC_SUBST(C_DEPEND_PREFIX)AM_IGNORE(C_DEPEND_PREFIX)AC_SUBST_FILE(C_DO_DEPENDS) dnl set the value of the variable to a dnl file that contains the dependency code, such asdnl ${top_srcdir}/maint/dependrule if test -n "$ac_cv_c_depend_opt" ; then AC_MSG_RESULT([Option $ac_cv_c_depend_opt creates dependencies (cached)]) C_DEPEND_OUT="$ac_cv_c_depend_out" C_DEPEND_MV="$ac_cv_c_depend_mv" C_DEPEND_OPT="$ac_cv_c_depend_opt" C_DEPEND_PREFIX="$ac_cv_c_depend_prefix" C_DO_DEPENDS="$ac_cv_c_do_depends"else # Determine the valuesrm -f conftest*dnldnl Some systems (/usr/ucb/cc on Solaris) do not generate a dependency fordnl an include that doesn't begin in column 1dnlcat >conftest.c <<EOF #include "confdefs.h" int f(void) { return 0; }EOFdnl -xM1 is Solaris C compiler (no /usr/include files)dnl -MM is gcc (no /usr/include files)dnl -MMD is gcc to .ddnl .u is xlC (AIX) outputfor copt in "-xM1" "-c -xM1" "-xM" "-c -xM" "-MM" "-M" "-c -M"; do AC_MSG_CHECKING([whether $copt option generates dependencies]) rm -f conftest.o conftest.u conftest.d conftest.err conftest.out dnl also need to check that error output is empty if $CC $CFLAGS $copt conftest.c >conftest.out 2>conftest.err && \ test ! -s conftest.err ; then dnl Check for dependency info in conftest.out if test -s conftest.u ; then C_DEPEND_OUT="" C_DEPEND_MV='mv $[*].u ${C_DEPEND_DIR}/$[*].dep' pac_dep_file=conftest.u elif test -s conftest.d ; then C_DEPEND_OUT="" C_DEPEND_MV='mv $[*].d ${C_DEPEND_DIR}/$[*].dep' pac_dep_file=conftest.d else dnl C_DEPEND_OUT='>${C_DEPEND_DIR}/$[*].dep' dnl This for is needed for VPATH. Perhaps the others should match. C_DEPEND_OUT='>$@' C_DEPEND_MV=: pac_dep_file=conftest.out fi if grep 'confdefs.h' $pac_dep_file >/dev/null 2>&1 ; then AC_MSG_RESULT(yes) C_DEPEND_OPT="$copt" AC_MSG_CHECKING([whether .o file created with dependency file]) if test -s conftest.o ; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) echo "Output of $copt option was" >&AC_FD_CC cat $pac_dep_file >&AC_FD_CC fi break else AC_MSG_RESULT(no) fi else echo "Error in compiling program with flags $copt" >&AC_FD_CC cat conftest.out >&AC_FD_CC if test -s conftest.err ; then cat conftest.err >&AC_FD_CC ; fi AC_MSG_RESULT(no) fi copt=""done if test -f $CONFIG_AUX_DIR/dependsrule -o \ -f $CONFIG_AUX_DIR/dependsrule.in; then C_DO_DEPENDS="$CONFIG_AUX_DIR/dependsrule" else C_DO_DEPENDS="/dev/null" fi if test "X$copt" = "X" ; then C_DEPEND_PREFIX="true" else C_DEPEND_PREFIX="" fi ac_cv_c_depend_out="$C_DEPEND_OUT" ac_cv_c_depend_mv="$C_DEPEND_MV" ac_cv_c_depend_opt="$C_DEPEND_OPT" ac_cv_c_depend_prefix="$C_DEPEND_PREFIX" ac_cv_c_do_depends="$C_DO_DEPENDS"fi])dnldnl/*D dnl PAC_C_PROTOTYPES - Check that the compiler accepts ANSI prototypes. dnldnl Synopsis:dnl PAC_C_PROTOTYPES([action if true],[action if false])dnldnl D*/AC_DEFUN(PAC_C_PROTOTYPES,[AC_CACHE_CHECK([if $CC supports function prototypes],pac_cv_c_prototypes,[AC_TRY_COMPILE([int f(double a){return 0;}],[return 0];,pac_cv_c_prototypes="yes",pac_cv_c_prototypes="no")])if test "$pac_cv_c_prototypes" = "yes" ; then ifelse([$1],,:,[$1])else ifelse([$2],,:,[$2])fi])dnldnldnl/*Ddnl PAC_FUNC_SEMCTL - Check for semctl and its argument typesdnldnl Synopsis:dnl PAC_FUNC_SEMCTLdnldnl Output Effects:dnl Sets 'HAVE_SEMCTL' if semctl is available.dnl Sets 'HAVE_UNION_SEMUN' if 'union semun' is available.dnl Sets 'SEMCTL_NEEDS_SEMUN' if a 'union semun' type must be passed as thednl fourth argument to 'semctl'.dnlD*/ dnl Check for semctl and argumentsAC_DEFUN(PAC_FUNC_SEMCTL,[AC_CHECK_FUNC(semctl)if test "$ac_cv_func_semctl" = "yes" ; then AC_CACHE_CHECK([for union semun], pac_cv_type_union_semun,[ AC_TRY_COMPILE([#include <sys/types.h>#include <sys/ipc.h>#include <sys/sem.h>],[union semun arg;arg.val=0;], pac_cv_type_union_semun="yes",pac_cv_type_union_semun="no")]) if test "$pac_cv_type_union_semun" = "yes" ; then AC_DEFINE(HAVE_UNION_SEMUN,,[Has union semun]) # # See if we can use an int in semctl or if we need the union AC_CACHE_CHECK([whether semctl needs union semun], pac_cv_func_semctl_needs_semun,[ AC_TRY_COMPILE([#include <sys/types.h>#include <sys/ipc.h>#include <sys/sem.h>],[int arg = 0; semctl( 1, 1, SETVAL, arg );], pac_cv_func_semctl_needs_semun="yes", pac_cv_func_semctl_needs_semun="no") ]) if test "$pac_cv_func_semctl_needs_semun" = "yes" ; then AC_DEFINE(SEMCTL_NEEDS_SEMUN,[Needs an explicit definition of semun]) fi fifi])dnldnl/*Ddnl PAC_C_VOLATILE - Check if C supports volatilednldnl Synopsis:dnl PAC_C_VOLATILEdnldnl Output Effect:dnl Defines 'volatile' as empty if volatile is not available.dnldnlD*/AC_DEFUN(PAC_C_VOLATILE,[AC_CACHE_CHECK([for volatile],pac_cv_c_volatile,[AC_TRY_COMPILE(,[volatile int a;],pac_cv_c_volatile="yes",pac_cv_c_volatile="no")])if test "$pac_cv_c_volatile" = "no" ; then AC_DEFINE(volatile,,[if C does not support volatile])fi])dnldnldnl/*Ddnl PAC_C_INLINE - Check if C supports inlinednldnl Synopsis:dnl PAC_C_INLINEdnldnl Output Effect:dnl Defines 'inline' as empty if inline is not available.dnldnlD*/AC_DEFUN(PAC_C_INLINE,[AC_CACHE_CHECK([for inline],pac_cv_c_inline,[AC_TRY_COMPILE([inline int a( int b ){return b+1;}],[int a;],pac_cv_c_inline="yes",pac_cv_c_inline="no")])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -