]> git.ipfire.org Git - thirdparty/kmod.git/blobdiff - Makefile.am
depmod: prevent module dependency files missing during depmod invocation
[thirdparty/kmod.git] / Makefile.am
index 87702ee21c60d5738c911ff521713f16f30b3998..1ab1db58531623c8b5b2e414750ab5605d366e35 100644 (file)
@@ -7,20 +7,22 @@ endif
 DISTCLEAN_LOCAL_HOOKS =
 EXTRA_DIST =
 CLEANFILES = $(BUILT_FILES)
+DISTCLEANFILES =
 BUILT_FILES =
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 AM_MAKEFLAGS = --no-print-directory
 
+GCC_COLORS ?= 'yes'
+export GCC_COLORS
+
 AM_CPPFLAGS = \
        -include $(top_builddir)/config.h \
-       -I$(top_srcdir)/libkmod \
        -I$(top_srcdir) \
        -DSYSCONFDIR=\""$(sysconfdir)"\" \
-       -DLIBEXECDIR=\""$(libexecdir)"\" \
        ${zlib_CFLAGS}
 
-AM_CFLAGS = $(WARNINGFLAGS)
-AM_LDFLAGS = $(GCLDFLAGS)
+AM_CFLAGS = $(OUR_CFLAGS)
+AM_LDFLAGS = $(OUR_LDFLAGS)
 
 SED_PROCESS = \
        $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
@@ -38,29 +40,29 @@ SED_PROCESS = \
 %.pc: %.pc.in Makefile
        $(SED_PROCESS)
 
-LIBKMOD_CURRENT=4
-LIBKMOD_REVISION=8
-LIBKMOD_AGE=2
+LIBKMOD_CURRENT=5
+LIBKMOD_REVISION=3
+LIBKMOD_AGE=3
 
-noinst_LTLIBRARIES = libkmod/libkmod-util.la
-libkmod_libkmod_util_la_SOURCES = \
+noinst_LTLIBRARIES = shared/libshared.la
+shared_libshared_la_SOURCES = \
        shared/macro.h \
        shared/missing.h \
        shared/array.c \
        shared/array.h \
        shared/hash.c \
        shared/hash.h \
+       shared/scratchbuf.c \
+       shared/scratchbuf.h \
+       shared/strbuf.c \
+       shared/strbuf.h \
        shared/util.c \
-       shared/util.h \
-       libkmod/libkmod-util.c \
-       libkmod/libkmod-util.h
+       shared/util.h
 
 include_HEADERS = libkmod/libkmod.h
 lib_LTLIBRARIES = libkmod/libkmod.la
 
 libkmod_libkmod_la_SOURCES = \
-       shared/macro.h \
-       shared/missing.h \
        libkmod/libkmod.h \
        libkmod/libkmod-internal.h \
        libkmod/libkmod.c \
@@ -81,10 +83,10 @@ libkmod_libkmod_la_LDFLAGS = $(AM_LDFLAGS) \
        -version-info $(LIBKMOD_CURRENT):$(LIBKMOD_REVISION):$(LIBKMOD_AGE) \
        -Wl,--version-script=$(top_srcdir)/libkmod/libkmod.sym
 libkmod_libkmod_la_DEPENDENCIES = \
-       libkmod/libkmod-util.la \
+       shared/libshared.la \
        ${top_srcdir}/libkmod/libkmod.sym
 libkmod_libkmod_la_LIBADD = \
-       libkmod/libkmod-util.la \
+       shared/libshared.la \
        ${liblzma_LIBS} ${zlib_LIBS}
 
 noinst_LTLIBRARIES += libkmod/libkmod-internal.la
@@ -128,8 +130,15 @@ tools_kmod_SOURCES = \
        tools/modinfo.c tools/modprobe.c \
        tools/depmod.c tools/log.h tools/log.c \
        tools/static-nodes.c
+
+if BUILD_EXPERIMENTAL
+tools_kmod_SOURCES += \
+       tools/insert.c \
+       tools/remove.c
+endif
+
 tools_kmod_LDADD = \
-       libkmod/libkmod-util.la \
+       shared/libshared.la \
        libkmod/libkmod-internal.la
 
 ${noinst_SCRIPTS}: tools/kmod
@@ -209,16 +218,36 @@ endif
 # TESTSUITE
 # ------------------------------------------------------------------------------
 
+EXTRA_DIST += testsuite/populate-modules.sh
+
+MODULE_PLAYGROUND = testsuite/module-playground
 ROOTFS = testsuite/rootfs
 ROOTFS_PRISTINE = $(top_srcdir)/testsuite/rootfs-pristine
 CREATE_ROOTFS = $(AM_V_GEN) ( $(RM) -rf $(ROOTFS) && mkdir -p $(dir $(ROOTFS)) && \
                                cp -r $(ROOTFS_PRISTINE) $(ROOTFS) && \
-                               touch testsuite/stamp-rootfs && \
-                               find $(ROOTFS) -type d -exec chmod +w {} \; )
+                               find $(ROOTFS) -type d -exec chmod +w {} \; && \
+                               find $(ROOTFS) -type f -name .gitignore -exec rm -f {} \; && \
+                               $(top_srcdir)/testsuite/populate-modules.sh \
+                                       $(MODULE_PLAYGROUND) $(ROOTFS) ) && \
+                               touch testsuite/stamp-rootfs
+
+build-module-playground:
+       $(AM_V_GEN)if test "$(top_srcdir)" != "$(top_builddir)"; then \
+               $(RM) -rf testsuite/module-playground && \
+               cp -r $(top_srcdir)/$(MODULE_PLAYGROUND) $(top_builddir)/$(MODULE_PLAYGROUND) && \
+               find $(top_builddir)/$(MODULE_PLAYGROUND) -type d -exec chmod +w {} \; ; \
+               fi
+if BUILD_MODULES
+       $(MAKE) -C $(MODULE_PLAYGROUND)
+else
+       $(MAKE) -C $(MODULE_PLAYGROUND) FAKE_BUILD=1
+endif
+
 
-rootfs:
+rootfs: build-module-playground
        $(CREATE_ROOTFS)
-.PHONY: rootfs
+
+.PHONY: rootfs build-playground
 
 $(ROOTFS): $(ROOTFS_PRISTINE)
        $(CREATE_ROOTFS)
@@ -239,9 +268,42 @@ check-sysconfdir:
 check-am: rootfs check-sysconfdir
 
 
+EXTRA_DIST += \
+       testsuite/module-playground/cache \
+       testsuite/module-playground/dummy.sha1 \
+       testsuite/module-playground/dummy.sha256 \
+       testsuite/module-playground/Makefile \
+       testsuite/module-playground/Makefile.arch \
+       testsuite/module-playground/mod-fake-cciss.c \
+       testsuite/module-playground/mod-fake-hpsa.c \
+       testsuite/module-playground/mod-fake-scsi-mod.c \
+       testsuite/module-playground/mod-foo-a.c \
+       testsuite/module-playground/mod-foo-b.c \
+       testsuite/module-playground/mod-foo.c \
+       testsuite/module-playground/mod-foo-c.c \
+       testsuite/module-playground/mod-loop-a.c \
+       testsuite/module-playground/mod-loop-b.c \
+       testsuite/module-playground/mod-loop-c.c \
+       testsuite/module-playground/mod-loop-d.c \
+       testsuite/module-playground/mod-loop-e.c \
+       testsuite/module-playground/mod-loop-f.c \
+       testsuite/module-playground/mod-loop-g.c \
+       testsuite/module-playground/mod-loop-h.c \
+       testsuite/module-playground/mod-loop-i.c \
+       testsuite/module-playground/mod-loop-j.c \
+       testsuite/module-playground/mod-loop-k.c \
+       testsuite/module-playground/mod-loop.h \
+       testsuite/module-playground/mod-simple.c \
+       testsuite/module-playground/mod-simple-i386.ko \
+       testsuite/module-playground/mod-simple-sparc64.ko \
+       testsuite/module-playground/mod-simple-x86_64.ko \
+       testsuite/module-playground/README
+
 check_LTLIBRARIES = $(TESTSUITE_OVERRIDE_LIBS)
 
 testsuite_uname_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
+testsuite_path_la_CPPFLAGS = $(AM_CPPFLAGS) \
+       -DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\"
 testsuite_path_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
 
 testsuite_delete_module_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
@@ -255,7 +317,7 @@ TESTSUITE_CPPFLAGS = $(AM_CPPFLAGS) \
        -DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\"
 TESTSUITE_LDADD = \
        testsuite/libtestsuite.la libkmod/libkmod-internal.la \
-       libkmod/libkmod-util.la
+       shared/libshared.la
 
 check_LTLIBRARIES += testsuite/libtestsuite.la
 testsuite_libtestsuite_la_SOURCES = \
@@ -268,16 +330,26 @@ testsuite_libtestsuite_la_LIBADD = -lrt
 TESTSUITE = \
        testsuite/test-hash \
        testsuite/test-array \
-       testsuite/test-init testsuite/test-testsuite testsuite/test-loaded \
+       testsuite/test-scratchbuf \
+       testsuite/test-strbuf \
+       testsuite/test-init \
+       testsuite/test-initstate \
+       testsuite/test-testsuite testsuite/test-loaded \
        testsuite/test-modinfo testsuite/test-util testsuite/test-new-module \
        testsuite/test-modprobe testsuite/test-blacklist \
-       testsuite/test-dependencies testsuite/test-depmod
+       testsuite/test-dependencies testsuite/test-depmod \
+       testsuite/test-list
+
+if BUILD_EXPERIMENTAL
+TESTSUITE += \
+       testsuite/test-tools
+endif
 
 check_PROGRAMS = $(TESTSUITE)
 TESTS = $(TESTSUITE)
 
 testsuite_test_testsuite_LDADD = \
-       testsuite/libtestsuite.la libkmod/libkmod-util.la
+       testsuite/libtestsuite.la shared/libshared.la
 testsuite_test_testsuite_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
 
 testsuite_test_hash_LDADD = $(TESTSUITE_LDADD)
@@ -286,8 +358,16 @@ testsuite_test_hash_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
 testsuite_test_array_LDADD = $(TESTSUITE_LDADD)
 testsuite_test_array_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
 
+testsuite_test_scratchbuf_LDADD = $(TESTSUITE_LDADD)
+testsuite_test_scratchbuf_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
+
+testsuite_test_strbuf_LDADD = $(TESTSUITE_LDADD)
+testsuite_test_strbuf_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
+
 testsuite_test_init_LDADD = $(TESTSUITE_LDADD)
 testsuite_test_init_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
+testsuite_test_initstate_LDADD = $(TESTSUITE_LDADD)
+testsuite_test_initstate_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
 testsuite_test_loaded_LDADD = $(TESTSUITE_LDADD)
 testsuite_test_loaded_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
 testsuite_test_modinfo_LDADD = $(TESTSUITE_LDADD)
@@ -304,10 +384,21 @@ testsuite_test_dependencies_LDADD = $(TESTSUITE_LDADD)
 testsuite_test_dependencies_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
 testsuite_test_depmod_LDADD = $(TESTSUITE_LDADD)
 testsuite_test_depmod_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
+testsuite_test_list_LDADD = $(TESTSUITE_LDADD)
+testsuite_test_list_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
+
+if BUILD_EXPERIMENTAL
+testsuite_test_tools_LDADD = $(TESTSUITE_LDADD)
+testsuite_test_tools_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
+endif
 
 testsuite-distclean:
        $(RM) -r $(ROOTFS)
        $(RM) testsuite/stamp-rootfs
+       $(MAKE) -C testsuite/module-playground/ clean
+       if test "$(top_srcdir)" != "$(top_builddir)"; then \
+               $(RM) -rf testsuite/module-playground; \
+       fi
 
 DISTCLEAN_LOCAL_HOOKS += testsuite-distclean
 EXTRA_DIST += testsuite/rootfs-pristine
@@ -321,6 +412,72 @@ distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
 buildtest-TESTS:
        $(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS)
 
+DISTCLEANFILES += $(DOLT_CLEANFILES)
+
+# ------------------------------------------------------------------------------
+# coverage
+# ------------------------------------------------------------------------------
+
+# .PHONY so it always rebuilds it
+.PHONY: coverage lcov-run lcov-report coverage-sync
+
+# run lcov from scratch, always
+coverage: all
+       $(MAKE) lcov-run
+       $(MAKE) lcov-report
+
+coverage_dir = coverage
+coverage_opts = --base-directory $(srcdir) --directory $(builddir) \
+               --rc 'geninfo_adjust_src_path=$(abspath $(srcdir))=>$(abspath $(builddir))'
+
+if ENABLE_COVERAGE
+# reset run coverage tests
+lcov-run:
+       @rm -rf $(coverage_dir)
+       lcov $(coverage_opts) --zerocounters
+       -$(MAKE) check
+
+# generate report based on current coverage data
+lcov-report:
+       $(MKDIR_P) $(coverage_dir)
+       lcov $(coverage_opts) --capture --no-external --ignore-errors graph \
+               | sed 's|$(abspath $(builddir))|$(abspath $(srcdir))|' > $(coverage_dir)/.lcov.info
+       lcov --remove $(coverage_dir)/.lcov.info --output-file $(coverage_dir)/.lcov-clean.info 'test-*'
+       genhtml -t "kmod test coverage" -o $(coverage_dir) $(coverage_dir)/.lcov-clean.info
+       @echo "Coverage report generated in $(abs_builddir)/$(coverage_dir)/index.html"
+
+else
+
+lcov-run lcov-report:
+       echo "Need to reconfigure with --enable-coverage"
+
+endif
+
+# ------------------------------------------------------------------------------
+# coverity
+# ------------------------------------------------------------------------------
+
+kmod-coverity-%.tar.xz:
+       rm -rf $< cov-int
+       ./autogen.sh c --disable-python --disable-manpages
+       make clean
+       cov-build --dir cov-int make -j 4
+       tar caf $@ cov-int
+
+coverity-tar: kmod-coverity-$(shell git describe  2>/dev/null).tar.xz
+
+coverity-sync: kmod-coverity-$(shell git describe 2>/dev/null).tar.xz
+       @echo "uploading coverity tarball"
+       @curl --form token=$(COVERITY_KMOD_TOKEN) \
+               --form email=lucas.de.marchi@gmail.com \
+               --form file=@$< \
+               --form version="$(shell git describe)" \
+               --form description="" \
+               https://scan.coverity.com/builds?project=kmod
+
+coverity-clean:
+       rm -rf kmod-coverity-*.tar.xz cov-int
+
 # ------------------------------------------------------------------------------
 # custom release helpers
 # ------------------------------------------------------------------------------
@@ -341,3 +498,13 @@ tar: kmod-$(VERSION).tar.xz kmod-$(VERSION).tar.sign
 
 tar-sync: kmod-$(VERSION).tar.xz kmod-$(VERSION).tar.sign
        kup put kmod-$(VERSION).tar.xz  kmod-$(VERSION).tar.sign /pub/linux/utils/kernel/kmod/
+
+# ------------------------------------------------------------------------------
+# mkosi
+# ------------------------------------------------------------------------------
+
+DISTRO ?= "arch"
+
+mkosi:
+       -$(MKDIR_P) $(top_srcdir)/testsuite/mkosi/mkosi.cache
+       $(MKOSI) -C $(top_srcdir)/testsuite/mkosi --build-sources ../../ --default mkosi.${DISTRO} -fi