GRASS on Linux prob

Hello Jehng-Jung Kao,

I'm am not a very knowledgeable GRASS or Linux or C or YACC or LEX person,
but I hope to be of some help in some way. Others on the list are much
more knowledgeable and much more experienced than I am.

In addition to being stupid, I mail from a stupid IBM-mini. The
EBCDIC ==> ASCII or the ASCII ==> EBCDIC translation messes up several
characters in the C language: left and right brackets and the 'or'
symbol. You might have to change a few characters in my examples....

Incidentally, I noticed in your gmake capture file that you turn on
optimization with the -O2 flag. I have found that using the "-m486"
compiler flag in linux/gcc, along with -O2, produces faster code
on my 486/66 in some of my tests. The -O2 -m486 combo seemed to produce
the fastest code.

Hi, we just tried to re-compile Grass4.1 on Linux Slackware.
Everything is ok except the following programs:

GISGEN: src/raster/r.binfer - Tue Jul 5 16:45:08 CST 1994
GISGEN: src/raster/r.combine - Tue Jul 5 16:58:13 CST 1994

We will appreciate very much for suggestions/hints/solutions
to resolve the problem for compiling these two modules.

......

-------- error 1 --------------------------------

GISGEN: src/raster/r.binfer - Tue Jul 5 16:45:08 CST 1994

#################################################################
/usr/local/grass4.1/source/src/raster/r.binfer
mkdir OBJ.i486
make -f OBJ.i486/make.rules

......

OBJ.i486/main.o: Undefined symbol _yylineno referenced from text segment
make: *** [/usr/local/grass4.1/source/etc/bin/main/cmd/r.binfer] Error 1
GISGEN failure at STEP: src/raster/r.binfer

The problem in r.binfer is the use of the undocumented "yylineno". For more
information on "yylineno" and how to get around it, see the FLEX Programmer's
Manual.

The easiest fix is simply to comment out the printf( ) statement that
references yylineno in src/raster/r.binfer/main.c

In my humble opinion, the use of "yylineno" should be avoided in GRASS.
A simple fix that prints an approx of yylineno might look something like:

src/raster/r.binfer/binfer.l

Since Flex does not have yylineno variable, add a line number variable that
approximates yylineno.

   ----------------------- binfer.l -----------------------

%{

int mylineno = 1; <======== add "mylineno"

#ifdef DEBUG
...
...
%}

letter (a-zA-Z) <======== parens should be brackets,
digit (0-9) <======== that darn ibm ebcdic prob...
letter_or_digit (a-zA-Z0-9_.)
white_space ( \t) <========= take \n out
new_line (\n) <========= create a new_line thing
blank ( \t)
other .

...
...
...

{white_space}+ ;

{new_line} { ++mylineno; } <====== add rule for new_line

...

       ------------------------ main.c ----------------------
....

#include <stdio.h>
#include "symtab.h"
extern int mylineno; <====== change yylineno to mylineno

....

yyerror(s)
char *s;
{
    fprintf( ... ,s,mylineno,yytext); <======= change yylineno to mylineno
    exit(0);
}

-------- error 2 --------------------------------

GISGEN: src/raster/r.combine - Tue Jul 5 16:58:13 CST 1994

#################################################################
/usr/local/grass4.1/source/src/raster/r.combine
mkdir OBJ.i486
make -f OBJ.i486/make.rules

/usr/local/bin/gmake4.1 -all
#################################################################
/usr/local/grass4.1/source/src/raster/r.combine/cmd
mkdir OBJ.i486
make -f OBJ.i486/make.rules

...

OBJ.i486/gis_lxcl.o: Undefined symbol _yyinput referenced from text segment
make[1]: *** [/usr/local/grass4.1/source/etc/r.combine] Error 1

The problem with this, I think, is that AT&T lex defines yyinput( )
as a macro. This problem is easily fixed. I try to do my fixes in a
portable manner so that my changes do not break in other unices:

src/raster/r.combine/gis_lxcl.l

  ------------------------- gis_lxcl.l ----------------------
%{
#include "gis_pars.h"
#ifdef getc
#undef getc
#endif
#define getc mygetc

#ifdef FLEX_SCANNER <====== check for FLEX signature
#undef yywrap <====== undefine yywrap in FLEX
int yyinput(void) { return input( ); } <====== define yyinput for FLEX
#endif

extern FILE *e_sav_fil ;
FILE *newinput ;
%}

For more information and reference see:

     John R. Levine, Tony Mason, and Doug Brown, _lex & yacc_, O'Reilly &
       Associates, Inc., Sebastopol, California, 1992, ISBN 1-56592-000-7,
       pages 160-161 and 174.

Hope this helps,
Frank Davis
USDA-ARS, Tifton, Ga
fmd@tifton.cpes.peachnet.edu