home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / linux / 8479 < prev    next >
Encoding:
Text File  |  1992-08-17  |  10.5 KB  |  506 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!gatech!darwin.sura.net!mips!cs.uoregon.edu!nntp.uoregon.edu!news.u.washington.edu!serval!phys1.physics.wsu.edu!hlu
  3. From: hlu@phys1.physics.wsu.edu (Hongjiu Lu)
  4. Subject: New install is on tsx-11.
  5. Message-ID: <1992Aug17.180152.16259@serval.net.wsu.edu>
  6. Sender: news@serval.net.wsu.edu (USENET News System)
  7. Organization: Washington State University
  8. Date: Mon, 17 Aug 92 18:01:52 GMT
  9. Lines: 495
  10.  
  11. If you have trouble with install.2.x, please get a new one from tsx-11. Or
  12. use the one here.
  13.  
  14.  
  15. -- 
  16. H.J.
  17. Gcc/libc maintainer for Linux.
  18. --------------
  19. #!/bin/sh
  20. # installation of gcc 2.xxx
  21.  
  22. # do something to kernel souce
  23. kernelstuff ()
  24. {
  25.   workdir=$1
  26.   srcdir=$2
  27.  
  28. # we may have something in there.
  29.  
  30.   for d in asm linux; do
  31.     if [ -d /usr/include/${d} ]; then
  32.       for f in /usr/include/${d}/*.h; do
  33.     if [ -f $f ]; then 
  34.       mv $f ${srcdir}/include/$d
  35.     fi
  36.       done
  37.       /bin/rm -rf /usr/include/${d}
  38.     fi
  39.   done
  40. }
  41.  
  42. # install jump table
  43. jumptable ()
  44. {
  45.   DIR=$1
  46.   VER=$2
  47.   REL=$3
  48.   M=$4
  49.  
  50.   mv $DIR/libc.so.${REL} /lib
  51.   mv $DIR/lib${M}.so.${REL} /lib/libm.so.${REL}
  52.  
  53.   ln -s -f /lib/libc.so.${REL} /lib/libc.so.${VER}
  54.   ln -s -f /lib/libm.so.${REL} /lib/libm.so.${VER}
  55. }
  56.  
  57. checkreturn ()
  58. {
  59.   if [ $? != 0 ]
  60.   then
  61.     echo Failed to $1.
  62.     exit 1
  63.   fi
  64. }
  65.  
  66. fixfiles ()
  67. {
  68.   VERBOSE=$1
  69.   VER=$2
  70.   BINS=$3
  71.  
  72.   if [ $VERBOSE = yes ]; then set -x; fi
  73.  
  74.   cd /usr/bin
  75.   chown bin:bin $BINS
  76.   chmod 755 $BINS
  77.  
  78.   chown -R bin:bin /usr/include /usr/g++-include /lib /usr/lib/gcc-lib
  79.   chmod -R 755 /lib /usr/lib/gcc-lib
  80.  
  81.   # this is for the header files
  82.   chmod 755 /usr/include /usr/g++-include
  83.   # Yes, 'find' would be cleaner and faster, but it is not on rootdisk
  84.   cd /usr/include
  85.   chmod 775 *
  86.   chmod 664 *.h
  87.   chmod 664 */*
  88.   cd /usr/g++-include
  89.   chmod 775 *
  90.   chmod 664 *.h
  91.   chmod 664 */*
  92.  
  93.   chmod 664 /usr/lib/gcc-lib/i386-linux/${VER}/*.?
  94.   chmod 664 /usr/lib/gcc-lib/i386-linux/${VER}/shared/*.?
  95. }
  96.  
  97. # check if it is a directory.
  98. checkdir ()
  99. {
  100.   if [ x${1}x = xx ]
  101.   then
  102.     echo No directory to check.
  103.     return 1
  104.   fi
  105.  
  106.   for f in $*
  107.   do
  108.     if [ ! -d $f ]; then
  109.       echo There is no such a directory, $f.
  110.       echo Please make sure there is one and it has right stuffs in it.
  111.       exit 1
  112.     fi
  113.   done
  114.   return 0
  115. }
  116.  
  117. checkbinfile ()
  118. {
  119.   for f in $*
  120.   do
  121.     if [ ! -f /bin/$f -a ! -f /usr/bin/$f ]; then
  122.       echo There is no such a file, $f.
  123.       return 1
  124.     fi
  125.   done
  126.   return 0
  127. }
  128.  
  129. checkfile ()
  130. {
  131.   if [ x${1}x = xx ]
  132.   then
  133.     echo No file to check.
  134.     return 1
  135.   fi
  136.  
  137.   for f in $*
  138.   do
  139.     if [ ! -f $f ]; then
  140.       echo There is no such a file, $f.
  141.       echo Please make sure there is one and it has right stuffs in it.
  142.       exit 1
  143.     fi
  144.   done
  145.   return 0
  146. }
  147.  
  148. checkroot ()
  149. {
  150.   uid=`id | sed -e 's/uid=\([0-9]*\)/\1/' -e 's/[^a-z0-9=].*//'`
  151.   if [ $? != 0 ]
  152.   then
  153.     echo Fail to get \"root\" id. You may need a working \"id\" and
  154.     echo \"sed\".
  155.     exit 1
  156.   fi
  157.  
  158.   if [ x${uid}x != x0x ]
  159.   then
  160.     echo You have to be root to run this script.
  161.     exit 1
  162.   fi
  163. }
  164.  
  165. usage ()
  166. {
  167.   echo Usage: sh $1 [-v] version {kernel src dir}
  168.   echo Note: \"sh\" must be zsh or bash.
  169.   exit 1
  170. }
  171.  
  172. checkroot
  173.  
  174. VERBOSE=no
  175.  
  176. if [ $# != 2 -a $# != 3 ]
  177. then
  178.   usage $0
  179. fi
  180.  
  181. case $1 in
  182. -v)
  183.   shift
  184.   set -x
  185.   VERBOSE=yes
  186.   ;;
  187. esac
  188.  
  189. if [ $# != 2 ]
  190. then
  191.   usage $0
  192. fi
  193.  
  194. VERSION=$1
  195. echo Installing gcc ${VERSION} ......
  196.  
  197. # kernel src dir
  198. KERNELSRCDIR=$2
  199.  
  200. #ln is not on rootdisk, let's use cp
  201. #LN="cp -s"
  202. #HDLN="cp -l"
  203. LN="ln -s"
  204. HDLN="ln"
  205. MV="mv -f"
  206. RM=/bin/rm
  207. PREFIX=/usr
  208. #LN="echo ln"
  209. #MV="echo mv"
  210. #PREFIX=/local
  211. LIBDIR=${PREFIX}/lib/gcc-lib/i386-linux/${VERSION}
  212. SHAREDLIBDIR=${LIBDIR}/shared
  213. JUMPLIBDIR=${LIBDIR}/jump
  214. SHIMAGEDIR=/lib
  215.  
  216. # change it by hand
  217. JUMP_VERSION=2
  218. JUMP_RELEASE=${JUMP_VERSION}.2
  219.  
  220. #create directories first
  221.  
  222. if [ -f $SHIMAGEDIR ]
  223. then
  224.   echo $SHIMAGEDIR should be directory. Remove it first!
  225.   exit 1
  226. fi
  227.  
  228. if [ ! -d $SHIMAGEDIR ]
  229. then
  230.   mkdir $SHIMAGEDIR
  231.  if [ $? != 0 ]
  232.  then
  233.    echo Unable to create directory: $SHIMAGEDIR. You may have to create
  234.    echo some paths in $SHIMAGEDIR first by hand.
  235.    exit 1
  236.   fi
  237. fi
  238.  
  239. echo gcc ${VERSION} will only work with a 387 or the kernel above 0.95.
  240. # ask if there is a 387.
  241. echo "Do you have a 387? [y/n] "
  242. read MATH
  243. if [ x${MATH}x = "xyx" ]
  244. then
  245.   MATH=hard
  246. else
  247.   MATH=soft
  248. fi
  249.  
  250. echo Check if we get the files.
  251. WORKDIR=`echo ${VERSION}*`
  252. if [ "${WORKDIR}" = "${VERSION}""*" ]
  253. then
  254.   echo No files to install. You need at least
  255.   echo 1. ${VERSION}misc.tar.Z
  256.   echo 2. ${VERSION}db.tar.Z
  257.   echo "3. ${VERSION}lib.tar.Z"
  258.   if [ ${VERSION} = 2.2.2d ]; then
  259.     echo "4. binutils.tar.Z"
  260.   else
  261.     echo "4. binutils.tar.Z (optional)"
  262.   fi
  263.   echo "5. xxxinc.tar.Z (header files also used by kernel source)"
  264.   exit 1
  265. fi
  266.  
  267. KERNELINC=`echo *inc.ta*`
  268. if [ "${KERNELINC}" = "*"inc.ta"*" ]
  269. then
  270.   echo You need xxxinc.tar.Z for the whole set of the header files
  271.   echo to use gcc ${VERSION}.
  272.   exit 1
  273. fi
  274.  
  275. echo Check ${VERSION}db.tar.Z and ${VERSION}misc.tar.Z
  276. checkfile ${VERSION}db.tar.Z ${VERSION}misc.tar.Z
  277.  
  278. # check those
  279. BINS="as86 ld86 ar as gprof ld nm objdump ranlib size strip"
  280. echo Check binaries.
  281. checkbinfile "${BINS}"
  282. if [ $? != 0 -o ${VERSION} = 2.2.2d ]
  283. then
  284.   checkfile binutils.tar.Z
  285. fi
  286.  
  287. LIBFILE=
  288.  
  289. # optional in gcc 2.2.2d. false.
  290. if [ ${VERSION} != xxxxxxx ]
  291. then
  292.   checkfile ${VERSION}lib.tar.Z
  293.   LIBFILE=${VERSION}lib.tar.Z
  294. else
  295.   # maybe it has gcc 2.2.2 file.
  296.   if [ -f 2.2.2lib.tar.Z ]; then
  297.     BBFILE=2.2.2lib.tar.Z
  298.   else
  299.     OLDLIBDIR=/usr/lib/gcc-lib/i386-linux/2.2.2
  300.     # it neens gcc 2.2.2d file.
  301.     if [ ! -d ${OLDLIBIR} ]; then
  302.       checkfile ${VERSION}lib.tar.Z
  303.       LIBFILE=${VERSION}lib.tar.Z
  304.     else
  305.       # can I use gcc 2.2.2
  306.       if [ ! -f ${OLDLIBDIR}/cc1 -o ! -f ${OLDLIBDIR}/cc1plus ]
  307.       then
  308.     checkfile ${VERSION}lib.tar.Z
  309.     LIBFILE=${VERSION}lib.tar.Z
  310.       fi
  311.     fi
  312.   fi
  313. fi
  314.  
  315. # double check the kernel sources
  316. checkdir $KERNELSRCDIR
  317. checkdir $KERNELSRCDIR/include/linux $KERNELSRCDIR/include/asm
  318.  
  319. WORKDIR=`pwd`
  320.  
  321. cd /usr
  322.  
  323. # optional
  324. if [ -f ${WORKDIR}/binutils.tar.Z ]
  325. then
  326.   echo installing binutils.tar.Z
  327. #  tar xvvofz ${WORKDIR}/binutils.tar.Z
  328.   zcat ${WORKDIR}/binutils.tar.Z | tar xvvof -
  329. fi
  330.  
  331. # optional
  332. if [ x${LIBFILE}x != xx ]
  333. then
  334.   echo installing ${LIBFILE}
  335. # tar xvvofz ${WORKDIR}/${LIBFILE}
  336.   zcat ${WORKDIR}/${LIBFILE} | tar xvvof -
  337. fi
  338.  
  339. echo installing ${VERSION}db.tar.Z.
  340. #tar xvvofz ${WORKDIR}/${VERSION}db.tar.Z
  341. zcat ${WORKDIR}/${VERSION}db.tar.Z | tar xvvof -
  342.  
  343. echo installing ${VERSION}misc.tar.Z.
  344. #tar xvvofz ${WORKDIR}/${VERSION}misc.tar.Z
  345. zcat ${WORKDIR}/${VERSION}misc.tar.Z | tar xvvof -
  346.  
  347. $RM -rf /usr/include/const.h /usr/include/asm /usr/include/linux
  348.  
  349. echo installing ${KERNELINC}
  350. #tar xvvofz ${WORKDIR}/${KERNELINC}
  351. zcat ${WORKDIR}/${KERNELINC} | tar xvvof -
  352.  
  353. $RM -rf /usr/include/sys/asy.h
  354.  
  355. if [ ${VERSION} = xxxxx ]
  356. then
  357.   if [ ! -f ${LIBDIR}/cc1 -o ! -f ${LIBDIR}/cc1plus ]
  358.   then
  359.     if [ x${OLDLIBDIR}x = xx ]
  360.     then
  361.       echo While installing gcc 2.2.2d, you don't have cc1/cc1plus
  362.       echo and you don't have gcc 2.2.2. This installation script is
  363.       echo wrong. Please use
  364.       echo "    sh $0 -v verson [kernel src dir]"
  365.       echo "    Note: \"sh\" must be zsh or bash."
  366.       echo to see what is wrong and report it to hlu@eecs.wsu.edu.
  367.       echo Thanks.
  368.       exit 1
  369.     else
  370.       $HDLN ${OLDLIBDIR}/cc1 ${OLDLIBDIR}/cc1plus ${LIBDIR}
  371.     fi
  372.   fi
  373. fi
  374.  
  375. #checkfile $LIBDIR/lib$MATH.a
  376. checkfile $LIBDIR/lib$MATH.a \
  377.     $LIBDIR/cpp $JUMPLIBDIR/libc.so.${JUMP_RELEASE} \
  378.     $JUMPLIBDIR/lib${MATH}.so.${JUMP_RELEASE}
  379.  
  380. # not used
  381. #    $SHAREDLIBDIR/libc.${VERSION} 
  382. #    $SHAREDLIBDIR/lib${MATH}.${VERSION}
  383.  
  384. if [ -f $SHIMAGEDIR/libc.${VERSION} -o -f $SHIMAGEDIR/libm.${VERSION} ]
  385. then
  386.   echo There is a libc.${VERSION} or libm.${VERSION} in $SHIMAGEDIR.
  387.   echo Do you want to deleted them? [y/n]
  388.   read answer
  389.   if [ x${answer}x = "xyx" ]
  390.   then
  391.     $RM -f $SHIMAGEDIR/libc.${VERSION} $SHIMAGEDIR/libm.${VERSION}
  392.   else
  393.     echo Give up.
  394.     exit 1
  395.   fi
  396. fi
  397.  
  398. if [ -f $SHIMAGEDIR/libc.so.${JUMP_RELEASE} -o -f $SHIMAGEDIR/libm.so.${JUMP_RELEASE} ]
  399. then
  400.   echo There is a libc.so.${JUMP_RELEASE} or libm.so.${JUMP_RELEASE} in $SHIMAGEDIR.
  401.   echo Do you want to deleted them? [y/n]
  402.   read answer
  403.   if [ x${answer}x = "xyx" ]; then
  404.     $RM -f $SHIMAGEDIR/libc.so.${JUMP_RELEASE} $SHIMAGEDIR/libm.so.${JUMP_RELEASE}
  405.   else
  406.     echo Give up.
  407.     exit 1
  408.   fi
  409. fi
  410.  
  411. #echo moving the shared image.
  412. #$MV $SHAREDLIBDIR/libc.${VERSION} $SHIMAGEDIR
  413. #$MV $SHAREDLIBDIR/lib${MATH}.${VERSION} $SHIMAGEDIR/libm.${VERSION}
  414.  
  415. $RM -f $LIBDIR/libm.a $SHAREDLIBDIR/libm.a
  416. $HDLN $LIBDIR/lib$MATH.a $LIBDIR/libm.a
  417. checkreturn "$HDLN $LIBDIR/lib$MATH.a $LIBDIR/libm.a"
  418.  
  419. #$HDLN $SHAREDLIBDIR/lib$MATH.a $SHAREDLIBDIR/libm.a
  420. #checkreturn "$HDLN $SHAREDLIBDIR/lib$MATH.a $SHAREDLIBDIR/libm.a"
  421.  
  422. echo install jump table.
  423. jumptable $JUMPLIBDIR $JUMP_VERSION $JUMP_RELEASE $MATH
  424.  
  425. $RM -rf /usr/lib/cpp /lib/cpp
  426.  
  427. $LN $LIBDIR/cpp /usr/lib/cpp
  428. checkreturn "$LN $LIBDIR/cpp /usr/lib/cpp"
  429. $LN $LIBDIR/cpp /lib/cpp
  430. checkreturn "$LN $LIBDIR/cpp /lib/cpp"
  431.  
  432. if [ -f /usr/include/stddef.h -o -f /usr/include/stdarg.h ]
  433. then
  434.   echo The version-dependent stddef.h and stdarg.h should not be in
  435.   echo /usr/include. Please take a look at
  436.   echo "    /usr/lib/gcc-lib/i386-linux/${VERSION}/include"
  437.   exit 1
  438. fi
  439.  
  440. if [ ! -f /usr/include/time.h ]
  441. then
  442.   echo You have to install xxxxinc.tar.Z first!
  443.   exit 1
  444. fi
  445.  
  446. echo "Do you have kernel source on line? [y/n] "
  447. read MATH
  448. if [ $MATH = "n" ]
  449. then
  450.    echo Oops. gcc ${VERSION} needs at least the header files from
  451.    echo the kernel source, i.e. linux/include/linux.
  452.    exit 1
  453. fi
  454.  
  455. echo Ignore the error message.
  456.  
  457. $RM -rf ${KERNELSRCDIR}/include/*.h  ${KERNELSRCDIR}/include/sys
  458. if [ -f ${KERNELSRCDIR}/include/a.out.h ]
  459. then
  460.   echo 'Fail to clean ${KERNELSRCDIR}/include/*.h and'
  461.   echo '${KERNELSRCDIR}/include/sys.'
  462.   exit 1
  463. fi
  464.  
  465. checkdir ${KERNELSRCDIR}/include/asm ${KERNELSRCDIR}/include/linux
  466.  
  467. kernelstuff $WORKDIR $KERNELSRCDIR
  468.  
  469. $LN  ${KERNELSRCDIR}/include/asm /usr/include
  470. if [ $? != 0 ]
  471. then
  472.    echo Fail to make a link from ${KERNELSRCDIR}/include/asm to
  473.    echo /usr/include/asm.
  474.    exit 1
  475. fi
  476.  
  477. $LN ${KERNELSRCDIR}/include/linux /usr/include
  478. if [ $? != 0 ]
  479. then
  480.    echo Fail to make a link from ${KERNELSRCDIR}/include/linux to
  481.    echo /usr/include/linux.
  482.    exit 1
  483. fi
  484.  
  485. echo No more error messages.
  486.  
  487. echo Fixing the files.
  488. fixfiles ${VERBOSE} ${VERSION} "${BINS}"
  489.  
  490. # for future use
  491. # gcc -V 2.xxx will read this file.
  492. cd $LIBDIR
  493. chmod 755 /usr/bin/gcc
  494. /usr/bin/gcc -dumpspecs > specs
  495.  
  496. if [ $? != 0 ]
  497. then
  498.   echo Error during the installation of gcc ${VERSION}
  499.   exit 1
  500. fi
  501.  
  502. echo Done! gcc ${VERSION} has been installed.
  503. echo Please get rid of all the \"-nostdinc -I\" from Makefiles in
  504. echo kernel source and then do a fresh "make dep".
  505.  
  506.