Skip to content

Use CURDIR instead of PWD in Makefile #3

@timblaktu

Description

@timblaktu

If you are using GNU make you should use CURDIR instead of PWD in Makefile. This should eliminate the need for your PWD ?= pwd_unknown caution.

PWD is not a built-in make variable. It comes from the environment and is usually but not always passed to make as if it was a make variable. From the autoconf special shell variable docs:

Posix 1003.1-2001 requires that cd and pwd must update the PWD environment variable to point to the logical name of the current directory, but traditional shells do not support this. This can cause confusion if one shell instance maintains PWD but a subsidiary and different shell does not know about PWD and executes cd; in this case PWD points to the wrong directory. Use ``pwd' rather than $PWD'.

CURDIR, OOTH, is:

Set to the absolute pathname of the current working directory (after all -C options are processed, if any).

Reference:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions