[Swan-dev] Some makefile variable tweaks

Andrew Cagney andrew.cagney at gmail.com
Thu Jan 22 04:06:55 EET 2015


[inline, snipped]

On 21 January 2015 at 13:46, D. Hugh Redelmeier <hugh at mimosa.com> wrote:

> |  I'd like to
> | impose a little of my view of sanity on the following:
> |
> | - while OBJDIR is assumed, make files are hedging their bets
> | -> I'll remove code assuming otherwise
>
> Good!  The fewer cases the better.
>
> In fact, I'd like make to be invoked with --warn-undefined-variables
>
> This is likely to force a lot of work but I think that it would pay off.
> Accidental misspellings are easy to make but hard to find in something
> as complicated as our makefiles.

I didn't know about --warn-undefined-variables.

> | - $(srcdir) and $(SRCDIR) are kind of redundant, while they might
> | designate the same directory they are not even internally consistent.
>
> Not sure what you mean, but it sounds bad.
>
> "kind of redundant" scares me because I wonder just when are they not
> redundant.
>
> | For instance, "./", "$PWD" and "$PWD/" are all found
>
> You mean as definitions for SRCDIR?

$ find  * -name 'Makefile*' -print | xargs grep -i -e '^srcdir'
...
initsystems/sysvinit/Makefile:srcdir?=${LIBRESWANSRCDIR}/initsystems/sysvinit/
lib/Makefile:srcdir?=$(shell pwd)/
lib/libcrypto/libsha2/Makefile:srcdir?=./
Makefile:srcdir?=$(shell pwd)
testing/lib/libpluto/Makefile:SRCDIR=${srcdir}

(and the recursive makes pass down srcdir=${srcdir}$${subdir}/ )

making the change fairly close to current reality

> | -> I'll remove the existing $(srcdir) definition, and have SRCDIR be
> | consistent - absolute and with a trailing / - so existing code works
>
> I don't like the trailing / being in the variable.  Making the /
> explicit in each use makes the use clearer.

> | - add a full set of directory variables THAT DO NOT ADD A TRAILING /
> | so I can use those.
>
> Ah, so you don't like trailing /.  Does anyone else?  Why can't we
> just ditch it?  Perhaps a simple matter of a sed script.

I did try that but backed away (this change was done with sed also).
Once more stuff is tidied up it should be possible to zap it.

On the other hand, while I can't test everything the risks of changing
just srcdir->SRCDIR and (mostly) preserving the / are relatively low.

> |  For names I stole from autoconf: relative:
> | srcdir, builddir, top_srcdir, top_builddir; absolute: abs_srcdir,
> | abs_top_srcdir, abs_builddir abs_top_builddir.
>
> I'd prefer that this wasn't redundant.  If SRCDIR is always $(srcdir)/
> then get rid of SRCDIR.
>
> I kind of like all uppercase variable names.  I'm not sure that I can
> defend that preference.

Agreed.  For me convention trumps personal aesthetics.


More information about the Swan-dev mailing list