📄 aclocal.m4
字号:
AC_DEFINE(POSIX_SIGNALS) else AC_DEFINE(USE_FAKE_SIGACT) if test $ksh_cv_signal_check = bsd42; then AC_DEFINE(BSD42_SIGNALS) elif test $ksh_cv_signal_check = bsd41; then AC_DEFINE(BSD41_SIGNALS) AC_CACHE_CHECK(if signals interrupt read(), ksh_cv_signals_interrupt, [AC_TRY_RUN([#include <errno.h>#include <signal.h> extern int errno; int flag = 0; RETSIGTYPE catcher(int sig) { flag = 1; return RETSIGVAL; } int main() { int pid; int fdc[2]; /* child writes to parent */ int fdp[2]; /* parent writes to child */ char buf; int nread; if (pipe(fdc) < 0) exit(1); if (pipe(fdp) < 0) exit(2); if ((pid = fork()) < 0) exit(3); if (pid == 0) { close(fdc[0]); close(fdp[1]); if (read(fdp[0], &buf, 1) != 0) exit(10); sleep(1); /* let parent into read */ if (kill(getppid(), SIGALRM) < 0) exit(11); sleep(1); /* ensure parent gets to run */ write(fdc[1], "1", 1); close(fdc[1]); exit(0); } close(fdc[1]); close(fdp[0]); /* Use native routines for test as this is what the shell * will be using... */#ifdef POSIX_SIGNALS { struct sigaction sa, osa; sa.sa_handler = catcher; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGALRM, &sa, &osa); }#else /* POSIX_SIGNALS */# ifdef BSD42_SIGNALS { struct sigvec vec, ovec; vec.sv_handler = catcher; vec.sv_mask = 0; vec.sv_flags = 0;# ifdef SV_INTERRUPT vec.sv_flags |= SV_INTERRUPT;# endif /* SV_INTERRUPT */ sigvec(SIGALRM, &vec, &ovec); }# else /* BSD42_SIGNALS */# ifdef BSD41_SIGNALS sigset(SIGALRM, catcher);# else /* BSD41_SIGNALS */# ifdef V7_SIGNALS signal(SIGALRM, catcher);# else /* V7_SIGNALS */ what kind of signals do you have?# endif /* V7_SIGNALS */# endif /* BSD41_SIGNALS */# endif /* BSD42_SIGNALS */#endif /* POSIX_SIGNALS */ close(fdp[1]); /* start child */ nread = read(fdc[0], &buf, 1); if (nread == 0) exit(4); if (nread > 0) exit(5); if (errno != EINTR) exit(6); if (!flag) exit(7); exit(0); return 0; } ], ksh_cv_signals_interrupt=yes, ksh_cv_signals_interrupt=no, AC_MSG_ERROR(cannot determine if signals interrupt read() when cross compiling) )]) if test $ksh_cv_signals_interrupt = no ; then AC_DEFINE(SIGNALS_DONT_INTERRUPT) fi else AC_DEFINE(V7_SIGNALS) fi fi ])dnldnldnldnldnl What kind of process groups: POSIX, BSD, SYSV or nonednl BSD uses setpgrp(pid, pgrp), getpgrp(pid)dnl POSIX uses setpid(pid, pgrp), getpgrp(void)dnl SYSV uses setpgrp(void), getpgrp(void)dnl Checks for BSD first since the posix test may succeed on BSDish systemsdnl (depends on what random value gets passed to getpgrp()).AC_DEFUN(KSH_PGRP_CHECK, [AC_CACHE_CHECK(flavour of pgrp routines, ksh_cv_pgrp_check, [AC_TRY_RUN([/* Check for BSD process groups */#include <signal.h>#ifdef HAVE_UNISTD_H# include <unistd.h>#endif /* HAVE_UNISTD_H */ main() { int ecode = 0, child = fork(); if (child < 0) exit(1); if (child == 0) { signal(SIGTERM, SIG_DFL); /* just to make sure */ sleep(10); exit(9); } if (setpgrp(child, child) < 0) ecode = 2; else if (getpgrp(child) != child) ecode = 3; kill(child, SIGTERM); exit(ecode); } ], ksh_cv_pgrp_check=bsd, [AC_TRY_RUN([/* Check for POSIX process groups */#ifdef HAVE_UNISTD_H# include <unistd.h>#endif /* HAVE_UNISTD_H */ main() { int child; int n, p1[2], p2[2]; char buf[1]; if (pipe(p1) < 0 || pipe(p2) < 0) exit(1); if ((child = fork()) < 0) exit(2); if (child == 0) { n = read(p1[0], buf, sizeof(buf)); /* wait for parent to setpgid */ buf[0] = (n != 1 ? 10 : (getpgrp() != getpid() ? 11 : 0)); if (write(p2[1], buf, sizeof(buf)) != 1) exit(12); exit(0); } if (setpgid(child, child) < 0) exit(3); if (write(p1[1], buf, 1) != 1) exit(4); if (read(p2[0], buf, 1) != 1) exit(5); exit((int) buf[0]); } ], ksh_cv_pgrp_check=posix, [AC_TRY_RUN([/* Check for SYSV process groups */#ifdef HAVE_UNISTD_H# include <unistd.h>#endif /* HAVE_UNISTD_H */ main() { int child; int n, p[2]; char buf[1]; if (pipe(p) < 0) exit(1); if ((child = fork()) < 0) exit(2); if (child == 0) { buf[0] = (setpgrp() < 0 ? 10 : (getpgrp() != getpid() ? 11 : 0)); if (write(p[1], buf, sizeof(buf)) != 1) exit(11); exit(0); } if (read(p[0], buf, 1) != 1) exit(3); exit((int) buf[0]); } ], ksh_cv_pgrp_check=sysv, ksh_cv_pgrp_check=none, AC_MSG_ERROR(cannot taste pgrp routines when cross compiling))], AC_MSG_ERROR(cannot taste pgrp routines when cross compiling))], AC_MSG_ERROR(cannot taste pgrp routines when cross compiling))]) if test $ksh_cv_pgrp_check = bsd; then AC_DEFINE(BSD_PGRP) elif test $ksh_cv_pgrp_check = posix; then AC_DEFINE(POSIX_PGRP) elif test $ksh_cv_pgrp_check = sysv; then AC_DEFINE(SYSV_PGRP) else AC_DEFINE(NO_PGRP) fi ])dnldnldnldnldnl Check if the pgrp of setpgrp() can't be the pid of a zombie process.dnl On some systems, the kernel doesn't count zombie processes when checkingdnl if a process group is valid, which can cause problems in creating thednl pipeline "cmd1 | cmd2": if cmd1 can die (and go into the zombie state)dnl before cmd2 is started, the kernel doesn't allow the setpgrp() for cmd2dnl to succeed. This test defines NEED_PGRP_SYNC if the kernel has this bug.dnl (pgrp_sync test doesn't mean much if don't have bsd or posix pgrps)AC_DEFUN(KSH_PGRP_SYNC, [AC_REQUIRE([KSH_PGRP_CHECK])dnl if test $ksh_cv_pgrp_check = bsd || test $ksh_cv_pgrp_check = posix ; then AC_CACHE_CHECK(if process group synchronization is required, ksh_cv_need_pgrp_sync, [AC_TRY_RUN([ main() {#ifdef POSIX_PGRP# define getpgID() getpgrp()#else# define getpgID() getpgrp(0)# define setpgid(x,y) setpgrp(x,y)#endif int pid1, pid2, fds[2]; int status; char ok; switch (pid1 = fork()) { case -1: exit(1); case 0: setpgid(0, getpid()); exit(0); } setpgid(pid1, pid1); sleep(2); /* let first child die */ if (pipe(fds) < 0) exit(2); switch (pid2 = fork()) { case -1: exit(3); case 0: setpgid(0, pid1); ok = getpgID() == pid1; write(fds[1], &ok, 1); exit(0); } setpgid(pid2, pid1); close(fds[1]); if (read(fds[0], &ok, 1) != 1) exit(4); wait(&status); wait(&status); exit(ok ? 0 : 5); } ], ksh_cv_need_pgrp_sync=no, ksh_cv_need_pgrp_sync=yes, AC_MSG_WARN(cannot test if pgrp synchronization needed when cross compiling - assuming it is) ksh_cv_need_pgrp_sync=yes)]) if test $ksh_cv_need_pgrp_sync = yes; then AC_DEFINE(NEED_PGRP_SYNC) fi fi ])dnldnldnldnldnl Check to see if opendir will open non-directories (not a nice thing)AC_DEFUN(KSH_OPENDIR_CHECK, [AC_CACHE_CHECK(if opendir() fails to open non-directories, ksh_cv_opendir_ok, [AC_TRY_RUN([#include <stdio.h>#include <sys/types.h>#ifdef HAVE_UNISTD_H# include <unistd.h>#endif /* HAVE_UNISTD_H */#if defined(HAVE_DIRENT_H)# include <dirent.h>#else# define dirent direct# ifdef SYSNDIR# include <sys/ndir.h># endif /* SYSNDIR */# ifdef SYSDIR# include <sys/dir.h># endif /* SYSDIR */# ifdef NDIR# include <ndir.h># endif /* NDIR */#endif /* DIRENT */ main() { int i, ret = 0; FILE *fp; char *fname = "conftestod", buf[256]; for (i = 0; i < sizeof(buf); i++) /* memset(buf, 0, sizeof(buf)) */ buf[i] = 0; unlink(fname); /* paranoia */ i = ((fp = fopen(fname, "w")) == (FILE *) 0 && (ret = 1)) || (fwrite(buf, sizeof(buf), 1, fp) != 1 && (ret = 2)) || (fclose(fp) == EOF && (ret = 3)) || (opendir(fname) && (ret = 4)) || (opendir("/dev/null") && (ret = 5)); unlink(fname); exit(ret); } ], ksh_cv_opendir_ok=yes, ksh_cv_opendir_ok=no, AC_MSG_WARN(cannot test if opendir opens non-directories when cross compiling - assuming it does) ksh_cv_opendir_ok=no)]) if test $ksh_cv_opendir_ok = no; then AC_DEFINE(OPENDIR_DOES_NONDIR) fi ])dnldnldnldnldnl Like AC_HAVE_HEADER(unistd.h) but only defines HAVE_UNISTD_H ifdnl the header file is sane (MIPS RISC/os 5.0 (and later?) has a unistd.hdnl in the bsd43 environ that is incorrect - it defines POSIX_VERSION evendnl though its non-posix).AC_DEFUN(KSH_UNISTD_H, [AC_CACHE_CHECK(for sane unistd.h, ksh_cv_header_unistd, [AC_TRY_COMPILE([#include <unistd.h>#if defined(_POSIX_VERSION)# include <sys/types.h># include <dirent.h> /* _POSIX_VERSION => HAVE_DIRENT_H test not needed */#endif ], , ksh_cv_header_unistd=yes, ksh_cv_header_unistd=no)]) if test $ksh_cv_header_unistd = yes; then AC_DEFINE(HAVE_UNISTD_H) fi ])dnldnldnldnldnl Several OSes need to be detected and symbols defined so the shell candnl deal with them. This is a bit kludgy, but...dnl Currently tests for:dnl AIX, ISC (Interactive systems corp), MINIX, OS2 using EMX library,dnl SCO (santa cruz operation), NEXTdnl DO NOT USE with AC_AIX, AC_MINIX or AC_ISC_POSIX tests as these arednl incorperated in this test.AC_DEFUN(KSH_OS_TYPE, [AC_BEFORE([$0], [AC_TRY_COMPILE])dnl AC_BEFORE([$0], [AC_TRY_LINK])dnl AC_BEFORE([$0], [AC_TRY_RUN])dnl AC_CACHE_CHECK(if this is a problematic os, ksh_cv_os_type, [ ksh_cv_os_type=no # Some tests below add -C to CPPFLAGS saveCPPFLAGS="$CPPFLAGS" for i in AIX ISC MINIX SCO OS2_EMX TITANOS NEXT HPUX; do case $i in #(( AIX) AC_EGREP_CPP(yes, [#ifdef _AIXyes#endif ], ksh_cv_os_type=$i) ;; #( ISC) # Both native ISC cpp and gcc understand this (leave comments in) CPPFLAGS="$CPPFLAGS -C" #XXX grep part won't work if cross-compiling... AC_EGREP_CPP(INTERACTIVE Systems Corporation, [#include <unistd.h>], [if grep _POSIX_VERSION /usr/include/sys/unistd.h > /dev/null 2>&1; then ksh_cv_os_type="$i-posix" else ksh_cv_os_type=$i fi])dnl CPPFLAGS="$saveCPPFLAGS" ;; #( MINIX) AC_CHECK_HEADER(minix/config.h, ksh_cv_os_type=$i)dnl ;; #( SCO) # Both native SCO cpp and gcc understand this (leave comments in) CPPFLAGS="$CPPFLAGS -C" AC_EGREP_CPP(The Santa Cruz Operation, [#include <unistd.h>], ksh_cv_os_type=$i)dnl CPPFLAGS="$saveCPPFLAGS" ;; #( OS2_EMX) AC_EGREP_CPP(yes, [#ifdef __EMX__yes#endif ], ksh_cv_os_type=$i)dnl ;; #( TITANOS) AC_EGREP_CPP(YesTitan, [#if defined(titan) || defined(_titan) || defined(__titan)YesTitan#endif ], ksh_cv_os_type=$i)dnl ;; #( NEXT) # # NeXT 3.2 (other versions?) - cc -E doesn't work and /lib/cpp # doesn't define things that need defining, so tests that rely # on $CPP will break. # # Hmmm - can't safely use CPP to test for NeXT defines, so have # to use a program that won't compile on a NeXT and one that will # only compile on a NeXT... AC_TRY_COMPILE([], [ #if defined(__NeXT) || defined(NeXT) this is a NeXT box and the compile should fail #endif ], , AC_TRY_COMPILE([], [ #if !defined(__NeXT) && !defined(NeXT) this is NOT a NeXT box and the compile should fail #endif ], ksh_cv_os_type=$i))dnl ;; #( HPUX) AC_EGREP_CPP(yes, [#ifdef __hpuxyes#endif ], ksh_cv_os_type=$i) ;; #( esac #)) test $ksh_cv_os_type != no && break done ]) case $ksh_cv_os_type in #(( AIX) AC_DEFINE(_ALL_SOURCE)dnl ;; #( ISC) AC_DEFINE(OS_ISC)dnl ;; #( ISC-posix) AC_DEFINE(OS_ISC)dnl AC_DEFINE(_POSIX_SOURCE)dnl if test "$GCC" = yes; then CC="$CC -posix"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -