New version that cleans up all of /usr/obj on amd64, i386 and macppc
(including the machine@ symlinks). I verified that it survives
make build and make release on these three architectures.
The previous diff had a bug that made make 'includes error' out on archs
different from amd64 and i386 because I overlooked that mm_malloc.h in
gnu/usr.bin/cc/include/Makefile is only compiled there.
This patch adds a prereq target to bsd.subdir.mk, which is a no-op.
Since I add ./sys/arch/${MACHINE}/stand to the PRDIRS, this ensures that
the .BEGIN targets responsible for these symlinks fire at the prereq
stage, so the machine symlinks end up owned by BUILDUSER.
To test this, it's safer to install the makefiles first:
# cd /usr/src/share/mk && make install
# cd /usr/src && make obj && make includes
and then
$ find /usr/obj -user root -ls
should produce no output (or maybe /usr/obj).
Index: Makefile
===================================================================
RCS file: /var/cvs/src/Makefile,v
retrieving revision 1.129
diff -u -p -U4 -r1.129 Makefile
--- Makefile 6 Oct 2016 18:56:17 -0000 1.129
+++ Makefile 13 Oct 2016 17:31:04 -0000
@@ -78,10 +78,10 @@ build:
echo $@ must be called by root >&2; \
false; \
fi
cd ${.CURDIR}/share/mk && exec ${MAKE} install
- exec ${MAKE} includes
exec ${MAKE} cleandir
+ exec ${MAKE} includes
cd ${.CURDIR}/lib && \
su ${BUILDUSER} -c '${MAKE} depend && exec ${MAKE}' && \
NOMAN=1 exec ${MAKE} install
cd ${.CURDIR}/gnu/lib && \
Index: include/Makefile
===================================================================
RCS file: /var/cvs/src/include/Makefile,v
retrieving revision 1.213
diff -u -p -U4 -r1.213 Makefile
--- include/Makefile 23 Sep 2016 09:18:05 -0000 1.213
+++ include/Makefile 15 Oct 2016 21:43:45 -0000
@@ -28,16 +28,16 @@ DIRS= arpa protocols rpc rpcsvc
LDIRS= crypto ddb dev isofs miscfs msdosfs net netinet netinet6 \
netmpls net80211 nfs ntfs scsi sys ufs uvm
# Places that need a prerequisite target met before includes
-PRDIRS=
+PRDIRS= ../lib/libcrypto ../lib/librpcsvc ../sys/arch/${MACHINE}/stand
# Directories with an includes target
-RDIRS= ../lib/libcrypto ../lib/libcurses ../lib/libedit \
+RDIRS= ../lib/libcurses ../lib/libedit \
../lib/libevent ../lib/libexpat ../lib/libform \
../lib/libfuse ../lib/libkeynote ../lib/libmenu \
../lib/libossaudio ../lib/libpanel ../lib/libpcap \
- ../lib/libradius ../lib/librpcsvc ../lib/librthread \
+ ../lib/libradius ../lib/librthread \
../lib/libskey ../lib/libssl ../lib/libtls \
../lib/libusbhid ../lib/libutil ../lib/libz \
../usr.bin/lex ../gnu/lib/libreadline \
../sys/arch/${MACHINE}
@@ -46,10 +46,9 @@ RDIRS= ../lib/libcrypto ../lib/libcurses
RDIRS+= ../gnu/usr.bin/gcc ../gnu/lib/libobjc
PRDIRS+= ../gnu/lib/libstdc++
.else
RDIRS+= ../gnu/usr.bin/cc/libobjc
-PRDIRS+= ../gnu/lib/libstdc++-v3
-RDIRS+= ../gnu/usr.bin/cc/include
+PRDIRS+= ../gnu/lib/libstdc++-v3 ../gnu/usr.bin/cc/include
.endif
# prereq implies includes
RDIRS += ${PRDIRS}
Index: lib/libcrypto/Makefile
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/Makefile,v
retrieving revision 1.7
diff -u -p -U4 -r1.7 Makefile
--- lib/libcrypto/Makefile 23 Sep 2016 21:49:30 -0000 1.7
+++ lib/libcrypto/Makefile 15 Oct 2016 14:19:17 -0000
@@ -372,9 +372,11 @@ HDRS=\
HDRS_GEN=\
${.CURDIR}/arch/${MACHINE_CPU}/opensslconf.h \
${.OBJDIR}/obj_mac.h
-includes: obj_mac.h
+prereq: obj_mac.h
+
+includes: prereq
@test -d ${DESTDIR}/usr/include/openssl || \
mkdir ${DESTDIR}/usr/include/openssl
@for i in $(HDRS); do \
j="cmp -s $$i ${DESTDIR}/usr/include/openssl/`basename $$i` || \
Index: lib/librpcsvc/Makefile
===================================================================
RCS file: /var/cvs/src/lib/librpcsvc/Makefile,v
retrieving revision 1.10
diff -u -p -U4 -r1.10 Makefile
--- lib/librpcsvc/Makefile 2 Aug 2012 13:38:39 -0000 1.10
+++ lib/librpcsvc/Makefile 15 Oct 2016 14:24:39 -0000
@@ -12,8 +12,9 @@ LIB= rpcsvc
NOMAN=
all: ${HDRS}
beforedepend: ${HDRS}
+prereq: ${HDRS}
includes: ${HDRS}
${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
${DESTDIR}/usr/include/rpcsvc
Index: share/mk/bsd.subdir.mk
===================================================================
RCS file: /var/cvs/src/share/mk/bsd.subdir.mk,v
retrieving revision 1.22
diff -u -p -U4 -r1.22 bsd.subdir.mk
--- share/mk/bsd.subdir.mk 8 Oct 2016 09:43:46 -0000 1.22
+++ share/mk/bsd.subdir.mk 16 Oct 2016 00:25:59 -0000
@@ -75,9 +75,9 @@ afterinstall: realinstall
realinstall: beforeinstall _SUBDIRUSE
.endif
-.for t in all cleandir includes depend obj tags manlint
+.for t in all cleandir prereq includes depend obj tags manlint
. if !target($t)
$t: _SUBDIRUSE
. endif
.endfor
Index: gnu/usr.bin/cc/include/Makefile
===================================================================
RCS file: /var/cvs/src/gnu/usr.bin/cc/include/Makefile,v
retrieving revision 1.11
diff -u -p -U4 -r1.11 Makefile
--- gnu/usr.bin/cc/include/Makefile 1 Sep 2016 11:03:09 -0000 1.11
+++ gnu/usr.bin/cc/include/Makefile 15 Oct 2016 23:17:38 -0000
@@ -43,8 +43,14 @@ cleandir: _SUBDIRUSE clean
depend:
# Nothing here so far...
+.if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
+prereq: mm_malloc.h unwind.h
+.else
+prereq: unwind.h
+.endif
+
.if !empty(INCS)
install includes: ${INCS}
${INSTALL} -C -o ${BINOWN} -g ${LOCALEGRP} -m ${NONBINMODE} ${.ALLSRC} \
${DESTDIR}/usr/include