Change to config(8) for OFED
Bruce Evans
brde at optusnet.com.au
Mon Jun 14 10:56:15 UTC 2010
On Sat, 12 Jun 2010, [utf-8] Dag-Erling Smørgrav wrote:
> "M. Warner Losh" <imp at bsdimp.com> writes:
>> but NORMAL_C is
>>
>> NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
>>
>> and .IMPSRC is null. That seems like a bug to me, but I'm not sure 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= ${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}
%%%
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.
Bruce
More information about the freebsd-arch
mailing list