Subject: Re: Using xargs in kernel depend
To: None <tech-toolchain@netbsd.org>
From: Simon Gerraty <sjg@juniper.net>
List: tech-toolchain
Date: 05/14/2004 00:17:49
On Thu, 13 May 2004 23:05:19 -0700 (PDT), Simon Gerraty writes:
>My trial build of -current hosted on a freebsd box failed in the
>kernel compile becuase FreeBSD couldn't handle the command line
>length.  Since any system will eventually run out of resources, a
>patch like the following seems appropriate?

Well that didn't work as well as I thought it did
This time for sure...

--sjg

Index: sys/conf/Makefile.kern.inc
===================================================================
RCS file: /cvsroot/src/sys/conf/Makefile.kern.inc,v
retrieving revision 1.53
diff -u -p -r1.53 Makefile.kern.inc
--- sys/conf/Makefile.kern.inc	25 Apr 2004 04:24:06 -0000	1.53
+++ sys/conf/Makefile.kern.inc	14 May 2004 07:11:37 -0000
@@ -291,11 +291,24 @@ dependall: depend all
 SRCS?=		${MD_SFILES} ${MD_CFILES} ${MI_CFILES} ${CFILES} ${SFILES}
 MKDEP_AFLAGS?=	${AFLAGS}
 MKDEP_CFLAGS?=	${CFLAGS}
+# We have to assume that we'll eventually run out of command line.
+# We already hit that on non-NetBSD hosts.
+_SFILES=${MD_SFILES} ${SFILES}
+_CFILES=${MD_CFILES} ${MI_CFILES} ${CFILES}
+_XargsMKDEP=${MKDEP:M*=*} xargs -t ${MKDEP:N*=*}
+
+# This dance is necessary to avoid long command lines.
+${SRCS:S,^,list-,}:
+	@echo ${.TARGET:S,^list-,,}
+
+_sfiles: ${_SFILES:S,^,list-,}
+_cfiles: ${_CFILES:S,^,list-,}
+
 .depend: ${SRCS} assym.h config_time.h
 	${_MKTARGET_CREATE}
-	${MKDEP} -- ${MKDEP_AFLAGS} ${CPPFLAGS} ${MD_SFILES} ${SFILES}
-	${MKDEP} -a -- ${MKDEP_CFLAGS} ${CPPFLAGS} ${MD_CFILES} ${MI_CFILES} \
-	    ${CFILES}
+	@> $@
+	@${.MAKE} -f ${MAKEFILE} _sfiles | ${_XargsMKDEP} -a -- ${MKDEP_AFLAGS} ${CPPFLAGS} 
+	@${.MAKE} -f ${MAKEFILE} _cfiles | ${_XargsMKDEP} -a -- ${MKDEP_CFLAGS} ${CPPFLAGS}
 	cat ${GENASSYM} ${GENASSYM_EXTRAS} | \
 	    ${HOST_SH} $S/kern/genassym.sh ${MKDEP} -f assym.dep -- \
 	    ${CFLAGS} ${CPPFLAGS}