This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

precompiled headers (was: Slow compilation with many files)


Per Rosengren wrote:

> My only problem now is how to get my buildsystem to use it. I am
> currently using autoconf and automake. If I run "gcc -c myheader.hh", I
> get a myheader.hh.gch file. I have tried to add the headers to
> <target>SOURCES in Makefile.am, but the resulting Makefile doesn't
> compile them.

Anything you write in Makefile.am is simply passed through through
verbatim to the output Makefile in the absence of any automake-specific
syntax, so just write whatever you need as standard make rules.  I'd
start with something like:

BUILT_SOURCES = myheader.hh.gch
%.hh.gch: %.hh
	$(CXX) -c $<

(The %-pattern rule syntax is GNU make specific, so if you need
portability to other makes you would probably need to either spell it
out as "myheader.hh.gch: myheader.hh" or add .hh.gch to .SUFFIXES and
write it as an old-style suffix rule.)

You could also do it at the end of configure using e.g.
AC_CONFIG_COMMANDS or AC_CONFIG_COMMANDS_POST, assuring that it's the
first thing done before compiling anything.  The problem with that is
that it won't capture any dependency info, so the .gch will never be
remade if myheader.hh or something it includes is modified.  

But honestly the above is just a random stab at how to start, you'd be
much better asking on the automake list (in CC:.)

Brian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]