Bug 191054 - [build] [bsd.progs.mk] make clean/cleanobj does not clean as expected with bsd.progs.mk
Summary: [build] [bsd.progs.mk] make clean/cleanobj does not clean as expected with bs...
Status: Closed DUPLICATE of bug 191055
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-15 07:56 UTC by Enji Cooper
Modified: 2014-07-25 02:32 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer freebsd_triage 2014-06-15 07:56:41 UTC
When trying to isolate some issues with bsd.test.mk, I noticed that make clean/cleanobj  was not cleaning as expected, in particular make clean does not clean any of the compiled programs, and make cleanobj only cleans out the last compiled program. If I run make cleandir, it napalms the heck out of the directory by deleting the bsd.dep.mk files 6 times (twice for cleandir, twice for cleanobj, twice for cleandepend) and the generated objects 2 times each (once each for cleanobj, once each for cleandir).

I've provided an example below:

% uname -a
FreeBSD isilon-fuji-current.local 11.0-CURRENT FreeBSD 11.0-CURRENT #5 0d2be6b(isilon-atf): Sun Jun  8 21:34:32 PDT 2014     root@fuji-current.local:/usr/obj/usr/src/sys/FUJI  i386
% cat *
# Makefile
FILESDIR=/tmp/share

FILES=	c

BINDIR=	/tmp/bin

PROGS=	a b

MAN=

.include <bsd.progs.mk>
/* a.c */
#include <stdio.h>

int
main(void)
{

	printf("hello world!\n");
	return (0);
}
/* b.c */
#include <stdio.h>

int
main(void)
{

	printf("hello world!\n");
	return (0);
}
/* c */
This directory contains a simple C app that says, "hello world!"
% make obj
/usr/obj/root/make_clean_broken_with_progs_dot_mk created for /root/make_clean_broken_with_progs_dot_mk
% make depend
(cd /root/make_clean_broken_with_progs_dot_mk && make -f /root/make_clean_broken_with_progs_dot_mk/Makefile _RECURSING_PROGS=  SUBDIR= PROG=a  depend)
rm -f .depend.a
mkdep -f .depend.a -a     -std=gnu99   /root/make_clean_broken_with_progs_dot_mk/a.c
echo a: /usr/lib/libc.a  >> .depend.a
(cd /root/make_clean_broken_with_progs_dot_mk && make -f /root/make_clean_broken_with_progs_dot_mk/Makefile _RECURSING_PROGS=  SUBDIR= PROG=b  depend)
rm -f .depend.b
mkdep -f .depend.b -a     -std=gnu99   /root/make_clean_broken_with_progs_dot_mk/b.c
echo b: /usr/lib/libc.a  >> .depend.b
% make all
(cd /root/make_clean_broken_with_progs_dot_mk && make -f /root/make_clean_broken_with_progs_dot_mk/Makefile _RECURSING_PROGS=  SUBDIR= PROG=a )
cc -O2 -pipe   -std=gnu99 -fstack-protector   -Qunused-arguments -c /root/make_clean_broken_with_progs_dot_mk/a.c
cc -O2 -pipe   -std=gnu99 -fstack-protector   -Qunused-arguments  -o a a.o 
(cd /root/make_clean_broken_with_progs_dot_mk && make -f /root/make_clean_broken_with_progs_dot_mk/Makefile _RECURSING_PROGS=  SUBDIR= PROG=b )
cc -O2 -pipe   -std=gnu99 -fstack-protector   -Qunused-arguments -c /root/make_clean_broken_with_progs_dot_mk/b.c
cc -O2 -pipe   -std=gnu99 -fstack-protector   -Qunused-arguments  -o b b.o 
% make clean
% make cleanobj
(cd /root/make_clean_broken_with_progs_dot_mk && make -f /root/make_clean_broken_with_progs_dot_mk/Makefile _RECURSING_PROGS=  SUBDIR= PROG=a  cleanobj)
(cd /root/make_clean_broken_with_progs_dot_mk && make -f /root/make_clean_broken_with_progs_dot_mk/Makefile _RECURSING_PROGS=  SUBDIR= PROG=b  cleanobj)
rm -f b b.o
rm -f .depend.b GPATH GRTAGS GSYMS GTAGS
%  make cleandir
(cd /root/make_clean_broken_with_progs_dot_mk && make -f Makefile _RECURSING_PROGS=  SUBDIR= PROG=a  cleandepend)
rm -f .depend.a GPATH GRTAGS GSYMS GTAGS
(cd /root/make_clean_broken_with_progs_dot_mk && make -f Makefile _RECURSING_PROGS=  SUBDIR= PROG=b  cleandepend)
rm -f .depend.b GPATH GRTAGS GSYMS GTAGS
(cd /root/make_clean_broken_with_progs_dot_mk && make -f Makefile _RECURSING_PROGS=  SUBDIR= PROG=a  cleanobj)
rm -f a a.o
rm -f .depend.a GPATH GRTAGS GSYMS GTAGS
(cd /root/make_clean_broken_with_progs_dot_mk && make -f Makefile _RECURSING_PROGS=  SUBDIR= PROG=b  cleanobj)
rm -f b b.o
rm -f .depend.b GPATH GRTAGS GSYMS GTAGS
(cd /root/make_clean_broken_with_progs_dot_mk && make -f Makefile _RECURSING_PROGS=  SUBDIR= PROG=a  cleandir)
rm -f a a.o
rm -f .depend.a GPATH GRTAGS GSYMS GTAGS
(cd /root/make_clean_broken_with_progs_dot_mk && make -f Makefile _RECURSING_PROGS=  SUBDIR= PROG=b  cleandir)
rm -f b b.o
rm -f .depend.b GPATH GRTAGS GSYMS GTAGS
%

Expected behavior:

- make clean should clean all apps and generated files.
- make cleanobj should just nuke ${.OBJDIR}; it shouldn't have to nuke the files under ${.OBJDIR} (bsd.obj.mk ensures that requirement is met for cleanobj).
- make cleandir should does the same thing as cleanobj (why they're separate targets, I have no idea, but cleanobj isn't advertised in the docs though...).
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2014-06-26 02:15:12 UTC
refine summary again.
Comment 2 Enji Cooper freebsd_committer freebsd_triage 2014-07-02 23:27:10 UTC
I attached a proposed fix to bug 191055.
Comment 3 Julio Merino,+1 347 694 0576,New York City freebsd_committer freebsd_triage 2014-07-25 02:32:07 UTC
As you mention with your fix, this is actually a duplicate of 191055.  bsd.progs.mk is not handling the case of a mixture of PROGS and FILES correctly for all targets other than build.

*** This bug has been marked as a duplicate of bug 191055 ***