Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jul 2011 14:47:53 -0400
From:      "Mikhail T." <mi+thun@aldan.algebra.com>
To:        hackers@FreeBSD.org
Subject:   A style proposal for referring to upper-level directories in Makefiles
Message-ID:  <4E31AED9.4000105@aldan.algebra.com>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E31AED9.4000105>