Using --make with -odir and hierarchical modules
Thu, 16 Jan 2003 21:00:11 -0500

Martin Norb=E4ck wrote:

> What should be done about it?
> =

> Solution 1: -odir is relative to the source directory (files will end u=
> in Library/Bar/output/Module.o and Library/Foo/output/Module.o).
> This is a change of semantics from the earlier behaviour of -odir (file=
> are put in another place). On the other hand, it may be more natural to=

> put files relative to their source, like --make without -odir does. The=

> question remains what to do if -odir is an absolute path.

Perhaps a more fundamental question than what is "natural" is what the
intended use of "-odir" is and what is most useful in that context.

One might also want "-odir" and "-hidir" to behave similarly, even
though the role or .hi files and .o files are rather different.

> Solution 2: files put in -odir are put in directories (files will end u=
> in Program/output/Bar/Module.o and Program/output/Foo/Module.o)
> This is also a slight change in semantics, since files are put in
> directories. May affect Makefiles that does "ar output/*.o" or similar.=

Well, ar does not support directories anyway, so if the objective here is=

to build a link library, the leaf names had better be distinct. (At least=

GNU make does seem to allow putting two object files with the same name
into a link library if done as a single operation, but my guess is that
doing so is asking for trouble.)

> Solution 3: files put in -odir will have their full module name (files
> will end up in Program/Output/Bar.Module.o and
> Program/Output/Foo.Module.o)
> This is an ever lesser change in semantics, and is better than solution=

> 2 in my opinion.

At least that would ensure unique names in archives.

On the other hand, "-odir" should preferably work the same way regardless=

of whether "--make" is used or not. And if "--make" is not used, a tool
like "Make" is probably used instead. And in that case, it is often
usefull to be able to derive the output file name from the input file
name, which would seem hard with solution 3. But then again, if
"Make" is used, it might not be necessary to use "-odir" in the first
place. Since compilation is taking place file by file, "-o" should be
enough to put files wherever they need to go.

> I would recommend using solution 1 if the path name is relative and
> solution 3 if it's absolute.

This seems both a bit complicated and error prone and to me. Moreover,
there are all sorts of reasons for why one in some cases might want to us=
a relative path name and in other cases a relative one, and I would be
surprised if these reasons coinside with a desire to use solution 1
whenever the path is relative and solution 3 otherwise.

So whatever the best solution is, don't make it depend on the form of
the path.

All the best,


-- =

Henrik Nilsson
Yale University
Department of Computer Science