From: Nick Bowler Date: Fri, 31 Jan 2020 20:04:14 +0000 (-0500) Subject: Improve GOB rebuild rules for VPATH builds. X-Git-Url: http://git.draconx.ca/gitweb/upkg.git/commitdiff_plain/db03b6ae47317f74767e4850da14a02afaa90d6b Improve GOB rebuild rules for VPATH builds. 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. --- diff --git a/Makefile.am b/Makefile.am index bf4759d..e5140a4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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