On 2007-08-14 19:21:33 (+0300), Yakov Lerner <[EMAIL PROTECTED]> wrote: > I have tiny makefile that looks like this: > > all: prog > prog: a.o b.o ; $(CC) -o $@ a.o b.o > > It is very short because it relies on builtin %.o: %.c rule. > How do I add the following dependency: that all *.c files depend on all *.h ? > So that when any *.h changes, all *.o are recompiled ? > I tried to add '%.o: %.c *.h' now, but it didn't do the trick.
HEADERS := $(shell ls *.h) prog: a.o b.o $(CC) -o $@ $^ %.o: %.c $(HEADERS) $(CC) -c $< -o $@ This expresses that a.o depends on a.h, b.h, ... If you just want to express that a.o depends on a.h and b.o depends on b.h the following rule should do: $.o: %.c %. Though you may want to look in to the traditional methods of solving this. See http://www.cmcrossroads.com/option,com_smf/Itemid,180/topic,69672.0.html, which will scale a lot better. Kristof
signature.asc
Description: Digital signature
_______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
