On Wed, Aug 28, 2019 at 10:19 PM Bram Moolenaar <
Br...@moolenaar.net> wrote:
>
>
> > Recently you've been proposing (and Bram has accepted) to create a lot
> > of new source files to make the existing source easier to understand.
> > The notion is laudable but it doesn't work well with my shadow
> > directories: every time there is a new .c source (or .h; .pro sources
> > are taken care of automatically by virtue of their being in a special
> > src/proto directory for which a symlink has ben creted once and for
> > all in the shadow directory), I have to manually create a symlink
> > newsourcename.c -> ../newsourcename.c in each shadow directory,
> > otherwise the "make" step ends in error with "No rule to make
> > newsourcename.c. Stop.".
> >
> > Do you think the following rule (added to the src/Makefile which is
> > soft-linked from every shadow directory) could take care of my problem
> > without undesired side-effects?
> >
> > *: ../$@
> > ln -sv ../$@
> >
> > The idea is to create a link if a needed file exist inthe parent (src)
> > directory but not in the current (shadow) directory. Maybe the target
> > sould be made less general to avoid using this rule out of turn.
>
> What happens with "make foo"? Doesn't it execute "ln -sv ../foo" then?
> Or say "../foo" does not exist"? Both are very confusing.
"make foo" wouldn't work because there is no ../foo (i.e. no src/foo).
But maybe we should restrict the target to *.c and *.h. What I
wouldn't want is to add an unnecessary prerequisite for, for instance,
"phony" targets such as "install" or "reconfig".
I don't usually write Makefiles though I can more or less understand
those already written, so I suppose my proposed rule needs
fine-tuning. Normally (barring typing errors) this proposed rule would
be invoked _only_ as an implicit rule to make some prerequisite of
some *.o object needed for the link phase.
Once the softlink has been created, it will of course not be created
again, because thereafter the src/shadow/something.c exists (as a
symlink) and has the exact same date as its prerequisite, the
src/something.c to which the link points.
>
> Perhaps we can the "ln" line from "make shadow" and add it with a
> "shadowupdate" target:
>
> shadowupdate:
> ln -s ../*.[chm] ../*.in ../*.sh ../*.xs ../*.xbm ../gui_gtk_res.xml ../toolcheck ../proto ../libvterm ../vimtutor ../gvimtutor ../install-sh ../Make_all.mak .
>
> Probably reports a lot of error for already existing links.
Yeah, and BTW src/Make_all.mak is a very short file, only defining the
variable TAGS.
I think we can afford to assume that ../proto ../Makefile ../runtime
and some others are already correctly set (by virtue of "make shadow"
having been run at some point in the past). If possible, I'd like to
avoid "useless work" trying to recreate already existing links,
especially if it produces lots of error messages. What I propose is
that the make program will either (a) find that the *.c or *.h exists
in the shadowdir, has (by virtue of how the symlink was created) the
same date as its only prerequisite (the file by the same name one
level higher) and therefore doesn't need to be remade; or (b, less
often) find that it is not present in the shadowdir but is present one
level higher, and therefore can be remade by creating a symlink.
Best regards,
Tony.