⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aclocal.m4

📁 一个开放源代码的 AT&T 的 Korn Shell 的复制品, 支持大多数 ksh89 的特性。
💻 M4
📖 第 1 页 / 共 3 页
字号:
dnl Copyright (C) 1996, Memorial University of Newfoundland.dnl This file is covered by the GNU General Public License, version 2, seednl the file misc/COPYING for details.dnldnl This file is covered by the GPL 'cause it contains some modified versionsdnl of autoconf's macros, in particular:dnl	AC_FUNC_MMAP AC_LANG_C AC_LANG_CPLUXPLUS AC_TRY_RUN KSH_HEADER_SYS_WAITdnl	AC_HEADER_STAT AC_PROG_CCdnldnldnl Like AC_CHECK_TYPE(), onlydnl	- user gets to specify header file(s) in addition to the defaultdnl	  headers (<sys/types.h> and <stdlib.h>)dnl	- user gets to specify the messagednl	- word boundary checks are put at beginning/end of patterndnl	  (ie, \<pattern\>)dnl	- default argument is optionaldnl uses ac_cv_type_X 'cause this is used in other autoconf macros...dnl KSH_CHECK_H_TYPE(type, message, header files, default)AC_DEFUN(KSH_CHECK_H_TYPE, [AC_CACHE_CHECK($2, ac_cv_type_$1,    [AC_EGREP_CPP([(^|[^a-zA-Z0-9_])]$1[([^a-zA-Z0-9_]|\$)],      [#include <sys/types.h>#if STDC_HEADERS#include <stdlib.h>#endif$3      ], ac_cv_type_$1=yes, ac_cv_type_$1=no)])  ifelse($#, 4, [if test $ac_cv_type_$1 = no; then      AC_DEFINE($1, $4)  fi  ])dnl ])dnldnldnldnldnl Check for memmove and if not found, check for bcopy.  AC_CHECK_FUNCS()dnl not used 'cause it confuses some compilers that have memmove/bcopy builtin;dnl Also want to check if the function deals with overlapping src/dst properly.AC_DEFUN(KSH_MEMMOVE, [AC_CACHE_CHECK(for working memmove, ksh_cv_func_memmove,    [AC_TRY_RUN([#ifdef HAVE_STRING_H# include <string.h>#else# include <strings.h>#endif#ifdef HAVE_MEMORY_H# include <memory.h>#endif        int        main()        {	  char buf[16];	  strcpy(buf, "abcdefABCDEF");	  memmove(buf + 4, buf, 6);	  if (strcmp(buf, "abcdabcdefEF"))	    exit(1);	  memmove(buf, buf + 4, 6);	  if (strcmp(buf, "abcdefcdefEF"))	    exit(2);	  exit(0);	  return 0;	}],       ksh_cv_func_memmove=yes, ksh_cv_func_memmove=no,       AC_MSG_WARN(assuming memmove broken); ksh_cv_func_memmove=no)])  if test $ksh_cv_func_memmove = yes; then    AC_DEFINE(HAVE_MEMMOVE)  else    AC_CACHE_CHECK(for working bcopy, ksh_cv_func_bcopy,      [AC_TRY_RUN([#ifdef HAVE_STRING_H# include <string.h>#else# include <strings.h>#endif#ifdef HAVE_MEMORY_H# include <memory.h>#endif	  int	  main()	  {	    char buf[16];	    strcpy(buf, "abcdefABCDEF");	    bcopy(buf, buf + 4, 6);	    if (strcmp(buf, "abcdabcdefEF"))	      exit(1);	    bcopy(buf + 4, buf, 6);	    if (strcmp(buf, "abcdefcdefEF"))	      exit(2);	    exit(0);	  }],	 ksh_cv_func_bcopy=yes, ksh_cv_func_bcopy=no,         AC_MSG_WARN(assuming bcopy broken); ksh_cv_func_bcopy=no)])    if test $ksh_cv_func_bcopy = yes; then      AC_DEFINE(HAVE_BCOPY)    fi  fi ])dnldnldnldnldnl Check for sigsetjmp()/siglongjmp() and _setjmp()/_longjmp() pairs.dnl Can't use simple library check as QNX 422 has _setjmp() but not _longjmp()dnl (go figure).AC_DEFUN(KSH_SETJMP, [AC_CACHE_CHECK(for sigsetjmp()/siglongjmp(), ksh_cv_func_sigsetjmp,    [AC_TRY_LINK([], [sigsetjmp(); siglongjmp()],       ksh_cv_func_sigsetjmp=yes, ksh_cv_func_sigsetjmp=no)])  if test $ksh_cv_func_sigsetjmp = yes; then    AC_DEFINE(HAVE_SIGSETJMP)  else    AC_CACHE_CHECK(for _setjmp()/_longjmp(), ksh_cv_func__setjmp,      [AC_TRY_LINK([], [_setjmp(); _longjmp();],	 ksh_cv_func__setjmp=yes, ksh_cv_func__setjmp=no)])    if test $ksh_cv_func__setjmp = yes; then      AC_DEFINE(HAVE__SETJMP)    fi  fi ])dnldnldnldnldnl Check for memset function.   AC_CHECK_FUNCS() not used 'cause it confusesdnl some compilers that have memset builtin.AC_DEFUN(KSH_MEMSET, [AC_CACHE_CHECK(for memset, ksh_cv_func_memset,    [AC_TRY_LINK([#ifdef HAVE_STRING_H# include <string.h>#else# include <strings.h>#endif#ifdef HAVE_MEMORY_H# include <memory.h>#endif       ], [       char buf[16]; memset(buf, 'x', 7); printf("%7s", buf);],       ksh_cv_func_memset=yes, ksh_cv_func_memset=no)])  if test $ksh_cv_func_memset = yes; then    AC_DEFINE(HAVE_MEMSET)  fi ])dnldnldnldnldnl Check for rlim_t in a few places, and if not found, figure out thednl size rlim_t should be by looking at struct rlimit.rlim_cur.AC_DEFUN(KSH_RLIM_CHECK, [KSH_CHECK_H_TYPE(rlim_t, for rlim_t in <sys/types.h> and <sys/resource.h>,   [#ifdef HAVE_SYS_RESOURCE_H#include <sys/resource.h>#endif])dnl  if test $ac_cv_type_rlim_t = no; then    AC_MSG_CHECKING(what to set rlim_t to)    if test $ac_cv_header_sys_resource_h = yes; then      AC_CACHE_VAL(ksh_cv_rlim_check,	[AC_TRY_RUN([#include <sys/types.h>#include <sys/time.h>#include <sys/resource.h>	    main()	    {	      struct rlimit rl;	      if (sizeof(rl.rlim_cur) == sizeof(quad_t))		exit(0);	      exit(1);	    }	  ], ksh_cv_rlim_check=quad_t, ksh_cv_rlim_check=long,	  AC_MSG_ERROR(cannot determine type for rlimt_t when cross compiling)	  )])dnl    else      ksh_cv_rlim_check=long    fi    AC_MSG_RESULT($ksh_cv_rlim_check)    AC_DEFINE_UNQUOTED(rlim_t, $ksh_cv_rlim_check)  fi ])dnldnldnldnlAC_DEFUN(KSH_DEV_FD, [AC_CACHE_CHECK(if you have /dev/fd/n, ksh_cv_dev_fd,    [AC_TRY_RUN([#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>	  main()	  {	    struct stat s1, s2;	    FILE *fp1, *fp2;	    char *file = "conftest.file";	    char devfd[32];	    if (!(fp1 = fopen(file, "w")))	      exit(1);	    if (fstat(fileno(fp1), &s1) < 0)	      exit(2);	    sprintf(devfd, "/dev/fd/%d", fileno(fp1));	    if (!(fp2 = fopen(devfd, "w")))	      exit(3);	    if (fstat(fileno(fp2), &s2) < 0)	      exit(4);	    if (s1.st_dev != s2.st_dev || s1.st_ino != s2.st_ino)	      exit(5);	    exit(0);	  }	], ksh_cv_dev_fd=yes, ksh_cv_dev_fd=no,	AC_MSG_WARN(cannot determine if you have /dev/fd support, assuming not)	ksh_cv_dev_fd=no)])  if test $ksh_cv_dev_fd = yes; then    AC_DEFINE(HAVE_DEV_FD)  fi ])dnldnldnldnldnl  Check for sys_siglist[] declaration and existence.AC_DEFUN(KSH_SYS_SIGLIST, [AC_DECL_SYS_SIGLIST  if test ac_cv_decl_sys_siglist = yes; then    AC_DEFINE(HAVE_SYS_SIGLIST)  else    AC_CACHE_CHECK(for sys_siglist in library, ksh_cv_var_sys_siglist,      [AC_TRY_LINK(, [	  extern char *sys_siglist[];	  char *p = sys_siglist[2];	  if (p)		  return 12;	  ], ksh_cv_var_sys_siglist=yes, ksh_cv_var_sys_siglist=no)])    if test $ksh_cv_var_sys_siglist = yes; then      AC_DEFINE(HAVE_SYS_SIGLIST)    fi  fi ])dnldnldnldnldnl  Check for sys_errlist[] declaration and existence.AC_DEFUN(KSH_SYS_ERRLIST, [AC_CACHE_CHECK(for sys_errlist declaration in errno.h, ksh_cv_decl_sys_errlist,  [AC_TRY_COMPILE([#include <errno.h>],    [char *msg = *(sys_errlist + 1); if (msg && *msg) return 12; ],    ksh_cv_decl_sys_errlist=yes, ksh_cv_decl_sys_errlist=no)])  if test $ksh_cv_decl_sys_errlist = yes; then    AC_DEFINE(SYS_ERRLIST_DECLARED)    AC_DEFINE(HAVE_SYS_ERRLIST)  else    AC_CACHE_CHECK(for sys_errlist in library, ksh_cv_var_sys_errlist,      [AC_TRY_LINK(, [	    extern char *sys_errlist[];	    extern int sys_nerr;	    char *p;	    p = sys_errlist[sys_nerr - 1];	    if (p) return 12;	  ], ksh_cv_var_sys_errlist=yes, ksh_cv_var_sys_errlist=no)])    if test $ksh_cv_var_sys_errlist = yes; then      AC_DEFINE(HAVE_SYS_ERRLIST)    fi  fi ])dnldnldnldnldnl  Check if time() declared in time.hAC_DEFUN(KSH_TIME_DECLARED, [AC_CACHE_CHECK(time() declaration in time.h, ksh_cv_time_delcared,    [AC_TRY_COMPILE([#include <sys/types.h>#include <time.h>], [time_t (*f)() = time; if (f) return 12;],      ksh_cv_time_delcared=yes, ksh_cv_time_delcared=no)])  if test $ksh_cv_time_delcared = yes; then    AC_DEFINE(TIME_DECLARED)  fi ])dnldnldnldnldnl Check for working times (ie, it exists and doesn't always return 0).dnl Defines TIMES_BROKEN if it doesn't exist or if it always returns 0dnl (also checks for existance of getrusage if times doesn't work).dnl  XXX: requires clock_t to be typedefed/defined...AC_DEFUN(KSH_TIMES_CHECK, [AC_CACHE_CHECK(if times() is present/working, ksh_cv_func_times_ok,    [AC_TRY_RUN([#include <sys/types.h>#include <sys/times.h>/* if missing, clock_t is defined to be INT32 */#if SIZEOF_INT == 4# define INT32	int#else /* SIZEOF_INT */# if SIZEOF_LONG == 4#  define INT32	long# else /* SIZEOF_LONG */   #error cannot find 32 bit type...# endif /* SIZEOF_LONG */#endif /* SIZEOF_INT */	  main()	  {	    extern clock_t times();	    struct tms tms;	    times(&tms);	    sleep(1);	    if (times(&tms) == 0)	      exit(1);	    exit(0);	  }	], ksh_cv_func_times_ok=yes, ksh_cv_func_times_ok=no,	AC_MSG_ERROR(cannot determine if times works when cross compiling)	)])  if test $ksh_cv_func_times_ok = no; then    AC_DEFINE(TIMES_BROKEN)    AC_CHECK_FUNCS(getrusage)  fi ])dnldnldnldnlAC_DEFUN(KSH_C_VOID, [AC_CACHE_CHECK(if compiler understands void, ksh_cv_c_void,    [AC_TRY_COMPILE(      [	void foo() { }	/* Some compilers (old pcc ones) like "void *a;", but a can't be used */	void *bar(a) void *a; { int *b = (int *) a; *b = 1; return a; }      ], , ksh_cv_c_void=yes, ksh_cv_c_void=no)])  if test $ksh_cv_c_void = yes; then    :  else    AC_DEFINE(void, char)  fi ])dnldnldnldnldnl Early MIPS compilers (used in Ultrix 4.2) don't likednl "int x; int *volatile a = &x; *a = 0;"AC_DEFUN(KSH_C_VOLATILE, [AC_CACHE_CHECK(if compiler understands volatile, ksh_cv_c_volatile,    [AC_TRY_COMPILE([int x, y, z;],      [volatile int a; int * volatile b = x ? &y : &z;      /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */      *b = 0;], ksh_cv_c_volatile=yes, ksh_cv_c_volatile=no)])  if test $ksh_cv_c_volatile = yes; then    :  else    AC_DEFINE(volatile, )  fi ])dnldnldnldnldnl Check if function prototypes work (including stdc vararg prototypes)AC_DEFUN(KSH_C_PROTOTYPES, [AC_CACHE_CHECK(if compiler understands prototypes, ksh_cv_c_prototypes,    [AC_TRY_COMPILE([#include <stdarg.h>void foo(char *fmt, ...);int bar(int a, char b, char *c);int bar(a, b, c) int a; char b; char *c;{ foo("%d%c%s\n", a, b, c); return a + b + *c; }void foo(char *fmt, ...) { va_list a; va_start(a, fmt); va_end(a); }      ], , ksh_cv_c_prototypes=yes, ksh_cv_c_prototypes=no)])  if test $ksh_cv_c_prototypes = yes; then    AC_DEFINE(HAVE_PROTOTYPES)  fi ])dnldnldnldnldnl Check if C compiler understands gcc's __attribute((...)).dnl checks for noreturn, const, and format(type,fmt,param), also checksdnl that the compiler doesn't die when it sees an unknown attribute (thisdnl isn't perfect since gcc doesn't parse unknown attributes with parameters)AC_DEFUN(KSH_C_FUNC_ATTR, [AC_CACHE_CHECK(if C compiler groks __attribute__(( .. )), ksh_cv_c_func_attr,    [AC_TRY_COMPILE([#include <stdarg.h>void test_fmt(char *fmt, ...) __attribute__((format(printf, 1, 2)));void test_fmt(char *fmt, ...) { return; }int test_cnst(int) __attribute__((const));int test_cnst(int x) { return x + 1; }void test_nr() __attribute__((noreturn));void test_nr() { exit(1); }void test_uk() __attribute__((blah));void test_uk() { return; }      ], [test_nr("%d", 10); test_cnst(2); test_uk(); test_nr(); ],      ksh_cv_c_func_attr=yes, ksh_cv_c_func_attr=no)])  if test $ksh_cv_c_func_attr = yes; then    AC_DEFINE(HAVE_GCC_FUNC_ATTR)  fi ])dnldnldnldnldnl Check if dup2() does not clear the close on exec flagAC_DEFUN(KSH_DUP2_CLEXEC_CHECK, [AC_CACHE_CHECK([if dup2() works (ie, resets the close-on-exec flag)], ksh_cv_dup2_clexec_ok,    [AC_TRY_RUN([#include <sys/types.h>#ifdef HAVE_FCNTL_H# include <fcntl.h>#endif /* HAVE_FCNTL_H */#ifndef F_GETFD# define F_GETFD 1#endif#ifndef F_SETFD# define F_SETFD 2#endif#ifndef O_RDONLY# define O_RDONLY 0#endif/* On some systems (Ultrix 2.1..4.2 (and more?)), dup2() does not clear   the close on exec flag */main(){  int fd1, fd2;  fd1 = open("/dev/null", O_RDONLY);  if (fcntl(fd1, F_SETFD, 1) < 0)    exit(1);  fd2 = dup2(fd1, fd1 + 1);  if (fd2 < 0)    exit(2);  exit(fcntl(fd2, F_GETFD, 0) == 0 ? 0 : 3);}     ], ksh_cv_dup2_clexec_ok=yes, ksh_cv_dup2_clexec_ok=no,     AC_MSG_WARN(cannot test if dup2 is broken when cross compiling - assuming it is)     ksh_cv_dup2_clexec_ok=no)])  if test $ksh_cv_dup2_clexec_ok = no; then    AC_DEFINE(DUP2_BROKEN)  fi ])dnldnldnldnldnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)AC_DEFUN(KSH_SIGNAL_CHECK, [AC_CACHE_CHECK(flavour of signal routines, ksh_cv_signal_check,    [AC_TRY_LINK([#include <signal.h>], [	sigset_t ss;	struct sigaction sa;	sigemptyset(&ss); sigsuspend(&ss);	sigaction(SIGINT, &sa, (struct sigaction *) 0);	sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);      ], ksh_cv_signal_check=posix,      AC_TRY_LINK([#include <signal.h>], [	  int mask = sigmask(SIGINT);	  sigsetmask(mask); sigblock(mask); sigpause(mask);	], ksh_cv_signal_check=bsd42,        AC_TRY_LINK([#include <signal.h>			RETSIGTYPE foo() { }],	  [	    int mask = sigmask(SIGINT);	    sigset(SIGINT, foo); sigrelse(SIGINT);	    sighold(SIGINT); sigpause(SIGINT);	  ], ksh_cv_signal_check=bsd41, ksh_cv_signal_check=v7)))])  if test $ksh_cv_signal_check = posix; then

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -