A style proposal for referring to upper-level directories in Makefiles

Garrett Cooper yanegomi at gmail.com
Thu Jul 28 22:30:14 UTC 2011


On Thu, Jul 28, 2011 at 11:47 AM, 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?

    This might cause issues with symlink traversal (it's the one thing
that came to mind). It wouldn't be a standard way to do things, but it
could cause problems if this change was made.
Thanks,
-Garrett


More information about the freebsd-hackers mailing list