porter's handbook documentation on avoiding != variable
assignments
Matthew Seaman
m.seaman at infracaninophile.co.uk
Sun Jul 20 09:05:08 UTC 2008
Kris Kennaway wrote:
> Can someone add to the PH a version of the advice below? It might need
> to be fleshed out a bit to provide more context.
>
> Kris
>
>> Variable assignments with != are bad! Try as hard as you can to avoid
>> using them -- especially in Mk/*! Every time something processes your
>> makefile it will spawn a command, even if it is not relevant for the
>> operation being performed. If you need to run shell commands, try to
>> isolate them within a makefile target. You can avoid code duplication
>> by assigning the *shell commands* (not their output) to a variable and
>> inserting it into your code block.
>>
>> e.g. instead of
>>
>> --
>> VARIABLE!= do some shell stuff; do some other stuff
>>
>> target:
>> echo ${VARIABLE}
>> --
>>
>> do this (or similar):
>>
>> --
>> VARIABLE_CMDS= do some shell stuff; do some other stuff
>>
>> target:
>> echo $$(${VARIABLE_CMDS})
>> --
>>
>> This defers the command execution to the point where the target runs,
>> so in the case when the target is *not* run (e.g. during INDEX builds or
>> other recursive port traversals), then you avoid wasting one or more
>> process executions.
Would it be acceptable to use something like:
.if !defined(BUILDING_INDEX)
VARIABLE!= something or other
.endif
or
.if !make(describe)
VARIABLE!= whatever
.endif
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard
Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
Kent, CT11 9PW
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20080720/9d07a7b2/signature.pgp
More information about the freebsd-ports
mailing list