On Fri, Apr 07, 2017 at 11:38:07AM +0100, Alex Bennée wrote: > > Thomas Huth <thuth@xxxxxxxxxx> writes: > > > On 06.04.2017 21:07, Alex Bennée wrote: > >> When doing an out-of-src-tree build we still want access to the > >> various bits of common script machinery to run. This is handled by the > >> scripts-common list which sub-builds can add explicit extra stuff to. > >> > >> The final rule is conditional so we don't attempt to link files when > >> we are doing an in-src-tree build. > >> > >> Signed-off-by: Alex Bennée <alex.bennee@xxxxxxxxxx> > >> --- > >> Makefile | 13 +++++++++++++ > >> x86/Makefile.common | 4 ++++ > >> 2 files changed, 17 insertions(+) > >> > >> diff --git a/Makefile b/Makefile > >> index 56598df..c9fea88 100644 > >> --- a/Makefile > >> +++ b/Makefile > >> @@ -31,6 +31,10 @@ cflatobjs := \ > >> lib/report.o \ > >> lib/stack.o > >> > >> +# These are scripts we want linked from the source tree > >> +scripts-common := run_tests.sh \ > >> + scripts > >> + > >> # libfdt paths > >> LIBFDT_objdir = $(SRCDIR)/lib/libfdt > >> LIBFDT_srcdir = $(SRCDIR)/lib/libfdt > >> @@ -86,8 +90,17 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS)) > >> mkdir -p $(dir $@) > >> $(CC) $(CFLAGS) -c -o $@ $< > >> > >> +$(scripts-common): $(SRCDIR)/$@ > >> + ln -sf $<$@ $@ > > > > The prerequisite does not seem to work correctly here. I can see that > > the symlinks are regenerated each time I run make. Even worse, during > > the second run, there is a > > > > ln -sf /home/thuth/devel/kvm-unit-tests/scripts scripts > > > > which generates a symlink in the source directory, since the "scripts" > > symlink already exists! > > > > I think you can not use automatic variables like $@ in the prerequisite > > list, can you? > > > > Maybe it would be better to create these symlinks in the configure > > script already? > > Hmm maybe. The trouble is catching them all. That's why I wanted to have > something like scripts-common that sub Makefiles could add to. > > We could certainly make the rule a bit more robust against re-linking > though. I think I'd prefer configure doing this linking. I don't think we'll ever have more than ln -sf "$srcdir/$testdir/run" $testdir/ ln -sf "$srcdir/$testdir/unittests.cfg" $testdir/ ln -sf "$srcdir/run_tests.sh" ln -sf "$srcdir/scripts" (And now I see what we want an absolute path for $srcdir.) Thanks, drew