home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume35 / procmail / part11 < prev    next >
Encoding:
Text File  |  1993-02-04  |  26.5 KB  |  933 lines

  1. Newsgroups: comp.sources.misc
  2. From: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  3. Subject: v35i032:  procmail - mail processing package v2.80, Part11/11
  4. Message-ID: <1993Feb5.020759.17013@sparky.imd.sterling.com>
  5. X-Md4-Signature: 46185aa2e6d21084c5ee8a798a32a39f
  6. Date: Fri, 5 Feb 1993 02:07:59 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  10. Posting-number: Volume 35, Issue 32
  11. Archive-name: procmail/part11
  12. Environment: sendmail, smail, MMDF, mailsurr, UNIX, POSIX
  13. Supersedes: procmail: Volume 31, Issue 40-44
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 11 (of 11)."
  22. # Contents:  procmail280/src/autoconf
  23. # Wrapped by berg@hathi on Thu Feb  4 15:28:01 1993
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'procmail280/src/autoconf' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'procmail280/src/autoconf'\"
  27. else
  28. echo shar: Extracting \"'procmail280/src/autoconf'\" \(23957 characters\)
  29. sed "s/^X//" >'procmail280/src/autoconf' <<'END_OF_FILE'
  30. X#! /bin/sh
  31. X:
  32. X#$Id: autoconf,v 1.32 1993/02/04 12:44:45 berg Exp $
  33. X
  34. X# All possible entries in autoconf.h:
  35. X
  36. X#    #define UNISTD_H_MISSING
  37. X#    #define STDDEF_H_MISSING
  38. X#    #define STDLIB_H_MISSING
  39. X#    #define DIRENT_H_MISSING
  40. X#    #define SYS_DIRENT_H_MISSING
  41. X#    #define NDIR_H_MISSING
  42. X#    #define SYS_NDIR_H_MISSING
  43. X#    #define SYS_DIR_H_MISSING
  44. X#    #define SYS_WAIT_H_MISSING
  45. X#    #define SYS_UTSNAME_H_MISSING
  46. X#    #define STRING_H_MISSING
  47. X#    #define SYSEXITS_H_MISSING
  48. X#Ok    #define SYS_FILE_H_MISSING
  49. X#    #define const
  50. X#    #define volatile
  51. X#    #define P(args) ()
  52. X#    #define void char
  53. X#    typedef int mode_t;
  54. X#    typedef int pid_t;
  55. X#    typedef int uid_t;
  56. X#    typedef int gid_t;
  57. X#    typedef unsigned size_t;
  58. X#    typedef long time_t;
  59. X#    #define NOmemmove
  60. X#    #define NObcopy
  61. X#    #define NOstrcspn
  62. X#    #define NOstrpbrk
  63. X#    #define NOopendir
  64. X#    #define NOrename
  65. X#    #define NOuname
  66. X#    #define NOstrstr
  67. X#    #define NOstrtol
  68. X#    #define strchr(s,c) index(s,c)
  69. X#    #define initgroups(n,g)
  70. X#Ok    #define endpwent()
  71. X#Ok    #define endgrent()
  72. X#Ok    #define endhostent()
  73. X#Ok    #define endservent()
  74. X#Ok    #define endprotoent()
  75. X#    #define h_0addr_list h_addr
  76. X#Ok    #define NO_COMSAT
  77. X#    #define _GUID_T
  78. X#Ok    #define UDP_protocolno 17
  79. X#Ok    #define BIFF_serviceport "512"
  80. X#Ok    #define IP_localhost {127,0,0,1,}
  81. X#    #define WMACROS_NON_POSIX
  82. X#    #define oBRAIN_DAMAGE
  83. X#Ok    #define LD_ENV_FIX
  84. X#Ok    #define GOT_bin_test
  85. X#Ok    #define SMALLHEAP
  86. X#    #define NOfcntl_lock
  87. X#Ok    #define USElockf
  88. X#Ok    #define USEflock
  89. X#Ok    #define SYSTEM_MAILBOX "/usr/spool/mail/$LOGNAME"
  90. X#Ok    #define SENDMAIL "/usr/lib/sendmail"
  91. X#Ok    #define CF_no_procmail_yet
  92. X
  93. X# A conforming ANSI compiler and POSIX library should not have any defines not
  94. X# marked as "Ok" in the autoconf.h file.
  95. X# Anything else indicates failure of your system to comply with either
  96. X# the ANSI or POSIX standards (but procmail should be installable anyway).
  97. X
  98. XSHELL=$1
  99. XPATH=.:$PATH
  100. Xshift; RM="$1"
  101. Xshift; MV="$1"
  102. Xshift; USRINC=$1
  103. Xshift; DEVNULL=$1
  104. Xshift; FGREP="$1"
  105. Xshift; MAKE="$1"
  106. Xshift; O=$1
  107. Xshift; ACONF=$1
  108. X
  109. Xtest 1 != $# &&
  110. X echo "Don't start this script directly, use \`make ../autoconf.h'" && exit 1
  111. X
  112. Xexport SHELL PATH
  113. Xif test -f $ACONF
  114. Xthen
  115. X trap "exit 1" 1 2 3 15
  116. Xelse
  117. X trap "$RM $ACONF; exit 1" 1 2 3 15
  118. Xfi
  119. X
  120. Xif test ! -z "$LD_LIBRARY_PATH"
  121. Xthen
  122. X  echo '***************************** WARNING *********************************'
  123. X  echo '* You seem to have set the LD_LIBRARY_PATH variable, this might cause *'
  124. X  echo '* some trouble during the execution of this autoconf script.  If the  *'
  125. X  echo '* the make does not finish by itself, do a: "make clean",          *'
  126. X  echo '* clear LD_LIBRARY_PATH from the environment, and start over.          *'
  127. X  echo '***************************** WARNING *********************************'
  128. Xfi
  129. X
  130. Xecho hi | $FGREP hi >$DEVNULL
  131. Xt=$?
  132. Xecho ho | $FGREP hi >$DEVNULL
  133. Xf=$?
  134. Xif test 0 != $t -o 0 = $f
  135. Xthen
  136. X  echo "Your \"$FGREP\" program seems to be incapable of returning a proper"
  137. X  echo "exitvalue depending on the success of the search.  This script can"
  138. X  echo "not work without it."
  139. X  exit 2
  140. Xfi
  141. X
  142. Xnocore=yes
  143. Xtest -f core && nocore=no
  144. X
  145. Xcat >grepfor <<HERE
  146. X$FGREP -e "\$1" _autotst.rrr >$DEVNULL && echo "\$2" >>$ACONF
  147. XHERE
  148. Xchmod 0755 grepfor
  149. X
  150. Xcat >$ACONF <<HERE
  151. X/* This file was automagically generated by autoconf */
  152. X
  153. XHERE
  154. X
  155. Xecho 'Checking for POSIX and ANSI system include files'
  156. Xtest -f $USRINC/unistd.h || echo "#define UNISTD_H_MISSING" >>$ACONF
  157. Xtest -f $USRINC/stddef.h || echo "#define STDDEF_H_MISSING" >>$ACONF
  158. Xtest -f $USRINC/stdlib.h || echo "#define STDLIB_H_MISSING" >>$ACONF
  159. Xif test ! -f $USRINC/dirent.h
  160. Xthen echo "#define DIRENT_H_MISSING" >>$ACONF
  161. X  if test ! -f $USRINC/ndir.h
  162. X  then echo "#define NDIR_H_MISSING" >>$ACONF
  163. X     if test ! -f $USRINC/sys/ndir.h
  164. X     then echo "#define SYS_NDIR_H_MISSING" >>$ACONF
  165. X    if test ! -f $USRINC/sys/dir.h
  166. X    then echo "#define SYS_DIR_H_MISSING" >>$ACONF
  167. X       test -f $USRINC/sys/dirent.h ||
  168. X        echo "#define SYS_DIRENT_H_MISSING" >>$ACONF
  169. X    fi
  170. X     fi
  171. X  fi
  172. Xfi
  173. Xtest -f $USRINC/sys/wait.h || echo "#define SYS_WAIT_H_MISSING" >>$ACONF
  174. Xtest -f $USRINC/sys/utsname.h || echo "#define SYS_UTSNAME_H_MISSING" >>$ACONF
  175. Xtest -f $USRINC/string.h || echo "#define STRING_H_MISSING" >>$ACONF
  176. Xtest -f $USRINC/sysexits.h || echo "#define SYSEXITS_H_MISSING" >>$ACONF
  177. X
  178. Xecho >_locktst.h
  179. Xtest -f $USRINC/sys/locking.h ||
  180. X echo "#define SYS_LOCKING_H_MISSING" >>_locktst.h
  181. Xtest -f $USRINC/sys/file.h || echo "#define SYS_FILE_H_MISSING" >>_locktst.h
  182. X$FGREP setsid $USRINC/sys/unistd.h >$DEVNULL 2>&1 ||
  183. X echo "#define setsid()" >>_locktst.h
  184. X
  185. X$RM _autotst.$O _autotst
  186. X
  187. Xcat >_autotst.c <<HERE
  188. X#include "$ACONF"
  189. X#include <sys/types.h>
  190. X#ifndef UNISTD_H_MISSING
  191. X#include <unistd.h>
  192. X#endif
  193. X#include <fcntl.h>
  194. X#ifndef SYS_FILE_H_MISSING
  195. X#include <sys/file.h>
  196. X#endif
  197. Xmain(){
  198. X#ifdef F_SETLKW
  199. X fcntl(0,F_SETLKW,0);
  200. X#endif
  201. X#ifdef F_LOCK
  202. X  lockf(0,F_LOCK,0L);
  203. X#endif
  204. X#ifdef LOCK_EX
  205. X  flock(0,LOCK_EX);
  206. X#endif
  207. X return 0;}
  208. XHERE
  209. X
  210. Xecho 'Initiating fcntl()/kernel-locking-support tests'
  211. Xecho   '********************************************************************'
  212. Xecho   '* If your system has mounted a REMOTE filesystem (like per NFS),   *'
  213. Xecho   '* then it would be advisable to compile these sources from within  *'
  214. Xecho   '* that filesystem, otherwise the locking tests might produce false *'
  215. Xecho   '* results (locking capability is file-system dependent)           *'
  216. Xecho   '********************************************************************'
  217. Xif $MAKE _autotst.$O >$DEVNULL 2>&1
  218. Xthen
  219. X:
  220. Xelse
  221. X  $RM _autotst.$O
  222. X  echo 'Oops, your <sys/file.h> file seems to be incorrect.'
  223. X  echo 'Retrying without it.'
  224. X  echo "#define SYS_FILE_H_MISSING" >>$ACONF
  225. X  if $MAKE _autotst.$O >_autotst.rrr 2>&1
  226. X  then
  227. X  :
  228. X  else
  229. X     echo 2>&1 "Whoeaaa!  There's something fishy going on here."
  230. X     echo 2>&1 "You have a look and see if you detect anything uncanny:"
  231. X     echo 2>&1 "*******************************************************"
  232. X     cat 2>&1 _autotst.rrr
  233. X     echo 2>&1 "*******************************************************"
  234. X     echo 2>&1 "I suggest you take a look at the definition of CFLAGS* and CC"
  235. X     echo 2>&1 "in the Makefile before you try make again."
  236. X     kill -15 $$
  237. X  fi
  238. Xfi
  239. X$MAKE _autotst >_autotst.rrr 2>&1
  240. X$RM _autotst.$O _autotst
  241. X
  242. X$FGREP fcntl _autotst.rrr >$DEVNULL && echo "#undef F_SETLKW" >>_locktst.h
  243. X$FGREP lockf _autotst.rrr >$DEVNULL && echo "#undef F_LOCK" >>_locktst.h
  244. X$FGREP flock _autotst.rrr >$DEVNULL && cat >>_locktst.h <<HERE
  245. X#ifdef LOCK_EX
  246. X#undef LOCK_EX
  247. X#endif
  248. X#ifndef SYS_FILE_H_MISSING
  249. X#define SYS_FILE_H_MISSING
  250. X#endif
  251. XHERE
  252. X
  253. Xcat >_autotst.c <<HERE
  254. X#include "$ACONF"
  255. X#include "../config.h"
  256. X#include <sys/types.h>
  257. X#ifndef UNISTD_H_MISSING
  258. X#include <unistd.h>        /* getppid() */
  259. X#endif
  260. X#include <stdio.h>
  261. X#include <time.h>
  262. X#include <fcntl.h>
  263. X#include <signal.h>        /* SIGKILL */
  264. X#ifndef tell
  265. X#define tell(fd)    lseek(fd,0L,SEEK_CUR)
  266. X#endif
  267. X#define EX_OK    0
  268. X#include "_locktst.h"
  269. X#ifndef SYS_FILE_H_MISSING
  270. X#include <sys/file.h>
  271. X#endif
  272. X#ifndef SEEK_SET
  273. X#define SEEK_SET    0
  274. X#define SEEK_CUR    1
  275. X#define SEEK_END    2
  276. X#endif
  277. X
  278. X#define MIN_locks    128      /* minimum of consecutive successful locks */
  279. X#define SLEEP_loop    64              /* iterations in the busy loop */
  280. X#define SLEEP_delay    0          /* sleep() time per busy iteration */
  281. X#define TIME_OUT_SEC    16             /* initial timeout per lock */
  282. X#define NR_of_forks    8             /* concurrent test-programs */
  283. X#define NR_of_lockfiles 2          /* lockfiles used in testing (<=4) */
  284. X#define GROW        3                /* when timing got worse */
  285. X#define DECAY        7/8               /* when timing got better */
  286. X#define GOBBLE        256             /* for the SunOS crash test */
  287. X
  288. X#define SHIFT_childno    3
  289. X#define MASK_fileno    ((1<<SHIFT_childno)-1)
  290. X#define MASK_childno    (~MASK_fileno)
  291. X
  292. X#ifdef NO_fcntl_LOCK
  293. X#undef F_SETLKW
  294. X#endif
  295. X#ifdef NO_lockf_LOCK
  296. X#undef F_LOCK
  297. X#endif
  298. X#ifdef NO_flock_LOCK
  299. X#undef LOCK_EX
  300. X#endif
  301. X
  302. X#define FIRST_lock    0x04        /* testing is in order of importance */
  303. X#define MSK_fcntl    0x04           /* don't change this order unless you */
  304. X#define MSK_lockf    0x02           /* change locking.c as well, fdlock() */
  305. X#define MSK_flock    0x01
  306. X
  307. Xint dolock,child[NR_of_forks],timeout;
  308. X
  309. Xvoid stimeout()
  310. X{ timeout=1;killchildren();
  311. X}
  312. X
  313. Xstatic unsigned long seed;
  314. X
  315. Xunsigned psrand()
  316. X{ return(unsigned)(seed*=69069L)>>8;
  317. X}
  318. X
  319. Xmain()
  320. X{ int goodlock,testlock,i,pip[2];unsigned otimet,dtimet;
  321. X  static char filename[]="_locktst.l0";
  322. X  close(0);goodlock=0;testlock=FIRST_lock;
  323. X  if(fork())                 /* try to ditch the controlling tty */
  324. X     return EX_OK;    /* mainly to prevent rather messy kernel-diagnostics */
  325. X  setsid();                       /* from appearing on your tty */
  326. X  do
  327. X   { otimet=time((char*)0);signal(SIGTERM,SIG_DFL);dolock=goodlock|testlock;
  328. X     if(fork())          /* discard the old body, let "init" adopt our children */
  329. X      { close(1);close(2);i=NR_of_lockfiles;
  330. X    do                   /* prime the lock, see if it vanishes */
  331. X     { filename[sizeof filename-2]='0'+--i;
  332. X       lseek(goodlock=open(filename,O_WRONLY),0L,SEEK_END);
  333. X       fdlock(goodlock);
  334. X     }
  335. X    while(i);
  336. X    for(;;)                    /* synchronising "busy"-wait */
  337. X       sleep(TIME_OUT_SEC);           /* until the games can be started */
  338. X      }
  339. X     sleep(1);pipe(pip);i=NR_of_forks;*child=0;
  340. X     fprintf(stderr,"\nStarting test %x\n",dolock);
  341. X     while((child[--i]=fork())&&i);               /* divide and conquer */
  342. X     if(!*child)
  343. X      { unsigned char lockflag;int fd,childno=i<<SHIFT_childno;
  344. X    close(pip[0]);close(1);seed=time((char*)0)+getpid()|1;
  345. X    for(;;)                           /* and lock away! */
  346. X     { filename[sizeof filename-2]='0'+(i=psrand()%NR_of_lockfiles);
  347. X       lockflag=childno|i<<1|1;
  348. X       lseek(fd=open(filename,O_WRONLY),0L,SEEK_END);
  349. X       if(sfdlock(fd))
  350. X          lockflag&=~1,fprintf(stderr,"XX%02x",lockflag);
  351. X       write(pip[1],&lockflag,1);
  352. X       fprintf(stderr,"%2x%02x",i,childno>>SHIFT_childno);
  353. X       lseek(fd,0L,SEEK_END);write(fd,&lockflag,1);
  354. X       for(i=SLEEP_loop;i;i--,time((char*)0),sleep(SLEEP_delay));
  355. X       lockflag&=~1;write(pip[1],&lockflag,1);
  356. X       if(fdunlock()||close(fd))
  357. X        { write(pip[1],&lockflag,1);fprintf(stderr,"XX%02x",lockflag);
  358. X          return 1;
  359. X        }
  360. X     }
  361. X      }
  362. X     ;{ unsigned char lckdfil[NR_of_lockfiles],curflag;
  363. X    int j,countlocks=MIN_locks;           /* give all children a chance */
  364. X    for(j=NR_of_lockfiles;lckdfil[--j]=0,j;);
  365. X    close(pip[1]);timeout=0;sleep(1);kill(getppid(),SIGKILL);
  366. X    signal(SIGALRM,(void(*)())stimeout);
  367. X    dtimet=(((unsigned)time((char*)0)-otimet)*GROW)+TIME_OUT_SEC;
  368. X    do
  369. X     { unlink("_locktst.alive");alarm(dtimet+2);         /* watchdog */
  370. X       dtimet=(otimet=time((char*)0)-otimet)>dtimet?
  371. X        otimet*GROW:otimet+(dtimet-otimet)*DECAY+1;       /* load dependent */
  372. X       otimet=time((char*)0);
  373. X     }
  374. X    while(1==read(pip[0],&curflag,1)&&
  375. X     (j=lckdfil[i=(curflag&MASK_fileno)>>1],!timeout)&&
  376. X     ((j^(lckdfil[i]=curflag))==1||!(j&1)&&curflag&1)&&--countlocks);
  377. X    alarm(0);killchildren();close(pip[0]);
  378. X#ifdef FAIR_LOCK_CHECK
  379. X    j=NR_of_lockfiles;
  380. X    do
  381. X       if(!lckdfil[--j])                /* was the locking fair? */
  382. X          countlocks+=MIN_locks;                     /* nope */
  383. X    while(j);
  384. X#endif
  385. X    fprintf(stdout,
  386. X     "/*locktype: %x, countlocks: %x, timeout %x, watchdog %x*/\n",dolock,
  387. X     countlocks,timeout,dtimet);fflush(stdout);
  388. X    if(!countlocks)                /* Hurray!    Locking was flawless */
  389. X       goodlock=dolock;              /* make a mark on our colt */
  390. X      }
  391. X   }
  392. X  while(testlock>>=1);
  393. X  if(!(goodlock&MSK_fcntl))                  /* report our findings */
  394. X     puts("#define NOfcntl_lock");
  395. X  if(goodlock&MSK_lockf)
  396. X     puts("#define USElockf");
  397. X  if(goodlock&MSK_flock)
  398. X   { puts("#define USEflock");
  399. X#ifdef SYS_FILE_H_MISSING
  400. X     puts("#define SYS_FILE_H_MISSING");
  401. X#endif
  402. X   }
  403. X  puts("Kernel-locking tests completed.");
  404. X  return EX_OK;
  405. X}
  406. X
  407. Xkillchildren()
  408. X{ int i;
  409. X  i=NR_of_forks;
  410. X  do
  411. X     if(child[--i]>0)
  412. X    kill(child[i],SIGTERM),child[i]=0;
  413. X  while(i);
  414. X}
  415. X
  416. Xsfdlock(fd)
  417. X{ int i;unsigned gobble[GOBBLE>>2];
  418. X  for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0);         /* SunOS crash test */
  419. X  return fdlock(fd);
  420. X}
  421. X
  422. Xstatic oldfdlock;
  423. X#ifdef F_SETLKW
  424. Xstatic struct flock flck;        /* why can't it be a local variable? */
  425. X#endif
  426. X#ifdef F_LOCK
  427. Xstatic long oldlockoffset;
  428. X#endif
  429. X
  430. Xfdlock(fd)
  431. X{ int i;unsigned gobble[GOBBLE>>2];
  432. X  for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0);         /* SunOS crash test */
  433. X  oldfdlock=fd;fd=0;
  434. X  if(MSK_fcntl&dolock)
  435. X#ifdef F_SETLKW
  436. X   { flck.l_type=F_WRLCK;flck.l_whence=SEEK_SET;flck.l_len=0;
  437. X     flck.l_start=tell(oldfdlock);fd|=fcntl(oldfdlock,F_SETLKW,&flck);
  438. X   }
  439. X#else
  440. X     fd=1;
  441. X#endif
  442. X  if(MSK_lockf&dolock)
  443. X#ifdef F_LOCK
  444. X     oldlockoffset=tell(oldfdlock),fd|=lockf(oldfdlock,F_LOCK,0L);
  445. X#else
  446. X     fd=1;
  447. X#endif
  448. X  if(MSK_flock&dolock)
  449. X#ifdef LOCK_EX
  450. X     fd|=flock(oldfdlock,LOCK_EX);
  451. X#else
  452. X     fd=1;
  453. X#endif
  454. X  return fd;
  455. X}
  456. X
  457. Xfdunlock()
  458. X{ int i;unsigned gobble[GOBBLE];
  459. X  for(i=GOBBLE;i;gobble[--i]=~(unsigned)0);         /* SunOS crash test */
  460. X  if(MSK_flock&dolock)
  461. X#ifdef LOCK_EX
  462. X     i|=flock(oldfdlock,LOCK_UN);
  463. X#else
  464. X     i=1;
  465. X#endif
  466. X  if(MSK_lockf&dolock)
  467. X#ifdef F_LOCK
  468. X   { lseek(oldfdlock,oldlockoffset,SEEK_SET);i|=lockf(oldfdlock,F_LOCK,2L);
  469. X     i|=lockf(oldfdlock,F_ULOCK,0L);
  470. X   }
  471. X#else
  472. X     i=1;
  473. X#endif
  474. X  if(MSK_fcntl&dolock)
  475. X#ifdef F_SETLKW
  476. X   { flck.l_len=2;i|=fcntl(oldfdlock,F_SETLK,&flck);flck.l_type=F_UNLCK;
  477. X     flck.l_len=0;i|=fcntl(oldfdlock,F_SETLK,&flck);
  478. X   }
  479. X#else
  480. X     i=1;
  481. X#endif
  482. X  if(!i)
  483. X     for(i=GOBBLE;i&&gobble[--i]==~(unsigned)0;);
  484. X  return i;
  485. X}
  486. XHERE
  487. X
  488. Xif $MAKE _autotst >_autotst.rrr 2>&1
  489. Xthen
  490. X:
  491. Xelse
  492. X  echo 2>&1 "Whoeaaa!  There's something fishy going on here."
  493. X  echo 2>&1 "You have a look and see if you detect anything uncanny:"
  494. X  echo 2>&1 "*******************************************************"
  495. X  cat 2>&1 _autotst.rrr
  496. X  echo 2>&1 "*******************************************************"
  497. X  echo 2>&1 "I suggest you take a look at the definition of LDFLAGS*"
  498. X  echo 2>&1 "in the Makefile before you try make again."
  499. X  kill -15 $$
  500. Xfi
  501. X
  502. X$MV _locktst _locktst.$$ 2>$DEVNULL
  503. X$RM _autotst.$O _autotst.rrr locktst* 2>$DEVNULL
  504. X$MV _autotst _locktst
  505. Xfor a in 0 1 2 3
  506. Xdo echo dummy_file >_locktst.l$a
  507. Xdone
  508. X_locktst >_locktst.rrr 2>lock.log    # this will finish in the background
  509. Xecho 'Proceeding with kernel-locking-support tests in the background'
  510. X
  511. Xtest -f $USRINC/sys/socket.h -a -f $USRINC/netdb.h -a -f $USRINC/netinet/in.h||
  512. X echo "#define NO_COMSAT" >>$ACONF
  513. X
  514. Xcat >_autotst.c <<HERE
  515. X#include "$ACONF"
  516. X#ifndef UNISTD_H_MISSING
  517. X#include <unistd.h>        /* execvp() */
  518. X#endif
  519. Xmain()
  520. X{ char r[]="",*const*p;char*q="";static struct{const int a;int b;}c[2];
  521. X  --(c+1)->b;                 /* AIX 3.1.5 machines can't do this */
  522. X  p= &q;
  523. X  execvp(q,p);      /* IRIX 4.0.1 system-include files are wrong on this point */
  524. X  return *r;
  525. X}
  526. XHERE
  527. X
  528. Xecho 'Testing for const'
  529. Xif $MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr &&
  530. X test -f _autotst.$O
  531. Xthen
  532. X  grepfor const '#define const'
  533. Xelse
  534. X  echo '#define const' >>$ACONF
  535. Xfi
  536. X$RM _autotst.$O
  537. X
  538. Xcat >_autotst.c <<HERE
  539. Xmain(){volatile int i;return(i=0);}
  540. XHERE
  541. X
  542. Xecho 'Testing for volatile'
  543. Xif $MAKE _autotst.$O >$DEVNULL 2>&1 && test -f _autotst.$O
  544. Xthen
  545. X:
  546. Xelse
  547. X echo '#define volatile' >>$ACONF
  548. Xfi
  549. X$RM _autotst.$O
  550. X
  551. Xif $FGREP const $ACONF >$DEVNULL
  552. Xthen
  553. X  echo '#define P(args) ()' >>$ACONF
  554. Xelse
  555. X  cat >_autotst.c <<HERE
  556. Xmain(const argc,const char*const argv[]){return argc;}
  557. XHERE
  558. X
  559. X  echo 'Testing for prototypes'
  560. X  if $MAKE _autotst.$O >$DEVNULL 2>&1 && test -f _autotst.$O
  561. X  then
  562. X  :
  563. X  else
  564. X     echo '#define P(args) ()' >>$ACONF
  565. X  fi
  566. X  $RM _autotst.$O
  567. Xfi
  568. X
  569. Xcat >_autotst.c <<HERE
  570. X#include "includes.h"
  571. X#ifndef NO_COMSAT
  572. X#include "network.h"
  573. X#endif
  574. Xvoid*vvoid;
  575. Xmain(){int i;char*p="t";
  576. X {size_t vsize_t;i=vsize_t=1;}
  577. X {pid_t vpid_t;i=vpid_t=1;}
  578. X {time_t vtime_t;i=vtime_t=1;}
  579. X {mode_t vmode_t;i=vmode_t=1;}
  580. X {uid_t vuid_t;i=vuid_t=1;}
  581. X {gid_t vgid_t;i=vgid_t=1;}
  582. X#ifndef NO_COMSAT
  583. X {struct hostent host;i=!(host.h_addr_list=0);}
  584. X#endif
  585. X vvoid=p;
  586. X return !vvoid;}
  587. XHERE
  588. X
  589. Xecho 'Testing for void*,size_t,pid_t,time_t,mode_t,uid_t,gid_t'
  590. X$MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr
  591. X$RM _autotst.$O
  592. X
  593. Xgrepfor void '#define void char'
  594. Xgrepfor size_t 'typedef unsigned size_t;'
  595. Xgrepfor pid_t 'typedef int pid_t;'
  596. Xgrepfor time_t 'typedef long time_t;'
  597. Xgrepfor mode_t 'typedef int mode_t;'
  598. Xgrepfor uid_t 'typedef int uid_t;'
  599. Xgrepfor gid_t 'typedef int gid_t;'
  600. Xgrepfor h_addr_list '#define h_0addr_list h_addr' ||
  601. X grepfor struct '#define h_0addr_list h_addr'
  602. X
  603. Xcat >_autotst.c <<HERE
  604. X#include "includes.h"
  605. Xmain(){int i;i=1;
  606. X i+=WIFEXITED(i);
  607. X i+=WIFSTOPPED(i);
  608. X i+=WEXITSTATUS(i);
  609. X return i;}
  610. XHERE
  611. X
  612. Xecho 'Testing for WIFEXITED(), WIFSTOPPED() & WEXITSTATUS()'
  613. Xif $MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr
  614. Xthen
  615. X   grepfor struct '#define WMACROS_NON_POSIX' ||
  616. X    grepfor union '#define WMACROS_NON_POSIX'
  617. Xelse
  618. X   echo '#define WMACROS_NON_POSIX' >>$ACONF
  619. Xfi
  620. X$RM _autotst.$O
  621. X
  622. Xcat >_autotst.c <<HERE
  623. X#include "includes.h"
  624. X#ifndef NO_COMSAT
  625. X#include "network.h"
  626. X#endif
  627. Xmain(){char a[2];
  628. X endpwent();endgrent();memmove(a,"0",1);bcopy("0",a,1);strcspn(a,"0");
  629. X strtol("0",(char**)0,10);strchr("0",'0');strpbrk(a,"0");rename(a,"0");
  630. X opendir("0");initgroups("0",0);strstr("0","0");
  631. X#ifndef NOuname
  632. X {struct utsname b;uname(&b);}
  633. X#endif
  634. X#ifndef NO_COMSAT
  635. X gethostbyname("0");getprotobyname(COMSATprotocol);endhostent();endservent();
  636. X endprotoent();
  637. X#endif
  638. X return 0;}
  639. XHERE
  640. X
  641. Xecho 'Testing for memmove, strchr, strpbrk, strcspn, strtol, strstr & opendir'
  642. Xif $MAKE _autotst.$O >_autotst.rrr 2>&1
  643. Xthen
  644. X:
  645. Xelse
  646. X  echo 2>&1 "Whoeaaa!  There's something fishy going on here."
  647. X  echo 2>&1 "You have a look and see if you detect anything uncanny:"
  648. X  echo 2>&1 "*******************************************************"
  649. X  cat 2>&1 _autotst.rrr
  650. X  echo 2>&1 "*******************************************************"
  651. X  if $FGREP NO_COMSAT $ACONF >$DEVNULL
  652. X  then
  653. X     echo 2>&1 "Your include files seem to be beyond repair <sigh>."
  654. X     echo 2>&1 "I give up."
  655. X     kill -15 $$
  656. X  else
  657. X     echo 2>&1 "Maybe your network-support include files are messed up."
  658. X     echo 2>&1 "Continuing the compilation, throwing out network"
  659. X     echo 2>&1 "support..."
  660. X     $RM _autotst.$O
  661. X     echo "#define NO_COMSAT" >>$ACONF
  662. X     if $MAKE _autotst.$O >$DEVNULL 2>&1
  663. X     then
  664. X    echo "It seems to be all right."
  665. X     else
  666. X    echo 2>&1 "Your include files seem to be beyond repair <sigh>."
  667. X    echo 2>&1 "I give up."
  668. X    kill -15 $$
  669. X     fi
  670. X  fi
  671. Xfi
  672. X$MAKE _autotst 2>&1 | $FGREP -v include/ >_autotst.rrr
  673. X$RM _autotst _autotst.$O
  674. X
  675. Xgrepfor strcspn '#define NOstrcspn'
  676. Xgrepfor strpbrk '#define NOstrpbrk'
  677. Xgrepfor opendir "
  678. X#define NOopendir    /* the readdir library does not seem to be available
  679. X               this will slightly affect the way a filenumber is
  680. X               selected in MH-folders by procmail */
  681. X"
  682. Xgrepfor rename '#define NOrename'
  683. Xgrepfor strchr '#define strchr(s,c) index(s,c)'
  684. Xgrepfor uname "\
  685. X#define NOuname         \
  686. X/* the include files define it, the libraries don't */"
  687. Xgrepfor initgroups '#define initgroups(n,g)'
  688. Xgrepfor endpwent '#define endpwent()'
  689. Xgrepfor endgrent '#define endgrent()'
  690. Xif grepfor gethostbyname '#define NO_COMSAT'
  691. Xthen
  692. X:
  693. Xelse
  694. X  grepfor getprotobyname '#define UDP_protocolno 17'
  695. X  grepfor endhostent '#define endhostent()'
  696. X  grepfor endservent '#define endservent()'
  697. X  grepfor endprotoent '#define endprotoent()'
  698. Xfi
  699. Xgrepfor strtol '#define NOstrtol'
  700. Xgrepfor strstr '#define NOstrstr'
  701. Xgrepfor memmove '#define NOmemmove' &&
  702. Xif $FGREP -e bcopy _autotst.rrr >$DEVNULL
  703. Xthen
  704. X echo '#define NObcopy' >>$ACONF
  705. X
  706. X echo 'Testing for brain damage'
  707. X cat >_autotst.c <<HERE
  708. X#include "includes.h"
  709. Xstruct tests{int a,b;};
  710. Xmain(){
  711. X return offsetof(struct tests,b);}
  712. XHERE
  713. X if $MAKE _autotst.$O >$DEVNULL 2>&1
  714. X then
  715. X    :
  716. X else
  717. X    echo 'Yep, it is'            # ISC chokes on its own offsetof()
  718. X    echo '#define oBRAIN_DAMAGE' >>$ACONF
  719. X fi
  720. X $RM _autotst.$O
  721. X
  722. Xelse
  723. X
  724. X cat >_autotst.c <<HERE
  725. X#include "includes.h"
  726. X#define M256    256
  727. X#define F33    33
  728. Xmain(){int j=0,i=M256-1;static char a[M256];
  729. X  do a[i]=i;while(i--);
  730. X  bcopy(a+F33,a,M256-F33);bcopy(a,a+F33,M256-F33);i=F33-1;
  731. X  do j|=a[i]!=(char)(i+F33);while(i--);i=M256-1;
  732. X  do j|=a[i]!=(char)i;while(--i!=F33-1);return!j;}
  733. XHERE
  734. X
  735. X echo 'Testing for bcopy handling overlaps'
  736. X $MAKE _autotst >$DEVNULL 2>&1
  737. X
  738. X if _autotst
  739. X then
  740. X   echo 'Sorry, incompetent bcopy'
  741. X   echo '#define NObcopy' >>$ACONF
  742. X fi
  743. X $RM _autotst
  744. Xfi
  745. X
  746. X$FGREP -e LD_ /bin/ld >/dev/null 2>&1 && echo "#define LD_ENV_FIX" >>$ACONF
  747. Xtest -f /bin/test && echo "#define GOT_bin_test" >>$ACONF
  748. X
  749. Xcat >_autotst.c <<HERE
  750. X#include "includes.h"
  751. X#ifndef NO_COMSAT
  752. X#include "network.h"                     /* also for ntohs() */
  753. X#endif
  754. Xmain(argc)
  755. X{ unsigned long s=(size_t)~0;int i;
  756. X  for(i=1;s>>=1;i++);
  757. X  if(argc==1)
  758. X   {
  759. X#ifndef NO_COMSAT
  760. X#ifndef UDP_protocolno
  761. X     ;{ const struct protoent*p;
  762. X    if(p=getprotobyname(COMSATprotocol))
  763. X     { printf("#define UDP_protocolno %d\n",p->p_proto);
  764. X#else
  765. X     ;{ if(1)
  766. X     {
  767. X#endif
  768. X       ;{ const struct servent*serv;
  769. X          if(serv=getservbyname(COMSATservice,COMSATprotocol))
  770. X         printf("#define BIFF_serviceport \"%d\"\n",
  771. X          ntohs(serv->s_port));
  772. X        }
  773. X#ifdef AF_INET
  774. X       ;{ const struct hostent*host;
  775. X          if(!strcmp("localhost",COMSAThost)&&
  776. X           (host=gethostbyname(COMSAThost))&&
  777. X           host->h_0addr_list&&host->h_addrtype==AF_INET&&
  778. X           host->h_length)
  779. X           { int j=host->h_length;
  780. X         const unsigned char*ad=(void*)host->h_0addr_list;
  781. X         printf("#define IP_localhost {");
  782. X         do printf("%d,",*ad++);
  783. X         while(--j);
  784. X         puts("}");
  785. X           }
  786. X        }
  787. X#endif /* AF_INET */
  788. X     }
  789. X    else
  790. X       puts("#define NO_COMSAT");
  791. X      }
  792. X#endif /* NO_COMSAT */
  793. X     if(i<=16)
  794. X      { puts("#define SMALLHEAP");return 1;
  795. X      }
  796. X#ifdef _GUID_T                              /* ISC cc hack */
  797. X     ;{ struct passwd*p;
  798. X    if(sizeof(int)>sizeof(uid_t)&&(p=getpwnam("root"))&&(*p->pw_dir!='/'||
  799. X     (*p->pw_shell&&!(p->pw_shell)[1])))
  800. X       puts("#define _GUID_T\ntypedef int uid_t;\ntypedef int gid_t;");
  801. X      }
  802. X#endif
  803. X   }
  804. X#ifdef SYSTEM_MBOX
  805. X  if(argc==2)
  806. X   { printf("#define SYSTEM_MAILBOX %s\n",SYSTEM_MBOX);return 1;
  807. X   }
  808. X#endif
  809. X#ifdef DEFsendmail
  810. X  if(argc==3)
  811. X   { printf("#define SENDMAIL %s\n",DEFsendmail);return 1;
  812. X   }
  813. X#endif
  814. X  return 0;
  815. X}
  816. XHERE
  817. X
  818. Xecho 'Determining the most applicable block size'
  819. X
  820. X$MAKE _autotst >$DEVNULL 2>&1
  821. X_autotst >>$ACONF
  822. X
  823. Xfound=no
  824. Xfor a in /usr/spool/mail /usr/mail /var/spool/mail /var/mail
  825. Xdo
  826. X  test -d $a -a $found != yes &&
  827. X   echo '#define SYSTEM_MAILBOX "'$a'/$LOGNAME"' >>$ACONF && found=yes
  828. Xdone
  829. Xif test $found != yes && _autotst 2 >>$ACONF
  830. Xthen
  831. X echo '#define SYSTEM_MAILBOX "$HOME/.mail"' >>$ACONF
  832. X echo Could not find the system-mailbox directory, supplied substitute
  833. Xfi
  834. X
  835. Xcat >lookfor <<HERE
  836. Xfor a in /usr/lib /lib /usr/etc /etc /usr/bin /bin /usr/local/bin /usr/lbin \
  837. X /usr/local/lib /usr/local /usr/.lib
  838. Xdo
  839. X if test -f "\$a/\$1"
  840. X then
  841. X    echo "#define SENDMAIL \"\$a/\$1\"" >>$ACONF
  842. X    exit 0
  843. X fi
  844. Xdone
  845. Xexit 1
  846. XHERE
  847. Xchmod 0755 lookfor
  848. X
  849. Xif lookfor sendmail || lookfor smail
  850. Xthen
  851. X:
  852. Xelif _autotst 2 3 >>$ACONF
  853. Xthen
  854. X echo 'Could not find any mailer.  It should be a mailer accepting at least'
  855. X echo 'one plain destination address as its only argument (any sendmail'
  856. X echo 'compatible mailer will do), and the mail-to-be-sent on stdin.'
  857. X echo 'What is your mailer called?  (You can override this in config.h)'
  858. X read a
  859. X echo "#define SENDMAIL \"$a\"" >>$ACONF
  860. Xfi
  861. X
  862. Xcat /usr/lib/sendmail.cf /etc/sendmail.cf 2>$DEVNULL |
  863. X grep 'Mlocal.*procmail' >$DEVNULL ||
  864. X echo '#define CF_no_procmail_yet' >>$ACONF
  865. X
  866. Xtailpid=""
  867. X
  868. Xwhile $FGREP -e "Kernel-locking tests completed." _locktst.rrr >$DEVNULL; \
  869. X test 0 != $?
  870. Xdo
  871. X  if test -z "$tailpid"
  872. X  then
  873. X     echo "Waiting for kernel-locking tests to finish..."
  874. X     exec 9>&2 2>$DEVNULL
  875. X     tail -f lock.log &
  876. X     tailpid=$!
  877. X     exec 2>&9 9>&-
  878. X  fi
  879. X# if test ! -f _locktst.alive
  880. X# then
  881. X#    echo >_locktst.alive
  882. X#    echo "Waiting for kernel-locking tests to finish..."
  883. X# fi
  884. X  sleep 4
  885. Xdone
  886. Xexec 9>&2 2>$DEVNULL
  887. Xtest ! -z "$tailpid" && kill $tailpid && echo && echo
  888. Xexec 2>&9 9>&-
  889. Xecho "Collecting results from kernel-locking tests"
  890. Xsed -e '/^Kernel-locking tests completed./,$ d' <_locktst.rrr >>$ACONF
  891. Xif test -f core -a $nocore = yes
  892. Xthen
  893. X  echo "Removing core file (probably from the locking tests)"
  894. X  $RM core
  895. Xfi
  896. X
  897. X$RM _autotst* _locktst* lookfor grepfor 2>$DEVNULL
  898. X
  899. Xecho =============================autoconf.h===================================
  900. Xcat $ACONF
  901. Xecho ==========================================================================
  902. END_OF_FILE
  903. if test 23957 -ne `wc -c <'procmail280/src/autoconf'`; then
  904.     echo shar: \"'procmail280/src/autoconf'\" unpacked with wrong size!
  905. fi
  906. chmod +x 'procmail280/src/autoconf'
  907. # end of 'procmail280/src/autoconf'
  908. fi
  909. echo shar: End of archive 11 \(of 11\).
  910. cp /dev/null ark11isdone
  911. MISSING=""
  912. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  913.     if test ! -f ark${I}isdone ; then
  914.     MISSING="${MISSING} ${I}"
  915.     fi
  916. done
  917. if test "${MISSING}" = "" ; then
  918.     echo You have unpacked all 11 archives.
  919.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  920. else
  921.     echo You still need to unpack the following archives:
  922.     echo "        " ${MISSING}
  923. fi
  924. ##  End of shell archive.
  925. exit 0
  926. -- 
  927. Sincerely,                                  berg@pool.informatik.rwth-aachen.de
  928.            Stephen R. van den Berg (AKA BuGless).    berg@physik.tu-muenchen.de
  929.  
  930. "Be spontaneous!"
  931.  
  932. exit 0 # Just in case...
  933.