Date: Mon, 14 Jun 2010 09:44:40 -0600 (MDT) From: "M. Warner Losh" <imp@bsdimp.com> To: brde@optusnet.com.au Cc: des@des.no, arch@FreeBSD.org Subject: Re: Change to config(8) for OFED Message-ID: <20100614.094440.321689434066253255.imp@bsdimp.com> In-Reply-To: <20100614201541.B37598@delplex.bde.org> References: <20100612.111805.94843338670897167.imp@bsdimp.com> <86zkz05bra.fsf@ds4.des.no> <20100614201541.B37598@delplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20100614201541.B37598@delplex.bde.org> Bruce Evans <brde@optusnet.com.au> writes: : On Sat, 12 Jun 2010, [utf-8] Dag-Erling Sm=C3=B8rgrav wrote: : = : > "M. Warner Losh" <imp@bsdimp.com> writes: : >> but NORMAL_C is : >> : >> NORMAL_C=3D ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} : >> : >> and .IMPSRC is null. That seems like a bug to me, but I'm not sur= e if : >> the bug is that .IMPSRC is computed wrong, or if it really should = be : >> ${.ALLSRC} : > : > .IMPSRC is the *implicit* source and is only valid in *implicit* : > rules. : = : However, NORMAL_C and related macros have always depended on it being= : defined to something reasonable so that they can abuse it in explicit= : rules. : = : > Consider the following: : > : > .SUFFIXES: .foo .bar : > .foo.bar: foo2bar.sh : > /bin/sh foo2bar.sh ${.IMPSRC} ${.TARGET} : > : > When building hello.bar from hello.foo, .IMPSRC is "hello.foo" but : > .ALLSRC : > is "hello.foo foo2bar.sh". : > : > GNU make has a way of defining more complex implicit rules (pattern= : > rules). If we had something similar, we could do: : > : > foo_%.o: %.c : > ${NORMAL_C} : = : BSD make can handle simple cases like this using pattern filters and : substitution. E.g.: : = : %%% : ABNORMAL_C=3D ${CC} -c ${CFLAGS} ${WERROR} ${PROF} : ${.ALLSRC:M*.c:S/^foo_//} : # Untested more careful patterns: ${.ALLSRC:M^foo*.c$:S/^foo_//} : = : bar.o: foo_bar.c stuff.nonc : ${ABNORMAL_C} : %%% That would work. Not sure I like it, but it would work. : This has no alternative of using .IMPSRC instead of .ALLSRC since its= : .IMPSRC is empty with the above dependencies. The rule for getting a= : nonempty .IMPSRC in an explicit dependency with BSD makef seems to be= : : : some of the sources must match the target according to a suffix : rule; then the first matching one (according to the order of the : sources in the dependency list for the target) becomes .IMPSRC, : so .IMPSRC always contains either 0 or 1 name. : = : I've don't remember having seen the exact rule documented. I've never seen this rule documented either. It is only a repeated observation that I've seen over the years. When I tried to chase it into the source, I couldn't find the place that did this... Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100614.094440.321689434066253255.imp>