[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MAKEOBJDIRPREFIX basically broken...



Continuing the endless list of make problems...
I now consider MAKEOBJDIRPREFIX broken, except for the simplest cases.

Look at the way OpenBSD source tree gets configured, specifically, have a
look at the obj links that get created with make obj: they don't mirror
the whole structure of the source tree.
Looking more closely, you can split the directories between leaf-directories,
where stuff actually gets built, and intermediate directories, which only
trigger submakes. 

Right now, a rule such as:
build:
	make cleandir

cleandir:
	blah blah blah

can't work if there exist an object link in the directory (try to 
ln -s /usr/obj /usr/src/obj for fun)

Why ? pretty simple:
- make notices an obj link in the current directory, so it sets
${.CURDIR} to the curdir, ${.OBJDIR} to the obj link, and does a chdir(obj).
- there is nothing magical about the `make cleandir' call. This does indeed
invoke a submake, which is invoked from obj; this one has lost the right
notion of a curdir, and can't even find its makefile.

That one is fixable, with some magic. It's just a question of telling the
submake that, even though it was invoked in objdir, it should really look
into srcdir, e.g., for instance, set up an env variable MAKEFUDGE that
holds objdir:curdir before exec'ing the submake, and let make check the
current directory against MAKEFUDGE. If it matches, magically revert to
the real current directory.

The real trouble starts when this gets more complicated. So far, the first
offender I've seen is libssl, which does generate include files. It would
work, except that src/lib/libssl/crypto/Makefile has some seriously kludged
include paths... from the name, you can assume that LCRYPTO_SRC would
point to the src/lib/libssl/src/crypto/ directory, except that this is not
where the include files do get generated, and indeed this Makefile gets
invoked in a submake, which means the corresponding include path does
point to obj/lib/libssl/src/crypto...

Other intricate directory structures will fail as well, or get highly 
error-prone.

Solutions welcome, or at least hints of which direction I should proceed in.
Right now, I think I'm going to proclaim MAKEOBJDIRPREFIX broken and 
remove ALL support from the current version of make.

This is not satisfying at all, as all the intrincacies of the current make 
build process stay as opaque as they were. We're already at the point where
things break from time to time and take rather long to fix, as it is
difficult to get a grip on what's going on.
-- 
	Marc Espie		
|anime, sf, juggling, unicycle, acrobatics, comics...
|AmigaOS, OpenBSD, C++, perl, Icon, PostScript...
| `real programmers don't die, they just get out of beta'


Visit your host, monkey.org