From: wweston@steer.sdsu.edu (stewart k)
Subject: (none)
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 14 Apr 1992 14:57:58 GMT

Gnu,
	This file is mail to two professors at SDSU on the status of
installing gcc-2.1 ( at this point we need bison updated first ).  I thought 
it might be of some help to novices as an example of a bison installation.
	The docs for gcc-2.1 say you'll have a problem installing gcc when
you have an old bison when c-parse.c gets compiled; they're right.  I've
installed bison-1.16 as far as I can go.  I need Ron to do the rest.
	I have screen dumps of the whole process which reveal some of the
problems installing gnu stuff with the solutions.

PROCEDURE FOR INSTALLING GNU BISON ON THE SDSU ELXSI:

	===============================================================
	1. Download the latest bison form mit at ftp prep.ai.mit.edu in
	   /pub/gnu.
	===============================================================

% ls -l
-rw-------  1 wweston    308684 Apr 14 19:46 bison-1.16.tar.Z
% pwd
/g88-tmp/bison

	===============================================================
	2. Decompress and detar the file.
	===============================================================

% zcat bison-1.16.tar.Z | tar -xvf -
x bison-1.16/COPYING, 17982 bytes, 36 tape blocks
		  .
		  .
		  .
x bison-1.16/alloca.c, 5233 bytes, 11 tape blocks

% ls
bison-1.16              bison-1.16.tar.Z
% cd bison-1.16

	===============================================================
	3. As described in the file README, run configure.
	===============================================================

% configure
checking for gcc
checking for install
checking for POSIXized ISC
checking for ANSI C header files
checking for BSD string and memory functions
checking for strerror
checking for alloca
checking for Minix
creating ./Makefile
creating config.status

	===============================================================
	4. Run make.
	===============================================================

% make
gcc -O -g -DSTRERROR_MISSING -c LR0.c
cc1: Invalid option `-g'
*** Exit 1
Stop.

	===============================================================
	 The problem here is that our out-of-date gcc doesn't have the -g
	 ( optimize ) option.  I removed the -g options in Makefile.
	===============================================================

% vi Makefile
CDEBUG = -g                                <==== here
CFLAGS = $(CDEBUG) $(DEFS)                 
LDFLAGS = -g                               <==== and here

	===============================================================
	Ran make again:
	===============================================================

gcc -O  -DSTRERROR_MISSING -c LR0.c
gcc -O  -DSTRERROR_MISSING -c allocate.c
gcc -O  -DSTRERROR_MISSING -c closure.c
gcc -O  -DSTRERROR_MISSING -c conflicts.c
/usr/local/bin/gcc35: Program cc1 got fatal signal 11.
*** Exit 1
Stop.

	===============================================================
	Wow! A bug in our gcc???  Well, now we must use cc instead of gcc;
	so might as well put -g compiler option back in.
	===============================================================


CC = cc -O

CDEBUG = -g
CFLAGS = $(CDEBUG) $(DEFS)       
LDFLAGS = 

	===============================================================
	Run make again:
	===============================================================

cc -O -g  -DSTRERROR_MISSING -c conflicts.c
			.
			.
			.
cc -O -g  -DSTRERROR_MISSING -c getopt.c
"getopt.c", line 458: illegal comparison of enums
"getopt.c", line 479: warning: enumeration type clash, operator ==
*** Exit 2
Stop.

	===============================================================
	What the hell now?  In getopt.h,  struct option has an enum field
	and in getopt.c this field is compared to 0, 1 etc.  I changed the
	enum field in struct option in getopt.h to an int and defined the
	enum values 0, 1, and 2.
	===============================================================

% vi getopt.h

#define no_argument 0                      <=== new lines added
#define required_argument 1
#define optional_argument 2

struct option
{
#ifdef __STDC__   
   const char *name;  c
#else
   char *name;  c
#endif
enum                     < -
 {                          |
   no_argument,             | all this goes to "int has_arg;"
   required_argument,       |
   optional_argument        |
  }has_arg;              < - 
}

	===============================================================
	Run make again:
	===============================================================

cc -O -g  -DSTRERROR_MISSING -c getopt.c
cc -O -g  -DSTRERROR_MISSING -c getopt1.c
cc -O  -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o         getargs.o gram.o lalr.o lex.o                                   main.o nullable.o output.o print.o reader.o reduce.o symtab.o   warshall.o version.o                                            getopt.o getopt1.o  
ld: Symbol xmalloc in /lib/libc.a is multiply defined. First defined in allocate.o
ld fatal: Error(s). No output written to bison
*** Exit 1
Stop.

	===============================================================
	It looks like xmalloc is in cc's libe!  Solution is to re-define 
	xmalloc using cc's -D option.   Edit Makefile's cc flags adding
	"-Dxmalloc=xxmalloc" to "clean up" the source files.
	===============================================================

% vi Makefile

	===============================================================
	Run make again:
	===============================================================

cc -O  -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o         getargs.o gram.o lalr.o lex.o                                   main.o nullable.o output.o print.o reader.o reduce.o symtab.o   warshall.o version.o                                            getopt.o getopt1.o  
ld: Symbol xmalloc in /lib/libc.a is multiply defined. First defined in allocate.o
ld fatal: Error(s). No output written to bison
*** Exit 1
Stop.

	===============================================================
	Aha; need to delete all object files to get all of xmalloc.  'need
	to do this anyway after mixing compilers.
	===============================================================

% rm *.o
% make
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c LR0.c
			.
			.
			.
cc -O  -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o         getargs.o gram.o lalr.o lex.o                                   main.o nullable.o output.o print.o reader.o reduce.o symtab.o   warshall.o version.o                                            getopt.o getopt1.o  
makeinfo bison.texinfo
Make: Cannot load makeinfo.  Stop.
*** Exit 1
Stop.

	===============================================================
	Take a look at Makefile for makeinfo:
	===============================================================

% vi Makefile

bison.info: bison.texinfo
	makeinfo bison.texinfo

	===============================================================
	Huh.  There's no man entry; it's not in mit's gnu.  Commented out
	these two lines!!!!

	One final make:
	===============================================================

% rm *.o
% make
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c LR0.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c allocate.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c closure.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c conflicts.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c derives.c
cc -O -c -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -DXPFILE=\"/usr/local/lib/bison.simple\"  -DXPFILE1=\"/usr/local/lib/bison.hairy\" files.c 
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c getargs.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c gram.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c lalr.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c lex.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c main.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c nullable.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c output.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c print.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c reader.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c reduce.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c symtab.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c warshall.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c version.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c getopt.c
cc -O -g -Dxmalloc=xxmalloc -DSTRERROR_MISSING -c getopt1.c
cc -O  -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o         getargs.o gram.o lalr.o lex.o                                   main.o nullable.o output.o print.o reader.o reduce.o symtab.o   warshall.o version.o                                            getopt.o getopt1.o  

	===============================================================
	Success!  or the illusion of it.

	Now you run "make install"
		    "make clean"
	That's it.
	===============================================================

% make install
/usr/bin/install -c bison /usr/local/bin
cp: /usr/local/bin/bison: Read-only file system
chgrp: staff: unknown group
cd /usr/local/lib; rm -f bison.simple bison.hairy
awk -f ./mergedir.awk dir=/usr/local/lib ./bison.simple > /usr/local/lib/bison.simple
sh: /usr/local/lib/bison.simple: cannot create
*** Exit 1
Stop.
% xxx make clean
xxx: Command not found.

	===============================================================
	We need Ron to do these last parts above.
	===============================================================

	Don't work so hard; you'll lose your sense of humor.
						wes
.


Newsgroups: gnu.gcc.bug