home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / finger / part05 / autoconfig < prev    next >
Encoding:
Text File  |  1992-04-03  |  10.4 KB  |  436 lines

  1. #! /bin/sh
  2. #  
  3. # Automatic configuration shell script for finger
  4. # Not quite up to Larry Wall's level...
  5. #  
  6. # Copyright (C) 1988, 1990  Philip L. Budne
  7. #  
  8. # This file is part of "Phil's Finger Program".
  9. #  
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 1, or (at your option)
  13. # any later version.
  14. #  
  15.  
  16. # $Id: autoconfig,v 3.0 90/07/06 13:10:22 budd Rel $
  17.  
  18. #  
  19. #  
  20. TMPDIR=/tmp
  21. #  
  22. SYSTEM=''
  23. #  
  24. E=/bin/echo
  25. #  
  26. # blank line
  27. B=$E
  28. #  
  29. # should return status
  30. CONTAINS=grep
  31. #  
  32. # hope its on your path, or built in
  33. T=test
  34. # end test
  35. ET=
  36. #  
  37. # test flags:
  38. #  
  39. # existance 
  40. EXI=-f
  41. # directory 
  42. DIR=-d
  43. # negation 
  44. NOT=!
  45. #  
  46. OR=-o
  47. AND=-a
  48. STR=
  49. LP='('
  50. RP=')'
  51. #  
  52. # S5
  53. BLK=-b
  54. CHR=-c
  55. # also -f means regular file only!
  56. #  
  57. # shorthand...
  58. TEXI="$T $EXI"
  59. TSTR="$T $STR"
  60. TDIR="$T $DIR"
  61. #
  62. if $TEXI /bin/hostname $ET; then
  63.     HOSTNAME=`/bin/hostname`
  64. elif $TEXI /bin/uname $ET; then
  65.     HOSTNAME=`/bin/uname -n`
  66. else
  67.     HOSTNAME='idunno'
  68. fi
  69. #  
  70. $E '/*'
  71. $E ' *    local.h for '$HOSTNAME
  72. $E ' *    created on '`date` by `./mywhoami` using autoconfig
  73. $E ' *'
  74. $E ' * do not edit this file.  instead put #define and #undef lines'
  75. $E ' * in the file local-flags which is inserted at the end of this file.'
  76. $E ' */'
  77. $B
  78. ################
  79. if $TEXI /bin/sun $ET && /bin/sun; then
  80.     # check for /usr/lib/liblwp.a ?
  81.     if $TDIR /var $ET; then
  82.     if $TEXI /bin/uname $ET; then
  83.         SOS=`uname -r -v | sed -e 's/\.//g' -e 's/ //g'`
  84.     elif $TDIR /usr/kvm $ET; then
  85.         # consdev fixed/broken in 4.0.3
  86.         SOS=403
  87.     else
  88.         SOS=400
  89.     fi
  90.     else
  91.     # 3.something
  92.     SOS=300
  93.     fi
  94.     $E '# define SunOS '$SOS
  95.     $B
  96. elif $TEXI /Umax.image $ET; then
  97.     if $TDIR /var $ET; then
  98.     $E '# define Umax 43            /* Encore Umax 4.3 */'
  99.     else
  100.         $E '# define Umax 42            /* Encore Umax 4.2 */'
  101.     fi
  102.     $B
  103. elif $CONTAINS BSD4_3 /usr/include/sys/param.h > /dev/null; then
  104.     $E '# define bsd4_3'
  105.     $B
  106. fi
  107. # accel, ultrix cpp have predefines
  108. ################
  109. # Sun, A/UX
  110. if $TEXI /etc/in.rlogind $OR $EXI /usr/etc/in.rlogind $ET; then
  111.     $E '# define IN_DOT_DAEMON    /* internet daemon names prefixed with in. */'
  112.     $B
  113. fi
  114. ################
  115. # check for /usr/adm/lastlog as well?
  116. if $TEXI /usr/include/lastlog.h $ET; then
  117.     $E '# define LASTLOG            /* BSD last login file */'
  118.     $B
  119. fi
  120. ################
  121. # check libc.a for wait3??
  122. if $T $NOT $EXI /usr/include/sys/wait.h $ET; then
  123.     $E '# define NO_WAIT_H            /* no BSD sys/wait.h */'
  124.     $B
  125. fi
  126. ################
  127. # BSD systems have drum
  128. # use checkmode to avoid incompatabilities in test
  129. # RT AIX and UmaxV lack /dev/swap
  130. if ./checkmode /dev/drum 0 >/dev/null 2>&1; then
  131.     $E '# define SWAP_DEVICE "/dev/drum"    /* swap device */'
  132.     $B
  133. elif ./checkmode /dev/swap 0 >/dev/null 2>&1; then
  134.     $E '# define SWAP_DEVICE "/dev/swap"    /* swap device */'
  135.     $B
  136.     USG=true
  137. elif $T $CHR /dev/ipldevice $ET; then
  138.     $E '# define AIX3                /* AIX release 3 (RS/6000) */'
  139.     USG=true
  140. elif $TEXI /bin/vrmfmt $ET; then
  141.     # AIX defined by cc command (what about PS/2 AIX?)
  142.     USG=true
  143.     UNDERSCORE=true
  144.     $E '# define AIX_RT                /* IBM PC/RT AIX */'
  145.     $B
  146. elif $T $CHR /dev/bbram $ET; then
  147.     $E '# define UmaxV                /* Encore Umax V */'
  148.     $B
  149.     USG=true
  150.     UNDERSCORE=true
  151. elif $TEXI /usr/include/sys/sysi86.h $ET; then
  152.     # Interactive SVR3.2 (others?)
  153.     USG=true
  154.     $E '# define SYSI86                /* 386/ix */'
  155.     $B
  156. fi
  157. ####
  158. if $TSTR "$USG" $ET; then
  159.     $E '# define USG                /* AT&T Unix */'
  160.     $B
  161.     if $T $CHR /dev/pts1 $ET; then
  162.     # AIX at least...
  163.     $E '# define PTYPATH "/dev/pts1"'
  164.     $B
  165.     $E '# define PTS_PTY_NAMES'
  166.     $B    
  167.     elif $T $CHR /dev/ttyq1 $ET; then
  168.     # SGI at least...
  169.     $E '# define PTYPATH "/dev/ttyq1"'
  170.     $B
  171.     fi
  172.     if $TEXI /usr/include/sys/dir.h $ET; then
  173.     $E '# define DIR_H'
  174.     $B
  175.     fi
  176.     if $TEXI /usr/include/sys/i386/ps2mous.h $ET; then
  177.     $E '# define AIX_PS2'
  178.     $B
  179.     fi
  180. fi
  181. ################
  182. if $TEXI /usr/include/filehdr.h $ET; then
  183.     $E '# define COFF                /* Common Object File Fiasco */'
  184.     $B
  185. else
  186.     UNDERSCORE=true
  187. fi
  188. ####
  189. if $TSTR "$UNDERSCORE"; then
  190.     $E '# define UNDERSCORE_NLIST_NAMES'
  191.     $B
  192. fi
  193. ################
  194. # SOS3.4 has (empty) stream.h!
  195. if $TEXI /usr/include/sys/stropts.h $ET; then
  196.     $E '# define STREAMS'
  197.     $B
  198. fi
  199. ################
  200. # check for SVR3 state names
  201. if $CONTAINS SXBRK /usr/include/sys/proc.h >/dev/null; then
  202.     $E '# define SVR3_STATES'
  203.     $B
  204. fi
  205. ################
  206. # check for short *{u,p}_ttyp (streams tty driver) sgi and SOS4
  207. if $CONTAINS 'short[     ]*\*[     ]*[ups]_ttyp' \
  208.     /usr/include/sys/user.h /usr/include/sys/proc.h >/dev/null 2>&1 ||
  209.     $TEXI /usr/include/sys/session.h $ET; then
  210.     $E '# define SHORT_TTYP'
  211.     $B
  212. fi
  213. ################
  214. # p_addr on AOS/ACIS 4.3 (RT) loses
  215. if $TDIR /usr/ibm $ET; then
  216.     $E '# define NEED_USRPT'
  217.     $B
  218. fi
  219. ################
  220. # USG uname(2) call (or simulation)
  221. # perhaps grep nm of libc.a too?
  222. if $TEXI /usr/include/sys/utsname.h $ET; then
  223.     $E '# define UTSNAME            /* USG uname(2) call */'
  224.     $B
  225. fi
  226. ################
  227. if $T $NOT $EXI /usr/include/strings.h $ET; then
  228.     $E '# define NO_STRINGS_H            /* No BSD strings */'
  229.     $B
  230. fi
  231. ################
  232. LIB=/lib/libc.a
  233. LIBNM=/tmp/auto$$
  234. if $TEXI /usr/include/netdb.h $ET && \
  235.     $CONTAINS h_errno /usr/include/netdb.h >/dev/null; then
  236.     $E "netdb.h has h_errno.  Checking libc.a..." 1>&2
  237.     nm $LIB > $LIBNM
  238.     if $CONTAINS 'h_errlist' $LIBNM >/dev/null; then
  239.     $E "The world is safe! $LIB contains h_errlist" 1>&2
  240.     $E '# define HAVE_H_ERRNO            /* found h_errno */'
  241.     else
  242. # SunOS 4.0 strikes again!
  243.     $E "$LIB lacks h_errlist!!" 1>&2
  244.     fi
  245.     $B
  246.     rm -f $LIBNM
  247. fi
  248. ################
  249. if $TEXI /bin/write $ET; then
  250.     if ./checkmode /bin/write gs >/dev/null; then
  251.     set foo `./getgroup /bin/write`
  252.     $E "# define TTY_GROUP_NUMBER $3"
  253.     $B
  254.     if $TSTR "$4" $ET; then
  255.         $E '# define TTY_GROUP "'$4'"'
  256.         $B
  257.     fi
  258.     fi
  259. fi
  260. ################
  261. # for Install.cpp -- shell orif to avoid confusing BSD test with -c
  262. # check for protected swap device as well??
  263. if $TEXI /dev/kmem $ET || $T $CHR /dev/kmem $ET; then
  264.     if ./checkmode /dev/kmem gr+o gr >/dev/null; then
  265.     $E '/* for Install.cpp */'
  266.     set foo `./getgroup /dev/kmem`
  267.     if $TSTR "$4" $ET; then
  268.         $E "# define KMEM_GROUP $4"
  269.     else
  270.         $E "# define KMEM_GROUP $3"
  271.     fi
  272.     $B
  273.     fi
  274. fi
  275. ################
  276. if $TEXI /bin/domainname $ET; then
  277.     YPDOMAIN=`/bin/domainname`
  278. elif $TEXI /usr/bin/domainname $ET; then
  279.     YPDOMAIN=`/usr/bin/domainname`
  280. fi
  281. ################
  282. if $TEXI /etc/ypbind $OR $EXI /usr/etc/ypbind $ET; then
  283.     if $TSTR "$YPDOMAIN" $ET; then
  284.     $E "IF YOU ARE NOT USING YP, YOU MAY NEED TO DEFINE 'GETPWNAM_SLOW'"\
  285.                                 1>&2
  286.     $E '/* getpwnam(3) is fast (yellow pages) */'
  287.     else
  288.     $E "IF YOU ARE USING YP, YOU MAY WANT TO UNDEFINE 'GETPWNAM_SLOW'"\
  289.                                 1>&2
  290.     $E '# define GETPWNAM_SLOW            /* yp not enabled */'
  291.     fi
  292. elif $TEXI /etc/passwd.pag $OR $EXI /etc/passwd.dir $ET; then
  293.     $E '/* getpwnam(3) is fast (dbm passwd file) */'
  294. else
  295.     $E '# define GETPWNAM_SLOW            /* 4.2 getpwnam(3) is losing */'
  296. fi
  297. $B
  298. ################
  299. # should check libc.a for yp_match.o
  300. if $TEXI /usr/include/rpcsvc/ypclnt.h $AND $STR "$YPDOMAIN" $ET; then
  301.     $E '# define HAVE_YP_MATCH            /* have yp_match(3) */'
  302.     $B
  303. fi
  304. ################
  305. if $TEXI /etc/aliases $ET; then
  306.     ALIASES=/etc/aliases
  307. elif $TEXI /usr/lib/aliases $ET; then
  308.     ALIASES=/usr/lib/aliases
  309. fi
  310. #  
  311. if $TSTR "$ALIASES" $ET; then
  312.     $E '# define ALIASES "'$ALIASES'"    /* sendmail aliases file */'
  313.     $B
  314. fi
  315. ################
  316. # 4.3 and Ultrix
  317. # note: use exists. let them see grep error!
  318. if $TEXI /usr/include/sys/tty.h $ET; then
  319.     if $CONTAINS t_winsize /usr/include/sys/tty.h >/dev/null; then
  320.     $E '# define TTY_REQUIRES_IOCTL        /* struct winsize */'
  321.     $B
  322.     fi
  323. fi
  324. ################
  325. # 4.3 and Ultrix
  326. # perhaps search libc.a too?
  327. if $TEXI /usr/include/ttyent.h $ET; then
  328.     $E '# define TTYENT                /* use getttyent(3) */'
  329.     $B
  330. fi
  331. ################
  332. # 4.3, Ultrix and Sun
  333. if $TEXI /etc/inetd $OR $EXI /usr/etc/inetd $ET; then
  334.     $E '# define INETD                /* use inetd for fingerd */'
  335.     $B
  336. fi
  337. ################
  338. # SunOS 4.x, Ultrix 3.x, SVR3?
  339. if $CONTAINS 'void.*signal' /usr/include/signal.h >/dev/null; then
  340.     $E '# define VOIDSIG            /* signal() declared as void * */'
  341.     $B
  342. fi
  343. ################
  344. # Ultrix 3.x, A/UX
  345. if $CONTAINS p_ttyp /usr/include/sys/proc.h >/dev/null; then
  346.     $E '# define P_TTYP                /* tty pointer in proc struct */'
  347.     $B
  348. fi
  349. ################
  350. # USG 
  351. if $CONTAINS ut_host /usr/include/utmp.h >/dev/null; then
  352.     $E '/* utmp has ut_host field */'
  353. else
  354.     $E '# define UTMP_NO_HOST            /* utmp file lacks host field */'
  355. fi
  356. $B
  357. ################
  358. if $TEXI /vmunix $ET; then
  359.     $E '# define KERNEL_FILE "/vmunix"'
  360. elif $TEXI /unix $ET; then
  361.     $E '# define KERNEL_FILE "/unix"'
  362. elif $TEXI /dynix $ET; then
  363.     $E '# define KERNEL_FILE "/dynix"'
  364. elif $TEXI /Umax.image $ET; then
  365.     $E '# define KERNEL_FILE "/Umax.image"'
  366. else
  367.     $E '/* no KERNEL_FILE found */'
  368. fi
  369. $B
  370. ################
  371. # AIX has both?  check /usr/mail first!!
  372. if $TDIR /usr/mail $ET; then
  373.     $E '# define MAIL_SPOOL "/usr/mail"'
  374. elif $TDIR /usr/spool/mail $ET; then
  375.     $E '# define MAIL_SPOOL "/usr/spool/mail"'
  376. else
  377.     $E '/* no MAIL_SPOOL found */'
  378. fi
  379. $B
  380. ################
  381. if $TEXI /usr/include/syslog.h $ET; then
  382.     $E '# define SYSLOG                /* fingerd does syslog-ing */'
  383.     $B
  384. fi
  385. ################
  386. if $TEXI /usr/include/inquir.h $ET; then
  387.     $E '# define INQUIRE            /* use inquire database */'
  388.     $B
  389. fi
  390.  
  391. # Boilerplate...
  392. cat <<END_OF_STUFF
  393. # define SAVED_NLIST "/etc/finger-saved-nlist" /* save nlist to this file */
  394.  
  395. # define AUTONLIST            /* update nlist save file as needed */
  396.  
  397. # define NLIST_MODE 0664        /* creation mode for nlist file */
  398.  
  399. # define NETBERK            /* network finger implies /berk */
  400.                     /* (I hate this) */
  401.  
  402. # define NETFOLLOW            /* net finger implies /follow */
  403.  
  404. /**************** REQUIRED!! (used by Install) ****************/
  405.  
  406. # define TTYLOC_DIR "/usr/spool/ttyloc"
  407.  
  408. # define TTYLOC_MODE 0644
  409.  
  410. END_OF_STUFF
  411. #  
  412. if $TEXI local-flags $ET; then
  413.     $E '/* local-flags: *****************/'
  414.     cat local-flags
  415.     $B
  416.     $E '/* end of local-flags ***********/'
  417. else
  418.     $E '/* host name prefixes to remove */'
  419.     $E '/*# define PREFIXES "PREFIX1", "PFX2" /**/'
  420.     $B
  421.     $E '/* extra paths to try to exec finger */'
  422.     $E '/* # define FINGERPATHS "/usr/local/local/bin/finger", "/bin/who" /**/'
  423.     $B
  424.     $E '# define C_FLAGS -g        /* compiler debug on by default */'
  425.     $E '# define DEBUGSW        /* include /debug switch */'
  426.     $E '# define UNPREFIX_NODOMAIN    /* unprefix hosts with no dots */'
  427. fi
  428. $B
  429. cat <<END_OF_STUFF
  430. /*
  431.  * Local variables:
  432.  * comment-column: 40
  433.  * End:
  434.  */
  435. END_OF_STUFF
  436.