problem with bison

Satish Balay balay at mcs.anl.gov
Fri Jul 18 08:49:22 CDT 2008


On Fri, 18 Jul 2008, Nicolas Flipo wrote:

> Hi Satish,
> 
> Thanks for your quick answer but I don't manage to make it works
> because I don't have enough expertise with makefiles.
> 
> Thus here is the Makefile of my initial problem (sorry I just saw that
> I forgot to include the last lines concerning the .y.o in my first
> message):
> 
> PROGRAMME= program
> SOURCES.c = verouille.c \
> 	hydraulique.c debug.c flux_apport.c init_hyd.c\
> 	adv_bott.c adv_decentre.c transport.c dispersion.c adv_caract.c pk.c  \
> 	reaere.c tubes.c rayons.c traceur.c \
> 	bact_nit.c timing.c GMcatch_main.c sortie.c verification_basin.c
> output_basin.c messages.c surf-zns.c  \
> 	phyto.c oxygene.c element_nut.c zoo.c bact.c\
> 	geometrie.c calculs_courants.c\
> 	maillage.c init.c  biologie.c\
> 	matrice.c
> 
> SOURCES.l = lexique.l
> 
> SOURCES.y = newent.y
> 
> SOURCES.h = parametres.h structurs.h var_globals.h functions.h
> 
> CFLAGS_GLOBAUX= -g -Wall -DYYDEBUG
> 
> CFLAGS= $(CFLAGS_GLOBAUX)
> 
> YACC= bison -y
> LEX= flex
> YFLAGS= -dv
> LFLAGS= -v
> 
> CC=gcc
> 
> OBJ= $(SOURCES.y:.y=.o) $(SOURCES.l:.l=.o) $(SOURCES.c:.c=.o)
> 
> CLEANFILES = $(OBJ) core y.*
> 
> include ${PETSC_DIR}/bmake/common/base
> 
> $(PROGRAMME) : $(OBJ) chkopts
> 	-$(CLINKER) -o $(PROGRAMME) $(OBJ) ${PETSC_KSP_LIB}
> .y.o :
> 	$(YACC.y) $<
> 	$(COMPILE.c) -o $@ y.tab.c
> 
> giving this error
> 
> [user at horsdeprix ]$ make program
> In file included from newent.y:166:
> var_globals.h:8:35: petscksp.h : File or folder not found
> 
> I then tried to replace the target .y.o by a .y.c one. I erased the
> target .y.o and replace it by what you said:
> 
> .y.c :
> 	$(YACC.y) $<
> 
> what led to the following error
> 
> [user at horsdeprix ]$ make program
> bison -y -dv  newent.y
> mpicxx -o newent.o -c -Wall -Wwrite-strings -Wno-strict-aliasing -g -g
> -Wall -DYYDEBUG -I/usr/local/PETSc/petsc-2.3.3-p13
> -I/usr/local/PETSc/petsc-2.3.3-p13/bmake/linux-gnu-c-debug
> -I/usr/local/PETSc/petsc-2.3.3-p13/include -I. -I/usr/local/include
> -I/usr/local/include -I/usr/X11R6/include -D__SDIR__="" newent.c
> c++: newent.c : No files or folder of this type
> c++: pas de fichier à  l'entrÃ(c)e
> make: *** [newent.o] Erreur 1
> 
> The thing is that bison -y -dv  newent.y creates three files called
> y.tab.c y.tab.h and y.output

You porbably have to:

bison newent.y -o newent.c

[I don't know if you need the -y -dv options]. So the target can probably be:

.y.c :
      $(YACC.y) $< -o $*.c

Satish


> 
> If I don't set the -y option I gonna also have three files called
> newent.tab.c newent.tab.h and newent.output
> 
> And I don't know how to force the makefile to take y.tab.c and y.tab.h
> instead of newent.c which does not exist. Maybe it comes from the
> lines
> 
> OBJ= $(SOURCES.y:.y=.o) $(SOURCES.l:.l=.o) $(SOURCES.c:.c=.o)
> 
> and
> 
> $(PROGRAMME) : $(OBJ) chkopts
> 	-$(CLINKER) -o $(PROGRAMME) $(OBJ) ${PETSC_KSP_LIB}
> 
> Maybe I also have to include the .tab.h at one point of the compiling process.
> 
> Thanks for your help
> Nico
> 
> 
> On Thu, Jul 17, 2008 at 9:00 PM, Satish Balay <balay at mcs.anl.gov> wrote:
> > What I mean by not having the correct make targets is:
> >
> > PETSc provides a make target for compiling .c files into .o files. i.e
> >
> > .c.o:
> >        ${CC} -c -I${PETSC_DIR} -I ${PETSC_DIR}/include $<
> >
> > However when your sourcefile is .y - and not .c, make is using a .y.o
> > target such as:
> >
> > .y.o:
> >        ${YACC} $<
> >        ${CC} -c ${CFLAGS} -o $*.o y.tab.c
> >
> >
> > This '.y.o:' target might be internal to make. So I was speculating
> > that becuase this other target is used to create .y.o - instead of the
> > '.c.o' from PETSc - the compile is failing.
> >
> > I was sugesting - perhaps you can add a '.y.c' target in your makefile
> > - this way make uses .y -> .c and .c -> .o targets [instead of .y->.o
> > target]
> >
> > .y.c:
> >        ${YACC} $<
> >
> >
> > [or whatever the correct syntax for invoking yacc to convert foo.y to foo.c is]
> >
> > Satish
> >
> > On Thu, 17 Jul 2008, Nicolas Flipo wrote:
> >
> >> Hi Satish,
> >>
> >> I'm not sure to understand exactly what you mean.
> >
> >> The last thing is that I don't understand why include
> >> ${PETSC_DIR}/bmake/common/base doesn't work for bison?
> >> Nico
> >
> >> On Thu, Jul 17, 2008 at 9:40 AM, Satish Balay <balay at mcs.anl.gov> wrote:
> >> > Hmm - perhaps you need to specify a '.y.c:' target in your makefile?
> >> >
> >> > It loks like make is using a '.y.o:' target - thus skipping '.c.o:'
> >> > target as defined in PETSc makefiles.
> >> >
> >> >> gcc -g -Wall -DYYDEBUG    -c -o newent.o y.tab.c
> >> >
> >> > If PETSc target for .c file is used - you should see
> >> > -I$PETSC_DIR/include etc options aswell.
> >> >
> >> > Satish
> >
> >
> 
> 
> 
> 


More information about the petsc-users mailing list