Subject: Using xargs in kernel depend
To: None <tech-toolchain@netbsd.org>
From: Simon Gerraty <sjg@juniper.net>
List: tech-toolchain
Date: 05/13/2004 23:05:19
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?

--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 05:59:09 -0000
@@ -291,11 +291,17 @@ 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*=*}
+
 .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}
+	@> $@
+	@(${_SFILES:@i@echo $i${.newline}@}) | ${_XargsMKDEP} -a -- ${MKDEP_AFLAGS} ${CPPFLAGS} 
+	@(${_CFILES:@i@echo $i${.newline}@}) | ${_XargsMKDEP} -a -- ${MKDEP_CFLAGS} ${CPPFLAGS}
 	cat ${GENASSYM} ${GENASSYM_EXTRAS} | \
 	    ${HOST_SH} $S/kern/genassym.sh ${MKDEP} -f assym.dep -- \
 	    ${CFLAGS} ${CPPFLAGS}