I am using two programming languages together. A compiler takes program written with the first language (the source language) and translates them into the second language (the target language, for me, the C language). There are a few files generated this way, and also hand-written ones. Finally, i compile all these file (in the target language) into executable code.
I managed to generate automatically dependency files (classically named .d files) for the source language, to tell Makefile (I'm using GNU Makefile) in which order and when to call the first compiler. (Order is important for this compiler.) I also know how to generate dependencies for the target language (using GCC). I use the include directive to automatically include all dependencies. Makefile will find which rule to call to generate dependency files and include them.
Makefile works in three phases. First, it includes everything already generated. Second, it generate missing includes if possible. Third, it tries to build the target.
Now, to generate automatically the dependencies for the target language, I first need to generate all the files (since some generated headers are included) using the first compiler.
Here is the problem, in the second phase: when Makefile will want to generate the dependency files for the target code, it will first try to generate this target code from the source code. But, even if it has generated dependency for the source code, it didn't load these dependencies yet (dependencies will only be read at the end of this phase). So it will fail to compile the source code, since it is generally dependent of the order of compilation.
Is there a way to solve this problem ? Can Makefile be instructed to include generated dependencies as soon are they are generated ? Is there a way to alter the "3 phase" behavior of Makefile ?