bt2: Fix Makefile dependency tracking when building out of tree
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 3 May 2019 19:58:04 +0000 (15:58 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 4 May 2019 01:52:28 +0000 (21:52 -0400)
commitdea730f4af098c0369a245c4c5089d027c56fe5b
tree8ae9367f848f4cfee2a63fd2082a483c8928d90a
parent95dc9c849ed229971f663b54841d8729c7495f47
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1250
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
bindings/python/bt2/Makefile.am
This page took 0.026791 seconds and 4 git commands to generate.