Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 08 Mar 2019 00:39:08 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 236380] `auto.obj.mk` uses incorrect test for relative pathed `obj` directory.
Message-ID:  <bug-236380-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D236380

            Bug ID: 236380
           Summary: `auto.obj.mk` uses incorrect test for relative pathed
                    `obj` directory.
           Product: Base System
           Version: 11.2-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: parakleta@darkreality.org

If using a Makefile with the following:

```
MK_AUTO_OBJ=3Dyes
.include <auto.obj.mk>
```

the first time `make` is run results in an error starting with:

```
make: "/usr/share/mk/auto.obj.mk" line 61: could not use obj: .OBJDIR=3D
```

This error is generated by the following block of code:

```
.OBJDIR: ${__objdir}
.if ${.OBJDIR:tA} !=3D ${__objdir:tA} && ${__objdir_made:Uno:M${__objdir}/*=
} !=3D
""=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
.error could not use ${__objdir}: .OBJDIR=3D${.OBJDIR}
.endif
```

The reason for this is that the use of the `.OBJDIR` target changes the cur=
rent
directory and thus if `__objdir` is a relative path then it can no longer be
found.  The man page for `make` states that:

    =E2=80=98.OBJDIR=E2=80=99 may be modified in the makefile via the speci=
al
    target =E2=80=98.OBJDIR=E2=80=99.  In all cases, make will chdir(2) to
    the specified directory if it exists, and set =E2=80=98.OBJDIR=E2=80=99
    and =E2=80=98PWD=E2=80=99 to that directory before executing any target=
s.

I believe the solution is to convert `__objdir` to an absolute path after it
has been created (and thus can be found) but before changing `.OBJDIR`.  Th=
at
is, immediately before the block of code quoted above from line 59, add the
following line:

```
__objdir:=3D ${__objdir:tA}
```

After this it is no longer necessary to use absolute paths in the following
test so these can be removed.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-236380-227>