There's a couple of things you can do (or try to do):
1. Keep derived (ie generated) files away from source files.  Put them in a separate 
directory hierarchy.  This'll make it a bit more difficult to delete the .P files.
2. I'm not sure if this'll work, but you could try something like (using gmake 3.80):

  %.o: %.c | %.P

As for the SIG 11 that Greg Chicares mentioned, make actions should be transactional 
in that they should completely succeed or completely fail which means, at least for 
"complicated" actions, they need to be on one command line separated by '&&' (Paul may
cite exceptions to this rule of thumb).  If it fails, IIRC, make will delete all 
generated files.  I'm not sure how it behaves if the action segfaults, though, but I 
would hope it treats these as failures as well; Paul, how does gmake behave under
segfaulting actions?

HTH,
Noel

Rolf Sandau wrote:
> 
> Following "Recursive Make Considered Harmful"  Peter Miller and Paul D.
> Smith, "Advanced Auto-Dependency Generation" I created a Makefile that
> generates the dependencies of c-sources (%.P) when compiling the c-source.
> While avoiding re-exec of make, if dependency file does not exist and
> avoiding 'no rule to make target ...' if a prerequisite is removed there is
> still a problem left.
> If anyone kills just dependency-files, make wouldn't do anything, but I
> would prefer make to recompile and regenerate dependencies. For I couldn't
> find anything that helps, in my typical naive way I just tried a second
> prerequisite-pattern :
>       %.o: %.c %.P
> ... and what a surprise, it worked with my cygwin's gnu-make 3.80 :-)
> 
> Now the questions:
> Is this a legal construction and should it work with other gnu-makes on
> other platforms too?
> And if it's neither legal nor globally available, does anybody now a way to
> fix the problem?
> On the other hand, if everything is correct, does exist a documentation
> about this?
> 
> Rolf
> 
> ===========
> Sample:
> 
> SRCS := main.c
> 
> OBJDIR := .
> 
> # determine the object files
> OBJS := ${patsubst %,${OBJDIR}/%,${patsubst %.c,%.o, ${filter
> %.c,${SRCS}}}}
> DEPS := ${patsubst %.o,%.P,${OBJS}}
> 
> MAKEDEPEND = gcc -M $< > ${basename [EMAIL PROTECTED]
> COMPILE.c := gcc ${CFLAGS}
> 
> proj: $(OBJS)
> 
> ${OBJDIR}/%.o: %.c ${OBJDIR}/%.P
>       ${MAKEDEPEND};\
>       cp ${basename [EMAIL PROTECTED] ${basename [EMAIL PROTECTED]; \
>       sed -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
>           -e '/^$$/ d' -e 's/$$/ :/' < ${basename [EMAIL PROTECTED] >> ${basename
> [EMAIL PROTECTED];
>       rm -f $*.d
>       ${COMPILE.c} -o $@ $<
> 
> ${DEPS}:
> 
> -include $(OBJS:%.o=%.P)
> 
> _______________________________________________
> Help-make mailing list
> [EMAIL PROTECTED]
> http://mail.gnu.org/mailman/listinfo/help-make

-- 
NOTICE: If received in error, please destroy and notify sender.  Sender does not waive 
confidentiality or privilege, and use is prohibited.


_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-make

Reply via email to