Tue, Aug 16, 2011 at 01:09:32PM +0100, Matt Burke wrote:
> How does the build process know about the non-symlinked path anyway?
> I can't see where (or understand why) it uses "pwd -P"

Make(1)'s .OBJDIR is used:
{{{
     .OBJDIR         A path to the directory where the targets are built.  At
                     startup, make searches for an alternate directory to
                     place target files.  It will attempt to change into this
                     special directory and will search this directory for
                     makefiles not found in the current directory.  The fol-
                     lowing directories are tried in order:

                     1.   ${MAKEOBJDIRPREFIX}/`pwd`
                     2.   ${MAKEOBJDIR}
                     3.   obj.${MACHINE}
                     4.   obj
                     5.   /usr/obj/`pwd`

                     The first directory that make successfully changes into
                     is used.  If either MAKEOBJDIRPREFIX or MAKEOBJDIR is set
                     in the environment but make is unable to change into the
                     corresponding directory, then the current directory is
                     used without checking the remainder of the list.  If they
                     are undefined and make is unable to change into any of
                     the remaining three directories, then the current direc-
                     tory is used.  Note, that MAKEOBJDIRPREFIX and MAKEOBJDIR
                     must be environment variables and should not be set on
                     make's command line.

                     The make utility sets .OBJDIR to the canonical path given
                     by getcwd(3).
}}}
getcwd(3) always fully resolves current path, so symlinking
won't be taken into account.

> I'm trying to setup a box to do automated FreeBSD builds for other hosts
> from multiple source trees.
> 
> I have a couple of source trees mounted - for legibility's sake let's say
> /build/stable and /build/current. I also have a few obj dirs for different
> targets. The current obj tree is symlinked to /usr/obj, and this works fine.
> 
> The problem comes when I symlink /usr/src: when I buildworld, I get
> /usr/obj/build/current/[...] instead of the desired /usr/obj/usr/src/[...]
> This is presumably fine when installing on the same machine, but it breaks
> when using it on another host with /usr/src and /usr/obj mounted over nfs.

Hmm, current Makefile system for src sets MAKEOBJDIRPREFIX via ?=, so
you're out of luck with symlinking on the build machine.  May be you
can mount /build/stable or /build/current on the target machine via
NFS (and, of course, /usr/obj or other directory that you can choose
with the MAKEOBJPREFIX, this leaves room for multi-architecture object
trees on the same build host) and invoke make from the relevant
directory?

Another possibility, if for some reason you want /usr/src to point to
the correct place at your "destination" machines, to always mount
/build across hosts where you're installing the stuff and to symlink
/usr/src to the proper location inside the /build.
-- 
Eygene Ryabinkin                                        ,,,^..^,,,
[ Life's unfair - but root password helps!           | codelabs.ru ]
[ 82FE 06BC D497 C0DE 49EC  4FF0 16AF 9EAE 8152 ECFB | freebsd.org ]

Attachment: pgp1Ikwq7VChK.pgp
Description: PGP signature

Reply via email to