Skip to contentSkip to conversation

master - build: fix build rules for srcdir

PATCH Zdenek Kabelac 1 participant 1 message May 12, 2018 Kbuild

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e2c766d37e20231db48e55edb5e23973df590569
Commit:        e2c766d37e20231db48e55edb5e23973df590569
Parent:        ac768a9d2baca83bd9043d4d36f8e436894d29f7
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Sat May 12 18:14:53 2018 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Sat May 12 18:18:23 2018 +0200

build: fix build rules for srcdir

It's very hard to use some 'non-recurive' Makefiles with rest of system running 'recursively'.

So ATM drop inclusion of subdir makefile and add support for 2 new top-level targets:

unit-test (builds test/unit dir) run-unit-test (build & run test/unit/unit-test run)

---
 Makefile.in           |   13 ++++-----
 test/Makefile.in      |   10 +++++--
 test/unit/Makefile.in |   67 ++++++++++++++++++++++++++++--------------------
 3 files changed, 52 insertions(+), 38 deletions(-)
Makefile.in +6 -7
index 3274f17..b0bceb0 100644
@@ -1,6 +1,6 @@
 #
 # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
-# Copyright (C) 2004-2015 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2004-2018 Red Hat, Inc. All rights reserved.
 #
 # This file is part of LVM2.
 #
@@ -61,6 +61,9 @@ po: tools daemons
 man: tools
 all_man: tools
 scripts: liblvm libdm
+test: lib
+unit-test: lib
+run-unit-test: unit-test
 
 lib.device-mapper: include.device-mapper
 libdm.device-mapper: include.device-mapper
@@ -96,7 +99,7 @@ endif
 DISTCLEAN_TARGETS += cscope.out
 CLEAN_DIRS += autom4te.cache
 
-check check_system check_cluster check_local check_lvmetad check_lvmpolld check_lvmlockd_test check_lvmlockd_dlm check_lvmlockd_sanlock: all
+check check_system check_cluster check_local check_lvmetad check_lvmpolld check_lvmlockd_test check_lvmlockd_dlm check_lvmlockd_sanlock unit-test run-unit-test: all
 	$(MAKE) -C test $(@)
 
 conf.generate man.generate: tools
@@ -145,7 +148,7 @@ install_system_dirs:
 	$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_RUN_DIR)
 	$(INSTALL_ROOT_DATA) /dev/null $(DESTDIR)$(DEFAULT_CACHE_DIR)/.cache
 
-install_initscripts: 
+install_initscripts:
 	$(MAKE) -C scripts install_initscripts
 
 install_systemd_generators:
@@ -210,10 +213,6 @@ endif
 
 endif
 
-include test/unit/Makefile
-
-include device-mapper/Makefile
-
 ifneq ($(shell which ctags),)
 .PHONY: tags
 tags:
test/Makefile.in +7 -3
index de8e3a1..67f2753 100644
@@ -27,7 +27,7 @@ datarootdir = @datarootdir@
 
 LVM_TEST_RESULTS ?= results
 
-SUBDIRS = api
+SUBDIRS = api unit
 SOURCES = lib/not.c lib/harness.c
 CXXSOURCES = lib/runner.cpp
 CXXFLAGS += $(EXTRA_EXEC_CFLAGS)
@@ -37,9 +37,9 @@ include $(top_builddir)/make.tmpl
 T ?= .
 S ?= @ # never match anything by default
 VERBOSE ?= 0
-ALL := $(shell find -L $(srcdir) \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) | $(SORT))
+ALL := $(shell find -L $(srcdir) \( -path \*/shell/\*.sh -or -path \*/api/\*.sh -or -path \*/unit/\*.sh \) | $(SORT))
 comma = ,
-RUN := $(shell find -L $(srcdir) -regextype posix-egrep \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) -and -regex "$(srcdir)/.*($(subst $(comma),|,$(T))).*" -and -not -regex "$(srcdir)/.*($(subst $(comma),|,$(S))).*" | $(SORT))
+RUN := $(shell find -L $(srcdir) -regextype posix-egrep \( -path \*/shell/\*.sh -or -path \*/api/\*.sh -or -path \*/unit/\*.sh \) -and -regex "$(srcdir)/.*($(subst $(comma),|,$(T))).*" -and -not -regex "$(srcdir)/.*($(subst $(comma),|,$(S))).*" | $(SORT))
 RUN_BASE = $(subst $(srcdir)/,,$(RUN))
 
 ifeq ("@BUILD_LVMETAD@", "yes")
@@ -83,6 +83,7 @@ help:
 	@echo "  check_lvmlockd_sanlock Run tests with lvmlockd and sanlock."
 	@echo "  check_lvmlockd_dlm     Run tests with lvmlockd and dlm."
 	@echo "  check_lvmlockd_test    Run tests with lvmlockd --test."
+	@echo "  run-unit-test          Run only unit tests (root not needed)."
 	@echo "  clean			Clean dir."
 	@echo "  help			Display callable targets."
 	@echo -e "\nSupported variables:"
@@ -190,6 +191,9 @@ check_lvmlockd_test: .tests-stamp
 		--flavours udev-lvmlockd-test --only $(T) --skip $(S)
 endif
 
+run-unit-test unit-test:
+	$(MAKE) -C unit $(@)
+
 DATADIR = $(datadir)/lvm2-testsuite
 EXECDIR = $(libexecdir)/lvm2-testsuite
 
test/unit/Makefile.in +39 -28

77 lines not on this page · raw message