Need smart makefile for lex&yacc

Need smart makefile for lex&yacc

Post by John K. Harri » Sun, 24 Mar 1996 04:00:00



Hi,

Could someone help out with what I'm sure must be a very common problem
with lex & yacc?

I want my makefile to be smart enough so that it doesn't rebuild things
dependent on y.tab.h (such as lex.yy.c) if the file that was generated
did not change since the last time it was generated.

My first stab at this was to make the y.tab.h file by generating it
first as __junk.fil and comparing and moving that to y.tab.h only if it
was different or y.tab.h didn't exist.

This works fine except for one thing:  When there is really nothing to
be remade (everything is up to date), the y.tab.h file is sitting there,
older than the yacc file, and my makefile _always_ regenerates
__junk.fil, finding that it didn't really need to because it hadn't
changed.

It's a minor nuisance (people shouldn't be in the habit of doing "make"
if everything's up-to-date), but it pisses me off that, for the life of
me, I can't think of a way to make it work perfectly right.

I need some help, man.

thanks in advance,

Here's the makefile:
--------------------------------------------------------------------
# Programs to build.
programs = PA1631SXSMCR5.2

# Makefile.
MAKEFILE = Makefile

# Installation subdirectory
INSTALLSUBDIR = NE1631SXSMCR5.2

# Sources.
SRCS =                                          \
        PA1631SXSMCR5.2.C                       \
        proxy_main.C                            \
        Spmd.C                                  \
        OFMigrate.C                             \
        EventSender.C                           \
        lib_interface.C                         \
        NEcoma.C                                \
        buffer_man.C                            \
        buildfdn.C                              \
        cmis.C                                  \
        intent_interpreter_1631r5smc.C          \
        intent_interpreter_NE.C                 \
        makemib_1631r5smc.C                     \
        ne_common.C                             \
        pducoda.C                               \
        pdudeca.C                               \
        scrobj.C                                \
        scrutil_1631r5smc.C                     \
        tablesNE.C                              \
        tl1obj.C                                \
        unit_of_work_1631r5smc.C                \
        unit_of_work_NE.C                       \
        unit_of_work_common.C                   \
        LGRequest.C                             \
        LGDe*.C                            \
        LGComm.C                                \
        LGUtil.C                                \
        LGMobj.C                                \
        LGInstCache.C                           \
        LGEqptCache.C                           \
        ParseUtil.C

# Headers.
HDRS =

OBJS =  $(SRCS:.C=.o)   \
        poll.o tl1yacc_1631r5smc.o tl1lex_1631r5smc.o

all: $(programs)

# Dependencies.
PA1631SXSMCR5.2 : $(OBJS)

poll.o libapli.a libasn.a libstr.a:
        cvs update poll.o libapli.a libasn.a libstr.a

tl1lex_1631r5smc.o : tl1lex_1631r5smc.C y.tab.h
tl1yacc_1631r5smc.o : ParseUtil.h

ParseUtil.o: y.tab.h

tl1lex_1631r5smc.C: tl1lex_1631r5smc.l y.tab.h

        LANG=C; export LANG; lex tl1lex_1631r5smc.l && \

        rm lex.yy.c ;)

tl1yacc_1631r5smc.C : tl1yacc_1631r5smc.y


y.tab.h: tl1yacc_1631r5smc.y

        bison -d -p Neyy --output-file=__junk.fil $< && \



# Packages we need.
USECFOFLIB = true
USECFSMAPI = true
USEOS           = true
USEFLEX = true
USECLSPR        = true
USECLSPRNE1631SXSMCR5_2 = true

# Just clean programs.
CLEANPROGRAMLIST = $(programs)

# Other things to clean.
XCLEAN =                                        \
        lex.yy.c                                \
        tl1lex_1631r5smc.C                      \
        tl1yacc_1631r5smc.C                     \
        y.tab.h                                 \
        tl1yacc_1631r5smc.C.output

# Other things to clean-all.
XCLEANALL = $(XCLEAN) $(programs)

# Install these.
install:: $(programs)
        $(INSTALL) -m 555 $(programs) $(INSTALLDIR)/$(INSTALLSUBDIR)/bin

include $(BUILDTOP)/include/NM1320makefile

 
 
 

1. Need makefile help: SCCS/Yacc/Lex

I need a sample makefile that can process a SCCS'ed Yacc file, a
SCCS'ed Lex file, and some SCCS'ed C files into one object file.

Anybody have such a thing?

Here's the makefile that I was using <before> I SCCS'ed everything:

OBJECTS=y.tab.o lex.yy.o file1.o file2.o
LIBES=-ll -ly
CFLAGS=-g

final:  $(OBJECTS)
        cc $(CFLAGS) $(OBJECTS) $(LIBES) -o final

y.tab.c:        final.y
        yacc -dv final.y

lex.yy.c:       final.l
        lex final.l

clean:
        rm final.o y.tab.[hc] lex.yy.c

Now, after SCCS'ing the files, it says that it can't make "final.l".

Any help would be appreciated.

car.
--
Christopher A. Rende           Central Cartage (Nixdorf/Pyramid/SysVR2/BSD4.3)
uunet!edsews!rphroy!trux!car   Multics,DTSS,Unix,Shortwave,Scanners,UnixPC/3B1

trux!ramecs!car     "I don't ever remember forgetting anything." - Chris Rende

2. Linux network collision, slow traffic

3. Where can I get origianl AT&T lex & yacc source?

4. finding my port number

5. Wanted - additional tutorials & documentation on Lex & Yacc

6. Dislabel problems!!

7. YACC & LEX under Microsoft Windows

8. UUDECODE (END)

9. The Lex & Yacc source code for C++

10. LEX/YACC & Imake

11. Need help with lex and yacc

12. YACC/LEX parsing help needed ../

13. Copmiling w/gcc under Solaris 2.3 (w/lex & yacc)