home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / BASHOS2.ZIP / support / mksysdefs.exe < prev    next >
Text File  |  1992-10-29  |  5KB  |  180 lines

  1. #!/local/bash/bash
  2. #
  3. # This file creates a file called "sysdefs.h" which contains CPP defines
  4. # helping to describe the operating system features.  We just take guesses
  5. # by looking at random files.
  6.  
  7. if [ "$1" ]; then
  8.   sysdefs=$1
  9. else
  10.   sysdefs=./sysdefs.h
  11. fi
  12.  
  13. rm -f $sysdefs
  14.  
  15. echo "/* sysdefs.h -- #defines for your system created by $0."       >>$sysdefs
  16. echo "   Do NOT EDIT this file, since any changes will disappear." >>$sysdefs
  17. echo "   Instead, edit $0, or config.h, or machines.h. */"       >>$sysdefs
  18. echo ""                                   >>$sysdefs
  19. echo "#if !defined (_SYSDEFS_H_)"                   >>$sysdefs
  20. echo "#  define _SYSDEFS_H_"                       >>$sysdefs
  21.  
  22. # Removes any inherited definitions.
  23. SHLIB=
  24. SYSDEF=
  25.  
  26. # Test for shared libraries (this is pretty Sunish).
  27. if test -f /lib/ld.so; then
  28.   SHLIB=-DHAVE_SHARED_LIBS
  29.   echo ""                    >>$sysdefs
  30.   echo "#define HAVE_SHARED_LIBS"        >>$sysdefs
  31. fi
  32.  
  33. # Test for shared libraries (this is pretty sVr4ish).
  34. if test -f /usr/ccs/lib/libc.so; then
  35.   if [ "$SHLIB" = "" ]; then
  36.     SHLIB=-DHAVE_SHARED_LIBS
  37.     echo ""                    >>$sysdefs
  38.     echo "#if !defined (HAVE_SHARED_LIBS)"    >>$sysdefs
  39.     echo "#  define HAVE_SHARED_LIBS"        >>$sysdefs
  40.     echo "#endif /* HAVE_SHARED_LIBS */"    >>$sysdefs
  41.   fi
  42.   SYSDEF=USGr4
  43. fi
  44.  
  45. # Get name of maintainer.
  46. if (whoami) >/dev/nul 2>&1 && (hostname) >/dev/nul 2>&1; then
  47.   WHOAMI=`whoami`@`hostname`;
  48. else
  49.   WHOAMI=`who am i | awk '{ print $1; }'`
  50. fi
  51.  
  52. if [ "$WHOAMI" = "" ]; then 
  53.   WHOAMI=`id | sed 's/uid=[01-9]*(//' | sed 's/) [) A-Za-z01-9(=,]*//'`
  54.   if (hostname) >/dev/nul 2>&1; then
  55.     WHOAMI=$WHOAMI@`hostname`
  56.   elif test -f /usr/bin/uuname -o -f /bin/uuname; then
  57.     WHOAMI=`uuname -l`!$WHOAMI
  58.   fi
  59. fi
  60.  
  61. if [ "$WHOAMI" = "" ]; then
  62.   WHOAMI=root
  63. fi
  64.  
  65. echo ""                        >>$sysdefs
  66. echo "#if !defined (MAINTAINER)"        >>$sysdefs
  67. echo "#  define MAINTAINER $WHOAMI"        >>$sysdefs
  68. echo "#endif /* MAINTAINER */"            >>$sysdefs
  69.  
  70. # Try to locate ranlib.  I think this is a bad idea.
  71. if [ -r /usr/bin/ranlib ]; then RANLIB_LOCATION=/usr/bin/ranlib;
  72. elif [ -r /bin/ranlib ]; then RANLIB_LOCATION=/bin/ranlib;
  73. elif [ -r /usr/local/bin/ranlib ]; then RANLIB_LOCATION=/usr/local/bin/ranlib;
  74. elif [ -r /usr/local/gnubin/ranlib ]; then RANLIB_LOCATION=/usr/local/gnubin/ranlib;
  75. fi
  76.  
  77. # Does this system have /bin/csh?  We don't care about other csh's.
  78. if [ -f /bin/csh ]; then
  79.   echo ""                        >>$sysdefs
  80.   echo "#if !defined (HAVE_CSH)"             >>$sysdefs
  81.   echo "#  define HAVE_CSH"                >>$sysdefs
  82.   echo "#endif /* HAVE_CSH */"                 >>$sysdefs
  83. fi
  84.  
  85. if [ "${RANLIB_LOCATION}" ]; then
  86.   echo ""                        >>$sysdefs
  87.   echo "#if !defined (RANLIB_LOCATION)"         >>$sysdefs
  88.   echo "#  define RANLIB_LOCATION ${RANLIB_LOCATION}"    >>$sysdefs
  89.   echo "#endif /* RANLIB_LOCATION */"             >>$sysdefs
  90. fi
  91.  
  92. #
  93. # Is this a Xenix system?
  94. #
  95. if [ -f /xenix ]; then
  96.   SYSDEF="Xenix"
  97.  case "`/bin/uname -p`" in
  98.   *286) SYSDEF="Xenix286" ;;
  99.   *386) SYSDEF="Xenix386" ;;
  100.  esac
  101. fi
  102.  
  103. #
  104. # Is this a cadmus system?
  105. #
  106. if [ -f /unix ]; then
  107.   if [ -d /generic ]; then   # This is an AIX system.
  108.     SYSDEF="aixpc"
  109.     cat cpp-Makefile | grep -v '/\*\*/' >aix-Makefile
  110.   elif [ -d /etc/conf/kconfig.d ] && [ -f /usr/include/sys/limits.h ]; then
  111.     SYSDEF="isc386"            # This is a 386 running ISC?
  112.   elif [ -f /etc/xlc.cfg ]; then
  113.     if fgrep _IBMR2 /etc/xlc.cfg >/dev/nul 2>&1; then
  114.       SYSDEF=RISC6000
  115.       cat cpp-Makefile | grep -v '/\*\*/' >aix-Makefile
  116.     fi
  117.   elif [ -f /bin/4d -a -f /bin/uname ]; then
  118.     case "`uname -r`" in
  119.       3.*) SYSDEF="Irix3" ;;
  120.       4.*) SYSDEF="Irix4" ;;
  121.       *)   SYSDEF="Irix3" ;;
  122.     esac
  123.   elif [ -d /usr/amiga ]; then
  124.     SYSDEF="amiga"        # An Amiga running V.4.
  125.   else
  126.     if [ "$SYSDEF" = "" ]; then
  127.       SYSDEF="cadmus"
  128.     fi
  129.  
  130.     if [ -f /shlib/libc_s ]; then
  131.       SHLIB=-DHAVE_SHARED_LIBS
  132.       echo ""                    >>$sysdefs
  133.       echo "#if !defined (HAVE_SHARED_LIBS)"    >>$sysdefs
  134.       echo "#  define HAVE_SHARED_LIBS"        >>$sysdefs
  135.       echo "#endif /* HAVE_SHARED_LIBS */"    >>$sysdefs
  136.     fi
  137.   fi
  138. fi
  139.  
  140. if [ "$SYSDEF" != "" ]; then
  141.   echo ""                    >>$sysdefs
  142.   echo "#if !defined ($SYSDEF)"            >>$sysdefs
  143.   echo "#  define $SYSDEF"            >>$sysdefs
  144.   echo "#endif /* $SYSDEF */"            >>$sysdefs
  145. fi
  146.  
  147. if [ -f /usr/include/unistd.h ]; then
  148.   echo ""                    >>$sysdefs
  149.   echo "#if !defined (HAVE_UNISTD_H)"        >>$sysdefs
  150.   echo "#  define HAVE_UNISTD_H"        >>$sysdefs
  151.   echo "#endif /* HAVE_UNISTD_H */"        >>$sysdefs
  152. fi
  153.  
  154. if [ -f /usr/include/sys/wait.h ]; then
  155.   echo ""                    >>$sysdefs
  156.   echo "#if !defined (HAVE_WAIT_H)"        >>$sysdefs
  157.   echo "#  define HAVE_WAIT_H"            >>$sysdefs
  158.   echo "#endif /* HAVE_WAIT_H */"        >>$sysdefs
  159. fi
  160.  
  161. if [ -f /usr/include/alloca.h ]; then
  162.   echo ""                    >>$sysdefs
  163.   echo "#if !defined (HAVE_ALLOCA_H)"        >>$sysdefs
  164.   echo "#  define HAVE_ALLOCA_H"        >>$sysdefs
  165.   echo "#endif /* HAVE_ALLOCA_H */"        >>$sysdefs
  166. fi
  167.  
  168. if [ -f /usr/include/sys/resource.h ]; then
  169.   echo ""                    >>$sysdefs
  170.   echo "#if !defined (HAVE_RESOURCE)"        >>$sysdefs
  171.   echo "#  define HAVE_RESOURCE"        >>$sysdefs
  172.   echo "#endif /* HAVE_RESOURCE */"        >>$sysdefs
  173. else
  174.   RESOURCE=
  175. fi
  176.  
  177. # These should be the last 2 lines in this file!
  178. echo ""                        >>$sysdefs
  179. echo "#endif /* _SYSDEFS_H_ */"            >>$sysdefs
  180.