Date: Sun, 20 Jul 2008 10:04:55 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Kris Kennaway <kris@freebsd.org> Cc: ports@freebsd.org Subject: Re: porter's handbook documentation on avoiding != variable assignments Message-ID: <4882FFB7.1090501@infracaninophile.co.uk> In-Reply-To: <488232AE.4090701@FreeBSD.org> References: <484EAFAC.3020208@FreeBSD.org> <488232AE.4090701@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6741CA0FD87C2A9C28964EF3 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Kris Kennaway wrote: > Can someone add to the PH a version of the advice below? It might need= =20 > to be fleshed out a bit to provide more context. >=20 > Kris >=20 >> Variable assignments with !=3D are bad! Try as hard as you can to avo= id=20 >> using them -- especially in Mk/*! Every time something processes your= =20 >> makefile it will spawn a command, even if it is not relevant for the=20 >> operation being performed. If you need to run shell commands, try to = >> isolate them within a makefile target. You can avoid code duplication= =20 >> by assigning the *shell commands* (not their output) to a variable and= =20 >> inserting it into your code block. >> >> e.g. instead of >> >> --=20 >> VARIABLE!=3D do some shell stuff; do some other stuff >> >> target: >> echo ${VARIABLE} >> --=20 >> >> do this (or similar): >> >> --=20 >> VARIABLE_CMDS=3D do some shell stuff; do some other stuff >> >> target: >> echo $$(${VARIABLE_CMDS}) >> --=20 >> >> 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=20 >> process executions. Would it be acceptable to use something like: =2Eif !defined(BUILDING_INDEX) VARIABLE!=3D something or other =2Eendif or=20 =2Eif !make(describe) VARIABLE!=3D whatever =2Eendif Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW --------------enig6741CA0FD87C2A9C28964EF3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREIAAYFAkiC/7wACgkQ8Mjk52CukIwQbwCePjrkHGLiCEnqvP+49om6xeXb L50AnjRNVPQxHCXhn/yFT/Ot+vbQFTV/ =I59W -----END PGP SIGNATURE----- --------------enig6741CA0FD87C2A9C28964EF3--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4882FFB7.1090501>