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/>

index | next in thread | raw e-mail

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236380

            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=yes
.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=
```

This error is generated by the following block of code:

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

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

    ‘.OBJDIR’ may be modified in the makefile via the special
    target ‘.OBJDIR’.  In all cases, make will chdir(2) to
    the specified directory if it exists, and set ‘.OBJDIR’
    and ‘PWD’ to that directory before executing any targets.

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`.  That
is, immediately before the block of code quoted above from line 59, add the
following line:

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

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

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

help

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