"Ming Kin Lai" <[EMAIL PROTECTED]> writes:

> Suppose I have prog1.c prog2.c prog3.c prog4.c prog1.h prog2.h
> In my Makefile I have these:
>
> $(OBJ)= prog1.o prog2.o prog3.o prog4.o
> $(OBJ): %.o: %.c %.h
>      $(CC) -c $< -o $@
>
> I do not want to explicitly write a separate rule for prog3 and prog4:
>
> ...
>
> That would be too awkward.  Is there a better way?

If you don't mind using features from 3.81beta4 then you can do it like
this:

.SECONDEXPANSION:

$(OBJ): %.o: %.c $$(if $$(wildcard %.h),%.h)
        $(CC) -c $< -o $@

hth,
-boris



_______________________________________________
Help-make mailing list
Help-make@gnu.org
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to