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>
This commit is contained in:
parent
b11b36ebdb
commit
f3ec118ab7
28
Makefile
28
Makefile
|
@ -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-32 > ioctl-test-32.log
|
||||||
$(Q)./ioctl-test-64 > ioctl-test-64.log
|
$(Q)./ioctl-test-64 > ioctl-test-64.log
|
||||||
|
|
||||||
library-test: library-test.o messages.o $(libs_shared)
|
library-test: library-test.c messages.o $(libs_shared)
|
||||||
@echo " [LD] $@"
|
@echo " [TEST PREP] $@"$(eval TMPD=$(shell mktemp -d))
|
||||||
$(Q)$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -Wl,-rpath=$(TOPDIR) -lbtrfs
|
$(Q)mkdir -p $(TMPD)/include/btrfs && \
|
||||||
@echo " [TEST] $@"
|
cp $(libbtrfs_headers) $(TMPD)/include/btrfs && \
|
||||||
$(Q)./$@
|
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.static.o messages.static.o $(libs_static)
|
library-test.static: library-test.c messages.static.o $(libs_static)
|
||||||
@echo " [LD] $@"
|
@echo " [TEST PREP] $@"$(eval TMPD=$(shell mktemp -d))
|
||||||
$(Q)$(CC) $(STATIC_CFLAGS) -o $@ $^ $(STATIC_LDFLAGS) $(libs_static) $(STATIC_LIBS)
|
$(Q)mkdir -p $(TMPD)/include/btrfs && \
|
||||||
@echo " [TEST] $@"
|
cp $(libbtrfs_headers) $(TMPD)/include/btrfs && \
|
||||||
$(Q)./$@
|
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
|
test-build: test-build-pre test-build-real
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue