help-gnu-utils
[Top][All Lists]
Advanced

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

Makefile - how to filter out x.c files that do not have corresponding x.


From: hzmonte
Subject: Makefile - how to filter out x.c files that do not have corresponding x.h in a rule that has %.h as prerequisite
Date: 12 Jan 2006 22:30:52 -0800
User-agent: G2/0.2

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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]