help-gnu-utils
[Top][All Lists]
Advanced

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

gmake: handling generated include files.


From: Kannan Goundan
Subject: gmake: handling generated include files.
Date: 15 Oct 2004 15:11:33 -0700

I have some scripts that generate C code.  However, the generated
files don't become standalone compilation units.  The generated files
are #included by another C file.

   int RunInterpreter(Instruction* code, Instruction *end)
   {
      int accumulator = 0;
      while (code < end) {
         switch (code->op) {

            #include "LoadCases.gen.h"
            #include "AluCases.gen.h"
            #include "BranchCases.gen.h"

            case Op_Return:
               return accumulator;

            default:
               printf("unknown instruction\n");
               return -1;
         }
         code++;
      }
   }

I also have shell scripts to generate each of those header files:

   LoadCases.gen.h.sh
   AluCases.gen.h.sh
   BranchCases.gen.h.sh

I have a makefile rule that (I think) will invoke the generator script
upon request:

   $(GEN_DIR)/%.gen.h: $(SRC_DIR)/%.gen.h.sh
      $< > $@

I'm using a relatively standard method for automatic dependency
generation.

The problem is that the dependency generation phase (i.e. GCC -MM)
fails when it hits a #include file that doesn't exist.  How can I make
GCC ignore the fact that the files are missing and have it print the
filenames out to the dependency list anyway?

One solution to this problem is to generate the entire ".c" file, but
I'd rather not do that, if possible.


reply via email to

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