📄 conf.sh
字号:
#!/bin/sh# Output RCS compile-time configuration.Id='$Id: conf.sh,v 5.14 1991/11/20 18:21:10 eggert Exp $'# Copyright 1990, 1991 by Paul Eggert# Distributed under license by the Free Software Foundation, Inc.# This file is part of RCS.## RCS 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.## RCS 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 RCS; see the file COPYING. If not, write to# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.## Report problems and direct all questions to:## rcs-bugs@cs.purdue.edu# Standard output should already be directed to "a.h";# later parts of this procedure need it.# Standard error can be ignored if a.h is OK,# and can be inspected for clues otherwise.# The Makefile overrides the following defaults.: ${CC=cc}: ${CFLAGS=-O}: ${COMPAT2=0}: ${DIFF3=${RCSPREFIX}diff3}: ${DIFF3_BIN=1}: ${DIFF=${RCSPREFIX}diff}: ${DIFF_FLAGS=-an}: ${DIFF_L=1}: ${DIFF_SUCCESS=0} ${DIFF_FAILURE=1} ${DIFF_TROUBLE=2}: ${ED=/bin/ed}: ${RCSPREFIX=/usr/local/bin/}: ${SENDMAIL='"/usr/lib/sendmail"'}# : ${LDFLAGS=} ${LDLIBS=} tickles old shell bugC="$CC $CFLAGS"CL="$CC $CFLAGS $LDFLAGS"L=$LDLIBSRM='rm -f a.out'cat <<EOF/* RCS compile-time configuration */ /* $Id *//* * This file is generated automatically. * If you edit it by hand your changes may be lost. * Instead, please try to fix conf.sh, * and send your fixes to rcs-bugs@cs.purdue.edu. */EOF: exitmaincat >a.c <<EOF#include "a.h"int main(argc,argv) int argc; char **argv; { return argc-1; }EOF$RM && $CL a.c $L >&2 || exite='exit(n), 3 /* lint fodder */'if ./a.out -then :elif ./a.outthen e=nfiecho "#define exitmain(n) return $e /* how to exit from main() */": _POSIX_SOURCEcat >a.c <<'EOF'#include "a.h"#include <stdio.h>int main() { exitmain(fileno(stdout) < 0); }EOFa='/* ' z='*/ '$RM || exitif ($CL a.c $L && ./a.out) >&2then :elif $RM || exit; ($CL -D_POSIX_SOURCE a.c $L && ./a.out) >&2then a= z=ficat <<EOF$a#define _POSIX_SOURCE $z/* Define this if Posix + strict Standard C. */#include <errno.h>#include <stdio.h>#include <time.h>EOFcat <<'EOF'/* Comment out #include lines below that do not work. */EOF# Run `$CS a.c $LS' instead of `$CL a.c $L' for compile-time checking only.# This speeds up the configuration process.if $C -S a.c >&2then CS="$C -S" LS= # Generate assembly language output.elif $C -c a.c >&2then CS="$C -c" LS= # Generate object code.else CS=$CL LS=$L # Generate an executable.fi# standard include files# sys/types.h and sys/stat.h must come first because others depend on them.has_signal=1for h in \ sys/types sys/stat \ dirent fcntl limits pwd signal stdlib string sys/mman sys/wait unistd utime vforkdo i="#include <$h.h>" : $i cat >a.c <<EOF#include "a.h"$iint main(){ exitmain(0); }EOF $RM || exit ($CL a.c $L && ./a.out) >&2 || { case $h in string) i='#include <strings.h>';; *) i="/* $i */" esac case $h in signal) has_signal=0 esac } echo "$i"donecat <<'EOF'/* Define the following symbols to be 1 or 0. */EOF# has_sys_*_hfor H in dir paramdo : has_sys_${H}_h cat >a.c <<EOF#include "a.h"#include <sys/$H.h>int main() { exitmain(0); }EOF $RM || exit if ($CL a.c $L && ./a.out) >&2 then h=1 else h=0 fi echo "#define has_sys_${H}_h $h /* Does #include <sys/$H.h> work? */"done# We must do NAME_MAX and has_readlink next, because they might generate# #include directives that affect later definitions.: NAME_MAXcat >a.c <<'EOF'#include "a.h"char b[NAME_MAX + 2];main(){#if !defined(NAME_MAX) exitmain(1);#else int i; b[0] = 'a'; b[1] = '.'; for (i = 2; i < NAME_MAX; i++) b[i] = 'a'; b[i] = 'b'; exitmain(creat(b, 0) < 0);#endif}EOF$RM a.*ab || exitif $CL a.c $L >&2 && ./a.out && test -f a.*abthen a= z=else a='/* ' z='*/ 'firm -f a.*ab || exit: has_readlinkcat >a.c <<'EOF'#include "a.h"char b[7];int main(){ exitmain(readlink("a.sym2",b,7) != 6 || strcmp(b, "a.sym1") != 0);}EOF$RM a.sym* || exitif (ln -s a.sym1 a.sym2 && $CL a.c $L && ./a.out) >&2then h=1else h=0ficat <<EOF#define has_readlink $h /* Does readlink() work? */$a#undef NAME_MAX $z/* Uncomment this if NAME_MAX is broken. */#if !defined(NAME_MAX) && !defined(_POSIX_NAME_MAX)# if has_sys_dir_h# include <sys/dir.h># endif# ifndef NAME_MAX# ifndef MAXNAMLEN# define MAXNAMLEN 14# endif# define NAME_MAX MAXNAMLEN# endif#endif#if !defined(PATH_MAX) && !defined(_POSIX_PATH_MAX)# if has_sys_param_h# include <sys/param.h># define included_sys_param_h 1# endif# ifndef PATH_MAX# ifndef MAXPATHLEN# define MAXPATHLEN 1024# endif# define PATH_MAX (MAXPATHLEN-1)# endif#endif#if has_readlink && !defined(MAXSYMLINKS)# if has_sys_param_h && !included_sys_param_h# include <sys/param.h># endif# ifndef MAXSYMLINKS# define MAXSYMLINKS 20 /* BSD; not standard yet */# endif#endifEOFcat <<'EOF'/* Comment out the keyword definitions below if the keywords work. */EOF: const, volatilefor i in const volatiledo cat >a.c <<EOF# include "a.h" enum Boolean { false, true }; static enum Boolean $i zero; static enum Boolean $i * $i azero = &zero; static enum Boolean $i * $i * $i aazero = &azero; int main() { exitmain(!!**aazero); }EOF a= z= if $CS a.c $LS >&2 then cat >a.c <<EOF typedef unsigned char $i *Iptr_type; struct { Iptr_type lim; } s, *f = &s; int main() { Iptr_type lim; lim = f->lim; return !!lim; }EOF if $CS a.c $LS >&2 then a='/* ' z=' */' fi fi echo "$a#define $i$z"done# *_tcat <<'EOF'/* Comment out the typedefs below if the types are already declared. *//* Fix any uncommented typedefs that are wrong. */EOFcat >a.c <<'EOF'#include "a.h"t x;int main() { exitmain(0); }EOFfor t in mode_t pid_t sig_atomic_t size_t ssize_t time_t uid_tdo : $t case $t in size_t) i=unsigned;; time_t) i=long;; *) i=int;; esac if $CS -Dt=$t a.c $LS >&2 then a='/* ' z=' */' else a= z= fi echo "${a}typedef $i $t;$z"done: has_prototypes, has_stdarg, has_varargs, va_start_argscat >a.ha <<'EOF'#if has_prototypes# define P(params) params#else# define P(params) ()#endif#if has_stdarg# include <stdarg.h>#else# if has_varargs# include <varargs.h># else typedef char *va_list;# define va_dcl int va_alist;# define va_start(ap) ((ap) = (va_list)&va_alist)# define va_arg(ap,t) (((t*) ((ap)+=sizeof(t))) [-1])# define va_end(ap)# endif#endif#if va_start_args == 2# define vararg_start va_start#else# define vararg_start(ap,p) va_start(ap)#endifEOFcat >a.c <<'EOF'#include "a.h"#include "a.ha"#if has_prototypeschar *f(char **p, ...)#elsechar *f(p, va_alist) char **p; va_dcl#endif{ char *s; va_list v; vararg_start(v,p); s = p[va_arg(v,int)]; va_end(v); return s;}int main P((int, char**));int main(argc, argv) int argc; char **argv; { exitmain(f(argv,0) != argv[0] || f(argv,1) != argv[1]);}EOFfor has_prototypes in 1 0do for has_stdarg in 1 v 0 do case $has_stdarg in v) has_varargs=1 has_stdarg=0;; *) has_varargs=0 esac case $has_stdarg in 0) as='1 2';; 1) as='2 1' esac for va_start_args in $as do $RM || exit $CL \ -Dhas_prototypes=$has_prototypes \ -Dhas_stdarg=$has_stdarg \ -Dhas_varargs=$has_varargs \ -Dva_start_args=$va_start_args \ a.c $L >&2 && ./a.out && break done && break done && breakdone || { echo >&2 "cannot deduce has_prototypes, has_stdarg, va_start_args" exit 1}cat - a.ha <<EOF/* Define the following symbols to be 1 or 0. */#define has_prototypes $has_prototypes /* Do function prototypes work? */#define has_stdarg $has_stdarg /* Does <stdarg.h> work? */#define has_varargs $has_varargs /* Does <varargs.h> work? */#define va_start_args $va_start_args /* How many args does va_start() take? */EOF: text_equals_binary_stdio, FOPEN_...cat >a.c <<'EOF'#include "a.h" intcopyto(filename, mode) char const *filename, *mode;{ int c; FILE *f, *g; if (!(f = fopen("a.out", "rb")) || !(g = fopen(filename, mode))) return 1; while (c=getc(f), !feof(f)) if (ferror(f) || putc(c,g)<0 && ferror(g)) return 1; return fclose(f)!=0 || fclose(g)!=0;}int main() { exitmain(copyto("a.d", "w+b") || copyto("a.e", "w+")); }EOFe=1$RM a.d a.e || exit$CL a.c $L >&2 && ./a.out && cmp a.out a.d && { cmp a.out a.e || e=0}cat <<EOF#define text_equals_binary_stdio $e /* Does stdio treat text like binary? */#define text_work_stdio 0 /* Text i/o for working file, binary for RCS file? */#if text_equals_binary_stdio /* Text and binary i/o behave the same, or binary i/o does not work. */# define FOPEN_R "r"# define FOPEN_W "w"# define FOPEN_WPLUS "w+"#else /* Text and binary i/o behave differently. */ /* This is incompatible with Posix and Unix. */# define FOPEN_R "rb"# define FOPEN_W "wb"# define FOPEN_WPLUS "w+b"#endif#if text_work_stdio# define FOPEN_R_WORK "r"# define FOPEN_W_WORK "w"# define FOPEN_WPLUS_WORK "w+"#else# define FOPEN_R_WORK FOPEN_R# define FOPEN_W_WORK FOPEN_W# define FOPEN_WPLUS_WORK FOPEN_WPLUS#endif/* Define or comment out the following symbols as needed. */EOF: bad_fopen_wpluscat >a.c <<'EOF'#include "a.h"int main() { exitmain(!fopen("a.d",FOPEN_WPLUS)); }EOF$RM || exitif echo nonempty >a.d && $CL a.c $L >&2 && ./a.out && test ! -s a.dthen b=0else b=1fiecho "#define bad_fopen_wplus $b /* Does fopen(f,FOPEN_WPLUS) fail to truncate f? */": getlogin_is_secureecho "#define getlogin_is_secure 0 /* Is getlogin() secure? Usually it's not. */": has_direntcat >a.c <<'EOF'#include "a.h"int main() { DIR *d = opendir("."); struct dirent *e; while ((e = readdir(d))) if (strcmp(e->d_name, "a.c") == 0 && closedir(d) == 0) exitmain(0); exitmain(1);}EOF$RM || exitif $CL a.c $L >&2 && ./a.outthen h=1else h=0fiecho "#define has_dirent $h /* Do opendir(), readdir(), closedir() work? */": has_fchmodcat >a.c <<'EOF'#include "a.h"int main() { exitmain(fchmod(fileno(stdin),0) != 0); }EOF$RM || exitif $CL a.c $L >&2 && ./a.out <a.c && test ! -r a.cthen h=1else h=0fiecho "#define has_fchmod $h /* Does fchmod() work? */"rm -f a.c || exit: has_fputscat >a.c <<'EOF'#include "a.h"int main() { exitmain(fputs("Hello\"\nworld", stdout) != 12); }EOFHello='Hello"world'$RM || exitif $CL a.c $L >&2 && ./a.out >/dev/null && x=`./a.out` && test " $x" = " $Hello"then h=1else h=0fiecho "#define has_fputs $h /* Does fputs() work? */": has_ftruncatecat >a.c <<'EOF'#include "a.h"int main(argc, argv) int argc; char **argv; { int f = creat(argv[1], 0); if (f<0 || write(f,"abc",3)!=3 || ftruncate(f,(off_t)0)!=0 || close(f)!=0) exitmain(1); exitmain(0);}EOF$RM || exitif $CL a.c $L >&2then h=1 # Check out /tmp too; it's buggy on some hosts. for d in . /tmp do if test -d $d then f=$d/a.d rm -f $f || exit ./a.out $f && test ! -s $f && test -f $f || h=0 rm -f $f || exit fi doneelse h=0fiecho "#define has_ftruncate $h /* Does ftruncate() work? */": has_getuidcat >a.c <<'EOF'#include "a.h"#ifndef getuid uid_t getuid();#endifint main() { exitmain(getuid()!=getuid()); }EOF$RM || exitif ($CL a.c $L && ./a.out) >&2then has_getuid=1else has_getuid=0fiecho "#define has_getuid $has_getuid /* Does getuid() work? */": has_getpwuidcase $has_getuid in0) a='/* ' z='*/ ' h=?;;*) a= z= cat >a.c <<'EOF'#include "a.h"int main() { exitmain(!getpwuid(0)); }EOF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -