Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22096

How to make Make generates headers before compiling?

$
0
0

I struggle to compile my CPP files because a header file is missing. I know it is missing because I want to generate it. How ?

Here what I have so far. Problem is : when "the_header.hpp" is used in several CPP files, recursive calls of make are not efficient (nor satisfactory) as headers included in "the_header.hpp" seem to be rebuilt several times because of parallelism.

The CPP files %.cpp :

#include "the_header.hpp"// ...

My Makefile :

#include *.g *.d# *.g like generator%.g: %.cpp    g++ -MM -MF $@ -MP -MG -MT $@ $<    make $@#%.d: %.g ;#%.o : %.cpp %.d    // g++ with auto-dependencies generation# the_header.hpp matches%.hpp : %.lcm    // Generate it

And just to be cleared of my intensions : as I compile a CPP files, I generate a %.g files which target will add more prerequisites to itself. The recursive call will end up sees "the_header.hpp" as prerequisite (and not up-to-date), generate it and regenerate %.g. The recursive call will see "the_header.hpp" up-to-date, nothing to do, end of recursions. Processes to compiling.

Moreover, "the_header.hpp" is a LCM generated file with lcmgen from %.lcm file.

Before doing so, I had just (which works great with parallelism but is neither satisfactory) :

#%.o : %.cpp %.d $(patsubst %.lcm,%.hpp,$(wildcard *.lcm)

Not knowing which lcm files was actually used. Also, I have mixed C and C++ projects which could lead to :

# lcmgen can be used with both C++ or C...%.o : %.cpp %.d $(patsubst %.lcm,%.hpp,$(wildcard *.lcm) $(patsubst %.lcm,%.h,$(wildcard *.lcm)

I hope you will find it entertaining !


Viewing all articles
Browse latest Browse all 22096

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>