tech-toolchain archive

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

Re: make rules when creating multiple files



On Sat, Aug 13, 2011 at 11:59:27AM +0100, Iain Hibbert wrote:
> 
> rework it to provide a single target, with other files produced as
> side-effects and rearrange any dependents to depend on that target rather
> than the side-effect files
> 
...
> 
> cgram.c: cgram.y
>       yacc -d cgram.y
>       mv yy.tab.c cgram.c
>       mv yy.tab.h cgram.h
> 
> src.c: cgram.c
> 
> and don't tell make about the cgram.h file. If the user edits it by hand,
> well thats their mistake..

I'd tend to tell make you are building the .h file, and add something
explicit to ensure the .c file isn't compiled before the .h is generated.
That way you get a correct build when multiple files include the .h file
(and when 'make depend' adds the dependencies).

Explicitly adding the foo.o: foo.h rule is probably enough.

In some senses this isn't a bug !

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index