[GRASS5] G57 compile errors in r.mapcalc

Hello,

I have had problems building r.mapcalc, seems to be related to the y.tab.c target. I am not sure if this is related to G53 or G57? I am compiling on a Mac G5.

Output from make:
bison -y -b OBJ.powerpc-apple-darwin7.3.0/y -d mapcalc.y
bison: OBJ.powerpc-apple-darwin7.3.0/y.tab.c: No such file or directory
bison: fclose: Bad file descriptor
<snip>

The line: bison: fclose: Bad file descriptor would go on for thousands of lines, and then crash.

It appears that y.tab.c was to be placed into the OBJ dir, but the OBJ dir was not yet created. Also, it doesn't seem like y.tab.c should be place into the OBJ dir at all.

So I changed:

y.tab.c y.tab.h: mapcalc.y
         $(YACC) -b $(OBJDIR)/y -d mapcalc.y
         $(MKDIR) $(OBJDIR)
         $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c $*.c

to:

y.tab.c y.tab.h: mapcalc.y
         $(MKDIR) $(OBJDIR)
         $(YACC) -b y -d mapcalc.y
         $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c $*.c

And it works for me.

Craig

On Fri, May 21, 2004 at 10:17:21AM -0600, Funkmeister wrote:

Hello,

I have had problems building r.mapcalc, seems to be related to the
y.tab.c target. I am not sure if this is related to G53 or G57? I am
compiling on a Mac G5.

Output from make:
bison -y -b OBJ.powerpc-apple-darwin7.3.0/y -d mapcalc.y
bison: OBJ.powerpc-apple-darwin7.3.0/y.tab.c: No such file or directory
bison: fclose: Bad file descriptor
bison: fclose: Bad file descriptor
bison: fclose: Bad file descriptor
<snip>

The line: bison: fclose: Bad file descriptor would go on for thousands
of lines, and then crash.

It appears that y.tab.c was to be placed into the OBJ dir, but the OBJ
dir was not yet created. Also, it doesn't seem like y.tab.c should be
place into the OBJ dir at all.

So I changed:

y.tab.c y.tab.h: mapcalc.y
        $(YACC) -b $(OBJDIR)/y -d mapcalc.y
        $(MKDIR) $(OBJDIR)
        $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c
$*.c

to:

y.tab.c y.tab.h: mapcalc.y
        $(MKDIR) $(OBJDIR)
        $(YACC) -b y -d mapcalc.y
        $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c
$*.c

And it works for me.

Thanks,

I have submitted a similar change. Please try again.
(Anyone knowing more about this may teach me...).

Markus

Markus Neteler wrote:

> It appears that y.tab.c was to be placed into the OBJ dir, but the OBJ
> dir was not yet created. Also, it doesn't seem like y.tab.c should be
> place into the OBJ dir at all.
>
> So I changed:
>
> y.tab.c y.tab.h: mapcalc.y
> $(YACC) -b $(OBJDIR)/y -d mapcalc.y
> $(MKDIR) $(OBJDIR)
> $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c
> $*.c
>
> to:
>
> y.tab.c y.tab.h: mapcalc.y
> $(MKDIR) $(OBJDIR)
> $(YACC) -b y -d mapcalc.y
> $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c
> $*.c
>
> And it works for me.

I have submitted a similar change. Please try again.
(Anyone knowing more about this may teach me...).

OK; the original rule was:

y.tab.c y.tab.h: mapcalc.y
  $(YACC) -d mapcalc.y
  \mkdir -p $(OBJDIR)
  $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c $*.c

This was changed to put y.tab.[ch] into $(OBJDIR):

y.tab.c y.tab.h: mapcalc.y
  $(YACC) -b $(OBJDIR)/y -d mapcalc.y
  $(MKDIR) $(OBJDIR)
  $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c $*.c

This won't work because:

a) the rule's targets are y.tab.c and y.tab.h, but it's actually
creating $(OBJDIR)/y.tab.c and $(OBJDIR)/y.tab.h.

b) The compilation command is still compiling y.tab.c, not
$(OBJDIR)/y.tab.c, and there don't appear to be any compiler switches
to force the compiler to look in $(OBJDIR) for y.tab.h.

c) $(OBJDIR) isn't created until after $(YACC) has been told to put
its output files there.

In Funkmeister's case, the new Makefile was creating the new
y.tab.[ch] files (based upon the new mapcalc.y, which was changed to
support r3.mapcalc) in a different directory, then using the old
y.tab.[ch] (left over from a previous build) instead.

So, as Funkmeister noted, you essentially need to revert the changes:

y.tab.c y.tab.h: mapcalc.y
        $(MKDIR) $(OBJDIR)
        $(YACC) -b y -d mapcalc.y
        $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c $*.c

This is almost identical to the original version, except that \mkdir
is replaced with $(MKDIR), and becomes the first command.

--
Glynn Clements <glynn.clements@virgin.net>

On Mon, May 24, 2004 at 05:04:14PM +0100, Glynn Clements wrote:

Markus Neteler wrote:

> > It appears that y.tab.c was to be placed into the OBJ dir, but the OBJ
> > dir was not yet created. Also, it doesn't seem like y.tab.c should be
> > place into the OBJ dir at all.

[...]

OK; the original rule was:

y.tab.c y.tab.h: mapcalc.y
  $(YACC) -d mapcalc.y
  \mkdir -p $(OBJDIR)
  $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c $*.c

This was changed to put y.tab.[ch] into $(OBJDIR):

y.tab.c y.tab.h: mapcalc.y
  $(YACC) -b $(OBJDIR)/y -d mapcalc.y
  $(MKDIR) $(OBJDIR)
  $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c $*.c

This won't work because:

a) the rule's targets are y.tab.c and y.tab.h, but it's actually
creating $(OBJDIR)/y.tab.c and $(OBJDIR)/y.tab.h.

b) The compilation command is still compiling y.tab.c, not
$(OBJDIR)/y.tab.c, and there don't appear to be any compiler switches
to force the compiler to look in $(OBJDIR) for y.tab.h.

c) $(OBJDIR) isn't created until after $(YACC) has been told to put
its output files there.

In Funkmeister's case, the new Makefile was creating the new
y.tab.[ch] files (based upon the new mapcalc.y, which was changed to
support r3.mapcalc) in a different directory, then using the old
y.tab.[ch] (left over from a previous build) instead.

Ok, now I get the point.

So, as Funkmeister noted, you essentially need to revert the changes:

y.tab.c y.tab.h: mapcalc.y
        $(MKDIR) $(OBJDIR)
        $(YACC) -b y -d mapcalc.y
        $(CC) $(LDFLAGS) $(INC) $(XTRA_LDFLAGS) -o $(OBJDIR)/$*.o -c $*.c

This is almost identical to the original version, except that \mkdir
is replaced with $(MKDIR), and becomes the first command.

Done in CVS, thanks!

Markus