----- Original Message ----- From: "Michal Nowikowski" <[EMAIL PROTECTED]> To: <help-make@gnu.org> Sent: Tuesday, January 09, 2007 8:45 AM Subject: creating directories through dependency
> Hello > > I have a problem of chicken-and-egg type. Makefile: > --- > BUILDDIR=build > > $(BUILDDIR): > mkdir -p $(BUILDDIR) > > $(objs):%.o:%.c $(BUILDDIR) > $(CC) -c $< -o $(BUILDDIR)/$@ > --- > > In this situation BUILDDIR is created before sources are compiled. > But when everything is compiled and I re-run make it tries to recompile > some source files because make claims that BUILDDIR is newer then > some object files. It is like that because BUILDDIR had been changing when > new object file were generated and put into it. Indeed, when you add files to a directory its modification date/time is updated. And that's exactly what GNU Make is using to determine if a file has changed... > How to solve this problem i.e. avoid recompiling files during subsequent > make run? You can solve this problem with order-only prerequisites (note the '|' character): $(objs):%.o:%.c | $(BUILDDIR) $(CC) -c $< -o $(BUILDDIR)/$@ See 4.3 "Types of Prerequisites" in the GNU Make documentation for more documentation. Hope this helps, Danny _______________________________________________ Help-make mailing list Help-make@gnu.org http://lists.gnu.org/mailman/listinfo/help-make