Re: Very long SRCS list with unusually long src/ prefix

From: Ruslan Ermilov <ru_at_freebsd.org>
Date: Fri, 6 Feb 2004 18:22:05 +0200
On Sat, Feb 07, 2004 at 03:07:55AM +1100, Bruce Evans wrote:
> On Thu, 5 Feb 2004, M. Warner Losh wrote:
> 
> > In message: <20040206030956.F11456_at_gamplex.bde.org>
> >             Bruce Evans <bde_at_zeta.org.au> writes:
> > : > > % +	(cd ${.CURDIR}; ${MAKE} _mkdep_cS) | xargs env \
> > : > > % +	    ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
> > : > > % +	    ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*}
> > : > >
> > : > > make uses a real shell, so the env shouldn't be needed.
> > : > >
> > : > $ echo foo.c | xargs CC=cc mkdep
> > : > xargs: CC=cc: No such file or directory
> > :
> > : $ echo foo.c | CC=cc xargs mkdep
> >
> > But MKDEPCMD is 'CC=cc mkdep', so the env is needed...  Unless there's
> > a MKDEPCMD_ENV variable...
> 
> I missed the mkdep in MKDEPCMD.  MKDEPCMD is actually just mkdep in the
> usual case and "CC='${CC}' mkdep" in the ${CC} != "cc" case.  Putting
> args in the macro for the command is mostly foot shooting here.
> Kernel makefiles handle this better.
> 
This works slightly better:

%%%
Index: bsd.dep.mk
===================================================================
RCS file: /home/ncvs/src/share/mk/bsd.dep.mk,v
retrieving revision 1.45
diff -u -r1.45 bsd.dep.mk
--- bsd.dep.mk	27 Jan 2004 23:22:15 -0000	1.45
+++ bsd.dep.mk	6 Feb 2004 11:53:48 -0000
_at__at_ -19,6 +19,8 _at__at_
 #
 # MKDEPCMD	Makefile dependency list program [mkdep]
 # 
+# MKDEPENV	Environment for ${MKDEPCMD} [not set]
+# 
 # SRCS          List of source files (c, c++, assembler)
 #
 # DPSRCS	List of source files which are needed for generating
_at__at_ -49,10 +51,11 _at__at_
 HTAGSFLAGS?=
 
 .if ${CC} != "cc"
-MKDEPCMD?=	CC='${CC}' mkdep
+MKDEPENV?=	CC='${CC}'
 .else
-MKDEPCMD?=	mkdep
+MKDEPENV?=
 .endif
+MKDEPCMD?=	mkdep
 DEPENDFILE?=	.depend
 
 # Keep `tags' here, before SRCS are mangled below for `depend'.
_at__at_ -126,24 +129,35 _at__at_
 # Different types of sources are compiled with slightly different flags.
 # Split up the sources, and filter out headers and non-applicable flags.
 DPSRCS+= ${SRCS}
+
+_mkdep_cS: ${DPSRCS:M*.[cS]:S/^/_mkdep_/}
+_mkdep_cc: ${DPSRCS:M*.cc:S/^/_mkdep_/} ${DPSRCS:M*.C:S/^/_mkdep_/} \
+    ${DPSRCS:M*.cpp:S/^/_mkdep_/} ${DPSRCS:M*.cxx:S/^/_mkdep_/}
+_mkdep_m: ${DPSRCS:M*.m:S/^/_mkdep_/}
+.for f in ${DPSRCS:M*.[cS]} ${DPSRCS:M*.cc} ${DPSRCS:M*.C} ${DPSRCS:M*.cpp} \
+    ${DPSRCS:M*.cxx} ${DPSRCS:M*.m}
+_mkdep_${f}: ${f}
+	_at_echo ${.ALLSRC}
+.endfor
+
 ${DEPENDFILE}: ${DPSRCS}
 	rm -f ${DEPENDFILE}
 .if !empty(DPSRCS:M*.[cS])
-	${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
-	    ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \
-	    ${.ALLSRC:M*.[cS]}
+	(cd ${.CURDIR}; ${MAKE} _mkdep_cS) | ${MKDEPENV} xargs \
+	    ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
+	    ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*}
 .endif
 .if !empty(DPSRCS:M*.cc) || !empty(DPSRCS:M*.C) || !empty(DPSRCS:M*.cpp) || \
     !empty(DPSRCS:M*.cxx)
-	${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
-	    ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*} \
-	    ${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx}
+	(cd ${.CURDIR}; ${MAKE} _mkdep_cc) | ${MKDEPENV} xargs \
+	    ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
+	    ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*}
 .endif
 .if !empty(DPSRCS:M*.m)
-	${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
+	(cd ${.CURDIR}; ${MAKE} _mkdep_m) | ${MKDEPENV} xargs \
+	    ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
 	    ${OBJCFLAGS:M-nostdinc*} ${OBJCFLAGS:M-[BID]*} \
-	    ${OBJCFLAGS:M-Wno-import*} \
-	    ${.ALLSRC:M*.m}
+	    ${OBJCFLAGS:M-Wno-import*}
 .endif
 .if target(_EXTRADEPEND)
 _EXTRADEPEND: .USE
%%%

-- 
Ruslan Ermilov
FreeBSD committer
ru_at_FreeBSD.org

Received on Fri Feb 06 2004 - 07:21:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:41 UTC