From dea730f4af098c0369a245c4c5089d027c56fe5b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 3 May 2019 15:58:04 -0400 Subject: [PATCH] bt2: Fix Makefile dependency tracking when building out of tree The problem, from the point of view of the developer: 1. Build out of tree, python bindings enabled. 2. Modify a bindings source file (e.g. trace_class.py, native_bt_trace.i). 3. Type "make" in the builddir. 4. The bindings are not rebuilt from the new source files. 5. Sad. When we build out of tree, it's done in two steps (assume $builddir is $top_builddir/bindings/python): 1. Copy all the static files (those checked in the repo, not generated at runtime) from $srcdir/bt2 to $builddir/bt2. Those files are placed next to other files that are generated (__init__.py, setup.py). Together, they form the complete source of the bt2 package. 2. Run setup.py, which runs SWIG and outputs the built package in $builddir/build_lib. The problem described above happens because of how the dependencies are stated for step #1: STATIC_BINDINGS_DEPS = ... bt2/native_bt_trace.i ... copy-static-deps.stamp: $(STATIC_BINDINGS_DEPS) When nothing exists yet in the build directory, bt2/native_bt_trace.i is resolved to the version in the srcdir (because of make's VPATH, I believe), so it works fine. But once the copied files exist, and you try to change the source files and "make" again, the dependency bt2/native_bt_trace.i will be resolved to the version in the build dir. Since that version is not newer than copy-static-deps.stamp, nothing is done. The fix it, we can force the dependency to be the one in the source directory, by prepending $(srcdir) to each file. Change-Id: Ic09d430e53b59e5afa9ebb19d98ba219dff16537 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/1250 Reviewed-by: Philippe Proulx --- bindings/python/bt2/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/bt2/Makefile.am b/bindings/python/bt2/Makefile.am index 6482d0c2..bc5c7f18 100644 --- a/bindings/python/bt2/Makefile.am +++ b/bindings/python/bt2/Makefile.am @@ -70,7 +70,7 @@ BUILD_FLAGS=CC="$(CC)" \ all-local: build-python-bindings.stamp -copy-static-deps.stamp: $(STATIC_BINDINGS_DEPS) +copy-static-deps.stamp: $(addprefix $(srcdir)/, $(STATIC_BINDINGS_DEPS)) @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ for file in $(STATIC_BINDINGS_DEPS); do \ cp -f $(srcdir)/$$file $(builddir)/$$file; \ -- 2.34.1