help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Handling code generators


From: Sankaranarayanan K V
Subject: Handling code generators
Date: Tue, 5 Dec 2000 19:03:01 +0530
User-agent: Mutt/1.2.5i

Hi,

Consider a code generator which takes a file named 'a.spec' and
generates a set of source files say 'Foo.cc', 'Bar.cc', etc.

The names of the generated files cannot be predicted from the name of
the spec file. (That means, it _may_ not be possible to use any pattern
rules to relate the generated code files and the spec file.)

The number of generated files is not fixed. It depends on the contents
of the spec file.

All the generated sources need to be compiled and built into a library.

In this situation, how do I set up the dependencies?
And how do I get the sources built?

I thought of the following solutions -- but none of them are elegant.

(1) Create a directory a.spec.dir for the spec file a.spec.
    Generate all files for a.spec in that directory.
    Write Makefiles for such directories to build the generated files.

    I can set up the dependency 
    
      a.spec.dir : a.spec

    _or_

      %.spec.dir: %.spec

   Somehow, this is not appealing to me as I need to create directories
   in the version control system for each spec file.
   Further, I need to put Makefiles to compile the generated stuff as
   well in the spec.dir directories.

(2) Have a wrapper script over the code generator create the directory
    a.spec.dir and put all the generated files there.
    Use vpath to locate the generated sources files from the parent
    directory and build them. This is useful only if the names of
    generated files are predictable and the number of files is small.
    Otherwise, it is extremely clumsy.

    One kludge is to make the wrapper script rename all the generated
    source files so that vpath pattern matching is simpler.
    So, 

        Bar.cc ==> Bar_spec.cc
        Foo.cc ==> Foo_spec.cc

    and in the parent directory Makefile:

    vpath %_spec.cc a.spec.dir

    ...

Are there better ways?

Regards
Sankar

-- 
Sankaranarayanan K. V.          | address@hidden
Motorola India Electronics Ltd  | http://www.mot.com/miel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]