diff --git a/Makefile.am b/Makefile.am index ca2093781..e1d311c13 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,9 +4,9 @@ INSTALL_DATA_HOOKS = ALL_LOCAL = CHECKS = shellcheck checkbashisms -include $(top_srcdir)/config/Shellcheck.am include $(top_srcdir)/config/Rules.am include $(top_srcdir)/config/CppCheck.am +include $(top_srcdir)/config/Shellcheck.am include $(top_srcdir)/config/Substfiles.am ACLOCAL_AMFLAGS = -I config @@ -16,11 +16,11 @@ if BUILD_LINUX include $(srcdir)/%D%/rpm/Makefile.am endif -CPPCHECKDIRS += etc/systemd/system-generators if CONFIG_USER -SUBDIRS += . tests etc +SUBDIRS += . tests include $(srcdir)/%D%/cmd/Makefile.am include $(srcdir)/%D%/contrib/Makefile.am +include $(srcdir)/%D%/etc/Makefile.am include $(srcdir)/%D%/lib/Makefile.am include $(srcdir)/%D%/man/Makefile.am include $(srcdir)/%D%/scripts/Makefile.am @@ -98,7 +98,7 @@ dist-hook: PHONY += codecheck $(CHECKS) codecheck: $(CHECKS) -SHELLCHECKDIRS = etc tests +SHELLCHECKDIRS = tests SHELLCHECKSCRIPTS += autogen.sh PHONY += checkstyle diff --git a/config/CppCheck.am b/config/CppCheck.am index 3fa6bddda..d0f1d6f19 100644 --- a/config/CppCheck.am +++ b/config/CppCheck.am @@ -13,9 +13,9 @@ CPPCHECKTARGETS = cppcheck-recursive-%: $(MAKE) -C $(subst ^,/,$(subst cppcheck-recursive-,,$@)) cppcheck -_CTGT = $(subst -,_,$(subst .,_,$(subst cppcheck-for-,,$@))) +_CTGT = $(subst cppcheck-for-,,$@) cppcheck-for-%: @[ -n "$($(_CTGT)_SOURCES)$(dist_$(_CTGT)_SOURCES)$(nodist_$(_CTGT)_SOURCES)" ] $(CPPCHECK) -j$(CPU_COUNT) $(CPPCHECKFLAGS) $(patsubst -U%,,$(patsubst -D%,,$(filter-out $(AM_CPPFLAGS_NOCHECK),$(or $($(_CTGT)_CPPFLAGS),$(AM_CPPFLAGS))))) $($(_CTGT)_SOURCES) $(dist_$(_CTGT)_SOURCES) $(nodist_$(_CTGT)_SOURCES) -cppcheck: $(addprefix cppcheck-for-,$(CPPCHECKTARGETS)) $(addprefix cppcheck-recursive-,$(subst /,^,$(CPPCHECKDIRS))) +cppcheck: $(addprefix cppcheck-for-,$(subst -,_,$(subst .,_,$(subst /,_,$(CPPCHECKTARGETS))))) $(addprefix cppcheck-recursive-,$(CPPCHECKDIRS)) diff --git a/config/Shellcheck.am b/config/Shellcheck.am index 873fb8eae..9002b76de 100644 --- a/config/Shellcheck.am +++ b/config/Shellcheck.am @@ -12,7 +12,7 @@ JUST_SHELLCHECK_OPTS = $(addprefix shellcheck-here-,$(subst /,^,$(1))) JUST_CHECKBASHISMS_OPTS = $(addprefix checkbashisms-here-,$(subst /,^,$(1))) SHELLCHECK_OPTS = $(call JUST_SHELLCHECK_OPTS,$(1)) $(call JUST_CHECKBASHISMS_OPTS,$(1)) -.PHONY: shellcheck shellcheck-recursive +PHONY += shellcheck shellcheck-recursive shellcheck-recursive: @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir shellcheck; done @@ -28,7 +28,7 @@ endif shellcheck: $(SHELLCHECKSCRIPTS) $(call JUST_SHELLCHECK_OPTS,$(SHELLCHECKSCRIPTS)) shellcheck-recursive -.PHONY: checkbashisms checkbashisms-recursive +PHONY += checkbashisms checkbashisms-recursive checkbashisms-recursive: @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir checkbashisms; done diff --git a/config/user-systemd.m4 b/config/user-systemd.m4 index 63f02ad2a..e4fd0b57c 100644 --- a/config/user-systemd.m4 +++ b/config/user-systemd.m4 @@ -35,16 +35,15 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_SYSTEMD], [ AC_MSG_RESULT([$enable_systemd]) AS_IF([test "x$enable_systemd" = xyes], [ - ZFS_INIT_SYSTEMD=systemd - ZFS_MODULE_LOAD=modules-load.d DEFINE_SYSTEMD='--with systemd --define "_unitdir $(systemdunitdir)" --define "_presetdir $(systemdpresetdir)" --define "_generatordir $(systemdgeneratordir)"' modulesloaddir=$systemdmodulesloaddir ],[ DEFINE_SYSTEMD='--without systemd' ]) - AC_SUBST(ZFS_INIT_SYSTEMD) - AC_SUBST(ZFS_MODULE_LOAD) + ZFS_INIT_SYSTEMD=$enable_systemd + ZFS_WANT_MODULES_LOAD_D=$enable_systemd + AC_SUBST(DEFINE_SYSTEMD) AC_SUBST(systemdunitdir) AC_SUBST(systemdpresetdir) diff --git a/config/user-sysvinit.m4 b/config/user-sysvinit.m4 index b6b63f1cf..cf3c8129f 100644 --- a/config/user-sysvinit.m4 +++ b/config/user-sysvinit.m4 @@ -2,10 +2,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_SYSVINIT], [ AC_ARG_ENABLE(sysvinit, AS_HELP_STRING([--enable-sysvinit], [install SysV init scripts [default: yes]]), - [],enable_sysvinit=yes) + [], enable_sysvinit=yes) - AS_IF([test "x$enable_sysvinit" = xyes], - [ZFS_INIT_SYSV=init.d]) - - AC_SUBST(ZFS_INIT_SYSV) + ZFS_INIT_SYSV=$enable_sysvinit ]) diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index 726b4b420..59bca5579 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -259,6 +259,10 @@ AC_DEFUN([ZFS_AC_CONFIG], [ AC_SUBST(TEST_JOBS) ]) + ZFS_INIT_SYSV= + ZFS_INIT_SYSTEMD= + ZFS_WANT_MODULES_LOAD_D= + case "$ZFS_CONFIG" in kernel) ZFS_AC_CONFIG_KERNEL ;; user) ZFS_AC_CONFIG_USER ;; @@ -271,6 +275,10 @@ AC_DEFUN([ZFS_AC_CONFIG], [ user kernel|user|all|srpm]) ;; esac + AM_CONDITIONAL([INIT_SYSV], [test "x$ZFS_INIT_SYSV" = "xyes"]) + AM_CONDITIONAL([INIT_SYSTEMD], [test "x$ZFS_INIT_SYSTEMD" = "xyes"]) + AM_CONDITIONAL([WANT_MODULES_LOAD_D], [test "x$ZFS_WANT_MODULES_LOAD_D" = "xyes"]) + AM_CONDITIONAL([CONFIG_USER], [test "$ZFS_CONFIG" = user -o "$ZFS_CONFIG" = all]) AM_CONDITIONAL([CONFIG_KERNEL], diff --git a/configure.ac b/configure.ac index f536ff2fc..c5af86c60 100644 --- a/configure.ac +++ b/configure.ac @@ -66,15 +66,6 @@ ZFS_AC_DEBUG_INVARIANTS AC_CONFIG_FILES([ Makefile - etc/Makefile - etc/default/Makefile - etc/init.d/Makefile - etc/modules-load.d/Makefile - etc/sudoers.d/Makefile - etc/systemd/Makefile - etc/systemd/system-generators/Makefile - etc/systemd/system/Makefile - etc/zfs/Makefile include/Makefile lib/libzfs/libzfs.pc lib/libzfsbootenv/libzfsbootenv.pc diff --git a/etc/Makefile.am b/etc/Makefile.am index 179c24009..ffe5fad2b 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -1,9 +1,95 @@ -include $(top_srcdir)/config/Shellcheck.am +sudoersddir = $(sysconfdir)/sudoers.d +sudoersd_DATA = \ + %D%/sudoers.d/zfs + +EXTRA_DIST += $(sudoersd_DATA) + + +sysconf_zfsdir = $(sysconfdir)/zfs + +dist_sysconf_zfs_DATA = \ + %D%/zfs/vdev_id.conf.alias.example \ + %D%/zfs/vdev_id.conf.multipath.example \ + %D%/zfs/vdev_id.conf.sas_direct.example \ + %D%/zfs/vdev_id.conf.sas_switch.example \ + %D%/zfs/vdev_id.conf.scsi.example + +sysconf_zfs_SCRIPTS = \ + %D%/zfs/zfs-functions + +SUBSTFILES += $(sysconf_zfs_SCRIPTS) +SHELLCHECKSCRIPTS += $(sysconf_zfs_SCRIPTS) +$(call SHELLCHECK_OPTS,$(sysconf_zfs_SCRIPTS)): SHELLCHECK_SHELL = sh -SUBDIRS = zfs sudoers.d -SHELLCHECKDIRS = default $(ZFS_INIT_SYSV) zfs if BUILD_LINUX -SUBDIRS += default $(ZFS_INIT_SYSTEMD) $(ZFS_INIT_SYSV) $(ZFS_MODULE_LOAD) +initconf_SCRIPTS = \ + %D%/default/zfs + +SUBSTFILES += $(initconf_SCRIPTS) +SHELLCHECKSCRIPTS += $(initconf_SCRIPTS) +$(call SHELLCHECK_OPTS,$(initconf_SCRIPTS)): SHELLCHECK_SHELL = sh + + +if INIT_SYSV +EXTRA_DIST += $(addprefix %D%/,init.d/README.md) + +init_SCRIPTS = \ + %D%/init.d/zfs-import \ + %D%/init.d/zfs-load-key \ + %D%/init.d/zfs-mount \ + %D%/init.d/zfs-share \ + %D%/init.d/zfs-zed + +SUBSTFILES += $(init_SCRIPTS) +SHELLCHECKSCRIPTS += $(init_SCRIPTS) +$(call SHELLCHECK_OPTS,$(init_SCRIPTS)): SHELLCHECK_SHELL = sh +endif + + +if INIT_SYSTEMD +dist_systemdpreset_DATA = \ + %D%/systemd/system/50-zfs.preset + +systemdunit_DATA = \ + %D%/systemd/system/zfs-import-cache.service \ + %D%/systemd/system/zfs-import-scan.service \ + %D%/systemd/system/zfs-import.target \ + %D%/systemd/system/zfs-mount.service \ + %D%/systemd/system/zfs-scrub-monthly@.timer \ + %D%/systemd/system/zfs-scrub-weekly@.timer \ + %D%/systemd/system/zfs-scrub@.service \ + %D%/systemd/system/zfs-share.service \ + %D%/systemd/system/zfs-volume-wait.service \ + %D%/systemd/system/zfs-volumes.target \ + %D%/systemd/system/zfs-zed.service \ + %D%/systemd/system/zfs.target + +SUBSTFILES += $(systemdunit_DATA) + +INSTALL_DATA_HOOKS += systemd-install-data-hook +systemd-install-data-hook: + $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)" + ln -sf /dev/null "$(DESTDIR)$(systemdunitdir)/zfs-import.service" + + +systemdgenerator_PROGRAMS = \ + %D%/systemd/system-generators/zfs-mount-generator + +%C%_systemd_system_generators_zfs_mount_generator_SOURCES = \ + %D%/systemd/system-generators/zfs-mount-generator.c + +%C%_systemd_system_generators_zfs_mount_generator_LDADD = \ + libzfs.la + +%C%_systemd_system_generators_zfs_mount_generator_LDFLAGS = -pthread + +CPPCHECKTARGETS += $(systemdgenerator_PROGRAMS) +endif + + +if WANT_MODULES_LOAD_D +dist_modulesload_DATA = \ + %D%/modules-load.d/zfs.conf +endif endif -DIST_SUBDIRS = default init.d zfs systemd modules-load.d sudoers.d diff --git a/etc/default/Makefile.am b/etc/default/Makefile.am deleted file mode 100644 index 98f22b8da..000000000 --- a/etc/default/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -CLEANFILES = -EXTRA_DIST = -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -initconf_SCRIPTS = zfs - -SUBSTFILES += $(initconf_SCRIPTS) - -SHELLCHECK_SHELL = sh -SHELLCHECKSCRIPTS += $(initconf_SCRIPTS) diff --git a/etc/init.d/Makefile.am b/etc/init.d/Makefile.am deleted file mode 100644 index 0a997f445..000000000 --- a/etc/init.d/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -CLEANFILES = -EXTRA_DIST = -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -EXTRA_DIST += README.md - -init_SCRIPTS = zfs-import zfs-load-key zfs-mount zfs-share zfs-zed - -SUBSTFILES += $(init_SCRIPTS) - -SHELLCHECK_SHELL = sh -SHELLCHECKSCRIPTS += $(init_SCRIPTS) diff --git a/etc/modules-load.d/.gitignore b/etc/modules-load.d/.gitignore deleted file mode 100644 index fee921708..000000000 --- a/etc/modules-load.d/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.conf diff --git a/etc/modules-load.d/Makefile.am b/etc/modules-load.d/Makefile.am deleted file mode 100644 index 8a2955767..000000000 --- a/etc/modules-load.d/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -dist_modulesload_DATA = \ - zfs.conf diff --git a/etc/sudoers.d/Makefile.am b/etc/sudoers.d/Makefile.am deleted file mode 100644 index 6f7ac8dbf..000000000 --- a/etc/sudoers.d/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -sudoersddir = $(sysconfdir)/sudoers.d -sudoersd_DATA = zfs - -EXTRA_DIST = \ - zfs diff --git a/etc/systemd/Makefile.am b/etc/systemd/Makefile.am deleted file mode 100644 index 7b47b93fc..000000000 --- a/etc/systemd/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = system system-generators diff --git a/etc/systemd/system-generators/Makefile.am b/etc/systemd/system-generators/Makefile.am deleted file mode 100644 index ee51d1c75..000000000 --- a/etc/systemd/system-generators/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -systemdgenerator_PROGRAMS = \ - zfs-mount-generator - -zfs_mount_generator_SOURCES = \ - zfs-mount-generator.c - -zfs_mount_generator_LDADD = \ - $(abs_top_builddir)/libzfs.la - -zfs_mount_generator_LDFLAGS = -pthread - -include $(top_srcdir)/config/CppCheck.am -CPPCHECKTARGETS += zfs-mount-generator diff --git a/etc/systemd/system/.gitignore b/etc/systemd/system/.gitignore index 4813c65a2..95d33fdd4 100644 --- a/etc/systemd/system/.gitignore +++ b/etc/systemd/system/.gitignore @@ -1,4 +1,3 @@ *.service *.target -*.preset *.timer diff --git a/etc/systemd/system/50-zfs.preset.in b/etc/systemd/system/50-zfs.preset similarity index 100% rename from etc/systemd/system/50-zfs.preset.in rename to etc/systemd/system/50-zfs.preset diff --git a/etc/systemd/system/Makefile.am b/etc/systemd/system/Makefile.am deleted file mode 100644 index b5fcddbf5..000000000 --- a/etc/systemd/system/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -CLEANFILES = -EXTRA_DIST = -include $(top_srcdir)/config/Substfiles.am - -systemdpreset_DATA = \ - 50-zfs.preset - -systemdunit_DATA = \ - zfs-zed.service \ - zfs-import-cache.service \ - zfs-import-scan.service \ - zfs-mount.service \ - zfs-share.service \ - zfs-volume-wait.service \ - zfs-import.target \ - zfs-volumes.target \ - zfs.target \ - zfs-scrub-monthly@.timer \ - zfs-scrub-weekly@.timer \ - zfs-scrub@.service - -SUBSTFILES += $(systemdpreset_DATA) $(systemdunit_DATA) - -install-data-hook: - $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)" - ln -sf /dev/null "$(DESTDIR)$(systemdunitdir)/zfs-import.service" diff --git a/etc/zfs/Makefile.am b/etc/zfs/Makefile.am deleted file mode 100644 index f62c687c6..000000000 --- a/etc/zfs/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -CLEANFILES = -EXTRA_DIST = -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -pkgsysconfdir = $(sysconfdir)/zfs - -dist_pkgsysconf_DATA = \ - vdev_id.conf.alias.example \ - vdev_id.conf.sas_direct.example \ - vdev_id.conf.sas_switch.example \ - vdev_id.conf.multipath.example \ - vdev_id.conf.scsi.example - -pkgsysconf_SCRIPTS = \ - zfs-functions - -SUBSTFILES += $(pkgsysconf_SCRIPTS) - -SHELLCHECK_SHELL = sh -SHELLCHECKSCRIPTS += $(pkgsysconf_SCRIPTS) diff --git a/tests/Makefile.am b/tests/Makefile.am index 731915498..e839957d4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,3 +1,4 @@ +PHONY = include $(top_srcdir)/config/Shellcheck.am SUBDIRS = runfiles test-runner zfs-tests