]> git.draconx.ca Git - upkg.git/commitdiff
Improve GOB rebuild rules for VPATH builds.
authorNick Bowler <nbowler@draconx.ca>
Fri, 31 Jan 2020 20:04:14 +0000 (15:04 -0500)
committerNick Bowler <nbowler@draconx.ca>
Fri, 31 Jan 2020 20:20:44 +0000 (15:20 -0500)
In a VPATH build, if make explicitly targets a .gobstamp in srcdir, the
.c and .h outputs currently end up in builddir while the .gobstamp ends
up in srcdir.

This behaviour can be triggered when distributed headers in srcdir are
referenced by the automatic dependency tracking and then the .gob file
is updated.

Ideally everything would always go in builddir whenever gob files are
rebuilt but it turns out this is rather difficult to get right: when
headers originally in srcdir are updated in builddir, make will not
detect all necessary rebuilds.

However we can avoid most problems by just ensuring all the files end
up wherever make is trying to update the gobstamp.  This will typically
be builddir from a clean build but may be srcdir if automatic dependency
tracking is used.  The gob2 interface is a bit annoying because we cannot
explicitly specify the output filename but it is fairly simple to work
around in the shell.

While we are here, make sure the .gobstamp timestamp precedes the
other generated files, as otherwise the deletion recovery rules will
be run every build.

Makefile.am

index bf4759d26a3aa47d8bbed7f42541a9ecb35a362b..e5140a4679fddcccc4d4b2b9ddaa7e46a6aa2768 100644 (file)
@@ -109,8 +109,12 @@ GOB_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'GOB     ' $<;
 # this rule has to make some assumptions about the source tree layout.
 .gob.gobstamp:
 if HAVE_GOB2_DYN
-       $(GOB_V) $(GOB2) -o src --file-sep=/ --no-private-header $<
-       $(AM_V_at) touch $@
+       $(AM_V_at) touch $@.tmp
+       $(GOB_V) od='$(@D)'; case $$od in \
+         src/*) od=src ;; \
+         */src/*) od=$${od%/src/*}/src ;; \
+         esac; $(GOB2) -o "$$od" --file-sep=/ --no-private-header $<
+       $(AM_V_at) mv -f $@.tmp $@
 else
 if HAVE_GOB2
        @echo "ERROR: *** $(GOB2) does not support dynamic types." 1>&2