[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Pattern Rules Question
From: |
Guy Harrison |
Subject: |
Re: Pattern Rules Question |
Date: |
Tue, 29 Jun 2004 17:38:54 -0000 |
User-agent: |
KNode/0.7.2 |
cppaddict wrote:
> Hi,
>
> A simple question about pattern rules. The relevant part of my
> Makefile looks like this:
>
> <Makefile>
>
> OBJS=Main.obj WinDirectory.obj
>
> all: $(OBJS)
> $(CXX) $(OBJS)
>
> %.obj : %.cpp %.h
> $(CXX) -c $(CPPFLAGS) $<
>
> </Makefile>
>
> This works as expected when I update either WinDirectory.h or
> WinDirectory.cpp -- make recompiles WinDirectory.cpp and then links
> WinDirectory.obj and Main.obj. However, if I update Main.cpp, make
> will not recompile it. In fact, make doesn't do anything. I'm
> guessing this is because Main.h does not exist.
>
> In any case, how can alter my Makefile to get it to process updates to
> Main.cpp too (ie, to correctly process .cpp files that don't have a
> sister .h file)?
Have a look at the -M options to gcc. They can generate dependancy
information for you. Strictly the rest's offtopic so only a hint...
[stuff]
NAM =c
ITM =foo bar
OBJ =$(ITM:%=%.obj)
DEP =$(ITM:%=%.d)
EXE =$(NAM).exe
%.obj : %.cpp
$(CXX) -MMD -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $<
[stuff]
-include $(DEP)
--
Guy Harrison
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Pattern Rules Question,
Guy Harrison <=