diff options
author | David Sterba <dsterba@suse.com> | 2017-03-13 17:01:28 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-03-16 17:02:44 +0100 |
commit | f3ec118ab764927895b429001561a1b96458574a (patch) | |
tree | 7a650fafd02fe66679a54ec7e63f38da0bdf9696 | |
parent | b11b36ebdb92b1c8ea039e26208af599e77fb882 (diff) |
btrfs-progs: library-test: update test to build outside of topdir
We need to build outside of the topdir so we can use the "btrfs/" prefix
for includes and not accidentally include other files.
Make magic is simple:
- build dependencies inside TOPDIR
- build inside temporary directory, link back to TOPDIR
- library-test.o not built anymore obviously
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | Makefile | 30 |
1 files changed, 19 insertions, 11 deletions
@@ -446,17 +446,25 @@ test-ioctl: ioctl-test ioctl-test-32 ioctl-test-64 $(Q)./ioctl-test-32 > ioctl-test-32.log $(Q)./ioctl-test-64 > ioctl-test-64.log -library-test: library-test.o messages.o $(libs_shared) - @echo " [LD] $@" - $(Q)$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -Wl,-rpath=$(TOPDIR) -lbtrfs - @echo " [TEST] $@" - $(Q)./$@ - -library-test.static: library-test.static.o messages.static.o $(libs_static) - @echo " [LD] $@" - $(Q)$(CC) $(STATIC_CFLAGS) -o $@ $^ $(STATIC_LDFLAGS) $(libs_static) $(STATIC_LIBS) - @echo " [TEST] $@" - $(Q)./$@ +library-test: library-test.c messages.o $(libs_shared) + @echo " [TEST PREP] $@"$(eval TMPD=$(shell mktemp -d)) + $(Q)mkdir -p $(TMPD)/include/btrfs && \ + cp $(libbtrfs_headers) $(TMPD)/include/btrfs && \ + cd $(TMPD) && $(CC) -I$(TMPD)/include -o $@ $(addprefix $(TOPDIR)/,$^) -Wl,-rpath=$(TOPDIR) -lbtrfs + @echo " [TEST RUN] $@" + $(Q)cd $(TMPD) && ./$@ + @echo " [TEST CLEAN] $@" + $(Q)$(RM) -rf -- $(TMPD) + +library-test.static: library-test.c messages.static.o $(libs_static) + @echo " [TEST PREP] $@"$(eval TMPD=$(shell mktemp -d)) + $(Q)mkdir -p $(TMPD)/include/btrfs && \ + cp $(libbtrfs_headers) $(TMPD)/include/btrfs && \ + cd $(TMPD) && $(CC) -I$(TMPD)/include -o $@ $(addprefix $(TOPDIR)/,$^) $(STATIC_LDFLAGS) $(STATIC_LIBS) + @echo " [TEST RUN] $@" + $(Q)cd $(TMPD) && ./$@ + @echo " [TEST CLEAN] $@" + $(Q)$(RM) -rf -- $(TMPD) test-build: test-build-pre test-build-real |