[build] Allow running tests without the --enable-testing configuration
- Make the test targets always available (test, unit-test, functional-test) - Cleanup include paths, and bring back the CPPFLAGS in commit3e24cff
that was overwritten by the mergeca8f6df
(PR #60) - Introduce the dev-tools target for building testing/dbg tools individually - Leave the --enable-testing option for backward compatibility
This commit is contained in:
parent
050eacf4cb
commit
8014643b9e
45
Makefile.in
45
Makefile.in
@ -20,15 +20,18 @@ V=@
|
||||
|
||||
PROGRAMS=\
|
||||
bin/pdata_tools
|
||||
|
||||
ifeq ("@TESTING@", "yes")
|
||||
PROGRAMS += bin/pdata_tools_dev
|
||||
DEV_TOOLS=\
|
||||
bin/pdata_tools_dev
|
||||
TESTLIBS=\
|
||||
lib/libft.so
|
||||
endif
|
||||
|
||||
.PHONY: all
|
||||
all: $(PROGRAMS) $(TESTLIBS)
|
||||
.PHONY: all dev-tools
|
||||
all: $(PROGRAMS)
|
||||
dev-tools: $(DEV_TOOLS)
|
||||
|
||||
ifeq ("@TESTING@", "yes")
|
||||
all += $(TESTLIB)
|
||||
endif
|
||||
|
||||
include contrib/Makefile
|
||||
|
||||
@ -185,7 +188,8 @@ CXXFLAGS+=@CXXOPTIMISE_FLAG@
|
||||
CXXFLAGS+=@CXXDEBUG_FLAG@
|
||||
CXXFLAGS+=@CXX_STRERROR_FLAG@
|
||||
CXXFLAGS+=@LFS_FLAGS@
|
||||
INCLUDES+=-I$(TOP_BUILDDIR) -I$(TOP_DIR) -I$(TOP_DIR)/thin-provisioning
|
||||
CPPFLAGS?=@CPPFLAGS@
|
||||
CPPFLAGS+=-I$(TOP_BUILDDIR) -I$(TOP_DIR)
|
||||
LIBS:=-laio -lexpat -lboost_iostreams -ldl
|
||||
DEV_LIBS:=-lncurses
|
||||
|
||||
@ -211,30 +215,21 @@ INSTALL_DIR = $(INSTALL) -m 755 -d
|
||||
INSTALL_PROGRAM = $(INSTALL) -m 755
|
||||
INSTALL_DATA = $(INSTALL) -p -m 644
|
||||
|
||||
ifeq ("@TESTING@", "yes")
|
||||
TEST_INCLUDES=\
|
||||
-I$(TOP_DIR) \
|
||||
-Igoogletest/googlemock/include \
|
||||
-Igoogletest/googletest/include
|
||||
else
|
||||
TEST_INCLUDES=
|
||||
endif
|
||||
|
||||
.SUFFIXES: .d .txt .8
|
||||
|
||||
%.o: %.cc
|
||||
@echo " [CXX] $<"
|
||||
@mkdir -p $(dir $@)
|
||||
$(V) $(CXX) -c $(INCLUDES) $(CXXFLAGS) -o $@ $<
|
||||
$(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CXXFLAGS) $< > $*.$$$$; \
|
||||
$(V) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
|
||||
$(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(CPPFLAGS) $(CXXFLAGS) $< > $*.$$$$; \
|
||||
sed 's,\([^ :]*\)\.o[ :]*,\1.o \1.gmo $* : Makefile ,g' < $*.$$$$ > $*.d; \
|
||||
$(RM) $*.$$$$
|
||||
|
||||
%.o: %.c
|
||||
@echo " [CC] $<"
|
||||
@mkdir -p $(dir $@)
|
||||
$(V) $(CC) -c $(INCLUDES) $(CFLAGS) -o $@ $<
|
||||
$(V) $(CC) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CFLAGS) $< > $*.$$$$; \
|
||||
$(V) $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||
$(V) $(CC) -MM -MT $(subst .cc,.o,$<) $(CPPFLAGS) $(CFLAGS) $< > $*.$$$$; \
|
||||
sed 's,\([^ :]*\)\.o[ :]*,\1.o \1.gmo $* : Makefile ,g' < $*.$$$$ > $*.d; \
|
||||
$(RM) $*.$$$$
|
||||
|
||||
@ -275,7 +270,7 @@ clean:
|
||||
find . -name \*.o -delete
|
||||
find . -name \*.gmo -delete
|
||||
find . -name \*.d -delete
|
||||
$(RM) $(PROGRAMS) lib/*.a lib/*.so
|
||||
$(RM) $(PROGRAMS) $(DEV_TOOLS) lib/*.a lib/*.so
|
||||
|
||||
distclean: clean
|
||||
$(RM) config.cache config.log config.status configure.h version.h Makefile unit-tests/Makefile
|
||||
@ -360,7 +355,8 @@ install-rust-tools: man8/thin_metadata_pack.8 man8/thin_metadata_unpack.8 rust-t
|
||||
$(INSTALL_DATA) man8/thin_metadata_pack.8 $(MANPATH)/man8
|
||||
$(INSTALL_DATA) man8/thin_metadata_unpack.8 $(MANPATH)/man8
|
||||
|
||||
ifeq ("@TESTING@", "yes")
|
||||
#----------------------------------------------------------------
|
||||
|
||||
include unit-tests/Makefile
|
||||
|
||||
LIBFT_SOURCE=\
|
||||
@ -376,10 +372,11 @@ lib/libft.so: $(LIBFT_OBJECTS)
|
||||
|
||||
.PHONEY: functional-test unit-test
|
||||
|
||||
functional-test: $(PROGRAMS) $(TESTLIBS)
|
||||
functional-test: $(PROGRAMS) $(DEV_TOOLS) $(TESTLIBS)
|
||||
cd functional-tests && ./run-tests run
|
||||
|
||||
test: functional-test unit-test
|
||||
endif
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
||||
-include $(DEPEND_FILES)
|
||||
|
@ -81,9 +81,9 @@ TEST_OBJECTS=$(subst .cc,.gmo,$(TEST_SOURCE))
|
||||
%.gmo: %.cc
|
||||
@echo " [CXX] $<"
|
||||
@mkdir -p $(dir $@)
|
||||
$(V) $(CXX) -c $(TEST_INCLUDES) $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) -o $@ $<
|
||||
$(V) $(CXX) -c $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) -o $@ $<
|
||||
@echo " [DEP] $<"
|
||||
$(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(TEST_INCLUDES) $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) $< > $*.$$$$; \
|
||||
$(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) $< > $*.$$$$; \
|
||||
sed 's,\([^ :]*\)\.o[ :]*,\1.o \1.gmo $* : Makefile ,g' < $*.$$$$ > $*.d; \
|
||||
$(RM) $*.$$$$
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user