[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
how to have an "optional" prerequisite in a static pattern rule
From: |
Ming Kin Lai |
Subject: |
how to have an "optional" prerequisite in a static pattern rule |
Date: |
Thu, 12 Jan 2006 22:30:40 -0800 |
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 get an error because there are no prog3.h and prog4.h and the static
pattern rule apparently requires a header file for each object file.
I do not want to explicitly write a separate rule for prog3 and prog4:
prog3.o prog4.o: %.o %.c
$(CC) -c $< -o $@
$(filter prog3.o prog4.o, $(OBJ)): %.o: %.c %.h
$(CC) -c $< -o $@
That would be too awkward. Is there a better way?
- how to have an "optional" prerequisite in a static pattern rule,
Ming Kin Lai <=