home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / gnu / gcc / help / 2875 / mkucbgcc
Encoding:
Text File  |  1993-01-07  |  3.2 KB  |  125 lines

  1. #!/bin/sh
  2. #
  3. # Script to make a version of gcc that uses the BSD environment.
  4. # It will create the following files:
  5. #     /usr/ucb/gcc
  6. #     $GNUBIN/ucbgcc
  7. # And will create a directory
  8. #    $GNU/lib/gcc-lib/sparc-sun-solaris2-bsd/$version
  9. # that contains
  10. #    hardlinks to every file from sparc-sun-solaris2
  11. #    ucbinclude: a directory with fixed include files from /usr/ucbinclude
  12. #    a specs file that will use these new include files before the SysV ones
  13. #
  14. # Use of this C compiler:
  15. #    /usr/ucb/gcc
  16. #    ucbgcc
  17. #    gcc -bsd
  18. #
  19. # If you don't have cygnus-bin installed, you'll need to give a path to
  20. # your gcc source directory because mkucbgcc needs fixinc.svr4.
  21. #
  22. # This script has been tested with:
  23. #    cygnus-2.0.2
  24. #    gcc 2.3.2 and 2.3.3
  25. # on Solaris 2.1
  26. #
  27. # Author: Casper Dik (casper@fwi.uva.nl)
  28. #
  29. PATH=/bin:$PATH
  30. export PATH
  31.  
  32. echo Installing gcc for ucb environment.
  33. specs=`gcc -v 2>&1 |awk '$2 == "specs" { print $4 }' `
  34. if [ `basename $specs` != specs -o ! -f $specs ]
  35. then
  36.     echo 1>&2 "Can't locate gcc or specs file"
  37.     exit 1
  38. fi
  39.  
  40. # The specs file lives in <root>/lib/gcc-lib/<mach>/<version>/specs
  41. svrpath=`dirname $specs`
  42. version=`basename $svrpath`
  43. tmp=`dirname $svrpath`
  44. mach=`basename $tmp`
  45. tmp=`dirname $tmp`
  46. if [ gcc-lib != `basename $tmp` ]
  47. then
  48.     echo 1>&2 "Oops, path to specs file is not what I expect"
  49.     exit 1
  50. fi
  51. tmp=`dirname $tmp`
  52.  
  53. root=`dirname $tmp`
  54.  
  55. # Not sure about the fixinc.svr4 bit.
  56. if [ x"$1" != x ]
  57. then
  58.     fixinc="$1"/fixinc.svr4
  59.     if [ ! -d "$1" ]
  60.     then
  61.     echo 1>&2 "$1: not a directory"
  62.     exit 1
  63.     fi
  64.     if [ ! -x $fixinc -o ! -f $fixinc ]
  65.     then
  66.     echo 1>&2 "$fixinc: Can't execute"
  67.     exit 1
  68.     fi
  69. elif [ -f $root/lib/fixincludes -a `expr $version : cygnus` != 0 ]
  70. then
  71.     fixinc=$root/lib/fixincludes 
  72. else
  73.     echo 1>&2 "Usage: $0 <gcc-src-directory> (for fixinc.svr4)"
  74.     exit 1
  75. fi
  76.  
  77. if [ lib != `basename $tmp` ]
  78. then
  79.     echo 1>&2 "Oops, path to specs file is not what I expect"
  80.     exit 1
  81. fi
  82. if [ cygnus-2.0.2 != $version -a 2.3.2 != $version -a 2.3.3 != $version ]
  83. then
  84.     echo 1>&2 "Caveat: not tested for all versions of gcc."
  85. fi
  86.  
  87. ucbpath=$root/lib/gcc-lib/$mach-bsd/$version
  88.  
  89. echo Making directory structure.
  90. rm -rf $ucbpath/ucbinclude
  91. rm -f $ucbpath/*
  92. mkdir -p $ucbpath/ucbinclude
  93. # Link for gcc -bsd
  94. rm -f $root/lib/gcc-lib/sd
  95. ln -s $mach-bsd $root/lib/gcc-lib/sd
  96.  
  97. echo Making links.
  98. echo "Expect complaint: \`\`ln: <$svrpath/include> directory''"
  99. ln $svrpath/* $ucbpath
  100. set -e
  101. rm $ucbpath/specs
  102. echo "Updating specs file."
  103. sed -e "/^\*cpp:$/N;s%cpp:\n%&-I$root/lib/gcc-lib/$mach-bsd/$version/ucbinclude -I/usr/ucbinclude %"\
  104.     -e "/^\*lib:$/N;s%lib:\n%&-lucb -lsocket -lnsl -lelf -laio %"\
  105.     -e "/^\*link:$/N;s%link:.*$%& -R /usr/ucblib%"\
  106.     -e "s%Y P,%&/usr/ucblib:%g" < $svrpath/specs > $ucbpath/specs
  107.  
  108. cp $svrpath/include/*.h $ucbpath/ucbinclude
  109.  
  110. echo Running fixincludes. This may take some time. Output in /tmp/fixincludes.log
  111. echo Expect complaint from fixincludes about byteorder.h
  112. $fixinc $ucbpath/ucbinclude /usr/ucbinclude > /tmp/fixincludes.log < /dev/null
  113.  
  114.  
  115. rm -f /usr/ucb/gcc $root/bin/ucbgcc
  116. ln -s $root/bin/ucbgcc /usr/ucb/gcc
  117. cat > $root/bin/ucbgcc << !
  118. #!/bin/sh
  119. exec $root/bin/gcc -b $mach-bsd "\$@"
  120. !
  121. chmod 755 $root/bin/ucbgcc
  122.  
  123. echo Installation of /usr/ucb/gcc successfull.
  124. exit 0
  125.