[SUBDIRMK RFC 0/7 option A/B] Bikeshed colours

Ian Jackson ijackson at chiark.greenend.org.uk
Wed Dec 11 16:37:07 GMT 2019


I recently posted on my blog asking for feedback about the details of
subdirmk syntax:
  subdirmk - ergonomic preprocessing assistant for non-recursive make
  https://diziet.dreamwidth.org/3604.html

As a result of some very useful comments by private email I am
proposing some changes.

The first 5 look pretty good to me.

   1  README: v2: Introduce &:changequote
   2  README: v2: Use &@ for escaping; abolish \&
   3  README: v2: Define &:section
   4  README: v2: Refine &TARGETS_things, mostly to avoid # wrinkle
   5  README: v2: Provide &$VARIABLE


This next one needs some more thought to see if it makes any kind of
sense, or needs to be more sophisticated:

   6  README: v2: Draft - macro assistance facility

See the commit message for detailed questions on 6.


These next two are two alternative ways to deal with the awkwardness
that is &=/ etc. and the lack of a version of (say) &^ that gives the
directory name.  They take radically different approaches.

   7A README: v2: Draft - Introduce &. and friends
   7B README: v2: Draft - Use / for variable names too.


7A is a minor tweak to the syntax, introducing `.' to refer to the
directory ("sub/dir or ."), leaving &= (or perhaps some other similar
thing) for "sub/dir or TOP".

Comments on the choice of &= for this facility (probably rarely-used,
but necessary as it is a baseline) welcome.


7B is based on the observation that / is legal in make variable names.
It abolishes the distinction between "&/" and "&_", and consequently
the case convention about filenames.  The downside is that now the
top-level's local variables must be named "./variable" which is rather
odd, and the top-level's local files end up always prefixed by "./" in
commands which uglifies output etc.

I rejected as too hazardous and annoying the alternative of making the
top-level and global namespaces the same.

It would also have been possible to do only part of 7B - eg providing
two different expansions intended for variables and filenames which
differ only at the toplevel (producing "TOP/" and "", but this seems
like a UI beartrap.


I've included below the core syntax spec after each of 7A and 7B.

Ian.


-8<- 7A key README section on syntax

&CAPS		=>	sub_dir_CAPS			or TOP_CAPS
&lc		=>	sub/dir/lc			or lc
	Here CAPS is any ASCII letter A-Z and lc is a-z.
	The assumption is that filenames are usually lowercase and
	variables usually uppercase.  Otherwise, use another syntax:

&/		=>	sub/dir/			or nothing
&_		=>	sub_dir_			or TOP_
&.		=>	sub/dir				or .
	(This implies that `&./' works roughly like `&/', although
	it can produce a needless `./')

&=		=>	sub_dir				or TOP
^^^ rarely needed.  TBD, maybe one of
	&._ &_. &\_ &% &$_
	&<varnameprefix>  &[varnameprefix]
	$(patsubst %_,&_,%)

&^lc		=>	$(top_srcdir)/sub/dir/lc
&^/		=>	$(top_srcdir)/sub/dir/
&^.		=>	$(top_srcdir)/sub/dir

&~lc		=>	$(top_srcdir)/lc
&~/		=>	$(top_srcdir)/
&~.		=>	$(top_srcdir)

In general:
    ^   pathname of this subdirectory in source tree
    ~   pathname of top level of source tree
    /	terminates the path escape } needed if next is
    _   terminates the var escape  } not lwsp or space)
    .   terminates path escape giving dir name (excluding /)
    =	terminates var escape giving only prefix part (rarely needed)
  lwsp  starts multi-word processing (see below)



-8<- 7B key README section on syntax

&alpha		=>	sub/dir/alpha			or ./alpha
	Here alpha is any ASCII letter A-Za-z.
	The assumption is that filenames and variables usually
	start with a letter.  Otherwise, use another syntax:

&/		=>	sub/dir/			or nothing
&.		=>	sub/dir				or .
	(This implies that `&./' works much like `&/'. &./ is
	suitable for variable name construction in a way &/ is not.)

&^alpha		=>	$(top_srcdir)/sub/dir/alpha
&^/		=>	$(top_srcdir)/sub/dir/
&^.		=>	$(top_srcdir)/sub/dir

&~alpha		=>	$(top_srcdir)/alpha
&~/		=>	$(top_srcdir)/
&~.		=>	$(top_srcdir)

In general:
    ^   pathname of this subdirectory in source tree
    ~   pathname of top level of source tree
    /	terminates the escape (needed if next is not lwsp, alpha or `.')
    .	terminates the escape, gives subdir without /
  lwsp  starts multi-word processing (see below)

&_		=>	ERROR (for compat with v1)


-- 
2.11.0




More information about the sgo-software-discuss mailing list