A style proposal for referring to upper-level directories in
Makefiles
Chris Rees
crees at freebsd.org
Thu Jul 28 20:55:31 UTC 2011
On 28 July 2011 19:47, Mikhail T. <mi+thun at aldan.algebra.com> wrote:
> The most common method to refer to the upper directory in Makefile is as
> ${.CURDIR}/..
>
> I'd like to propose we begin using ${.CURDIR:H} instead. For one this speeds
> up the filesystem-traversal for the invoked tool. And, perhaps more
> importantly, it makes the various build-logs look nicer (and be smaller).
> The lines in Makefiles will also be shorter (two characters per level
> instead of three). For example:
>
> --- secure/Makefile.inc 3 Aug 2009 08:13:06 -0000 1.25.10.1
> +++ secure/Makefile.inc 28 Jul 2011 18:45:52 -0000
> @@ -3,8 +3,8 @@
> .include <bsd.own.mk>
>
> -.if exists(${.CURDIR}/../../lib/libcrypt/obj)
> -CRYPTOBJDIR= ${.CURDIR}/../../lib/libcrypt/obj
> +.if exists(${.CURDIR:H:H}/lib/libcrypt/obj)
> +CRYPTOBJDIR= ${.CURDIR:H:H}/lib/libcrypt/obj
> .else
> -CRYPTOBJDIR= ${.CURDIR}/../../lib/libcrypt
> +CRYPTOBJDIR= ${.CURDIR:H:H}/lib/libcrypt
> .endif
>
> @@ -14,4 +14,4 @@
>
> .if ${MK_OPENSSH} != "no"
> -SSHDIR= ${.CURDIR}/../../../crypto/openssh
> +SSHDIR= ${.CURDIR:H:H:H}/crypto/openssh
> .endif
>
> The new method is functionally equivalent to the old and I see no drawbacks
> to it, do you?
>
> -mi
Not too convinced I'm afraid-- in the logs I can at least see at a
glance where ${CURDIR} is, and how many directories it's traversing
etc etc.
Chris
More information about the freebsd-hackers
mailing list