[issue343] make clean removes all files if patches/ dir is empty

YONETANI Tomokazu qhwt+dfly at les.ath.cx
Sun Oct 8 05:23:55 PDT 2006


On Sun, Oct 08, 2006 at 04:31:23AM -0700, Peter Avalos wrote:
> On Sun, Oct 08, 2006 at 04:31:31PM +0900, YONETANI Tomokazu wrote:
> > On Sat, Oct 07, 2006 at 04:19:07PM -0000, Peter Avalos wrote:
> > > 
> > > New submission from Peter Avalos <pavalos at xxxxxxxxxxxx>:
> > > 
> > > I just got a nice little surprise.  If I don't have any files named *.patch in 
> > > patches/ and I do a make clean, it adds '*' to the rm list.  Is there any way 
> > > to prevent this behavior?
> > > 
> > > box:~pavalos/dfly/src/usr.bin/top/patches% mv machine.h.patch machine.h
> > > box:~pavalos/dfly/src/usr.bin/top/patches% cd ..
> > > box:~pavalos/dfly/src/usr.bin/top% make clean
> > > "/usr/share/mk/bsd.prog.mk", line 40: warning: duplicate script for 
> > > target "top" ignored
> > > rm -f top.local.h top.x top.1 * top .o top.1.gz top.1.cat.gz
> > > rm: CVS: is a directory
> > > rm: patches: is a directory
> > > *** Error code 1
> > > 
> > > Stop in /home/pavalos/dfly/src/usr.bin/top.
> > 
> > I can't reproduce it here.  Can you post your modification to the Makefile
> > if any?
> > 
> > Cheers.
> 
> I was a bit frustrated when I worte that since all my work was blown away.
> It's pretty clear what the problem is, but I was ust wondering if there's
> a better way to keep from shooting myself in the foot.  I suppose I could
> just add the actual patch files to the Makefile instead of doing:
> 
> PATCHES!=	echo ${.CURDIR}/patches/*.patch
> SRCS+=	${PATCHES}

A-ha..  Too bad that your work got lost!  Attached patch should be
enough for your anti-footshooting, with a nice side-effect to tell
you about non-existent patch files.

Cheers.
diff -r d32292c10d35 share/mk/bsd.patch.mk
--- a/share/mk/bsd.patch.mk	Sat Oct 07 02:57:30 2006 +0000
+++ b/share/mk/bsd.patch.mk	Sun Oct 08 21:06:07 2006 +0900
@@ -42,6 +42,9 @@ CLEANFILES?=
 
 .for _PSRC in ${SRCS:M*.no_obj.patch}
 .for _PC in ${_PSRC:T:C/(\.no_obj)?\.patch$//:S|,|/|g}
+.if !exists(${_PSRC})
+.error non-existent patch file ${_PSRC}
+.endif
 
 ${_PC}: _PATCHFILE ${CONTRIBDIR}/${_PC} ${_PSRC}
 
@@ -54,6 +57,9 @@ CLEANFILES:=	${CLEANFILES} ${_PC}
 
 .for _PSRC in ${SRCS:N*.no_obj.patch:M*.patch}
 .for _PC in ${_PSRC:T:C/(\.no_obj)?\.patch$//:S|,|/|g}
+.if !exists(${_PSRC})
+.error non-existent patch file ${_PSRC}
+.endif
 
 ${_PC}: _PATCHFILE ${CONTRIBDIR}/${_PC} ${_PSRC}
 




More information about the Bugs mailing list