This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Beginner GCC projects question
- From: Michael Veksler <VEKSLER at il dot ibm dot com>
- To: Paolo Bonzini <bonzini at gnu dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 17 May 2004 13:01:00 +0300
- Subject: Re: Beginner GCC projects question
Paolo Bonzini wrote:
> Remember the "Mega bonus points for working out a way to do
> automatic dependency generation without relying on features
> of GCC or GNU make. And we don't want a make dep pass if it
> can possibly be avoided." This is feasible, especially since
> GNU make *is* now allowed. You need good make skills, but
> not guru-level -- just take a look at how Automake does it.
> I cannot approve any patch, but if you pick this one I'm
> willing to help.
I have been doing this for years with GNU make. What you have
to do is to generate a small makefile for each source file,
and -include it from your global makefile. It may seem trivial
but it is not quite so. Possible pitfalls:
1. Parallel make. Parallel make does not work well with
multiple targets. This won't work:
foo.m foo.o: foo.c
do tricks to generate foo.m and foo.o
2. You don't want "make clean" to compile foo.m and foo.o,
all you want is to clean-up. So this won't work (again):
foo.m foo.o: foo.c
(because include directive will force gnu-make to rebuild
your foo.m).
3. You want to re-create foo.m when it is explicitly removed.
Here (contrary to 1, 2) you may be tempted to do something
like
foo.m: foo.c
There are ways to fix concerns 1-3 but they are quite
ugly. Some of the solutions are not so portable (e.g. require
/bin/touch). You may wind up doing weird dependencies like:
foo.o: foo.c foo.m
foo.m:
@#do nothing
or:
foo.o: foo.c foo.m
foo.m: foo.c
I am sure that there are examples somewhere on the
web, I am not quite sure if Automake has it done right.