]> git.proxmox.com Git - mirror_zfs.git/blame - module/Makefile.in
libzfs: pool: fix false-positives -Wmaybe-uninitialised
[mirror_zfs.git] / module / Makefile.in
CommitLineData
71504277 1include Kbuild
c9c0d073 2
d09f98a9 3INSTALL_MOD_DIR ?= extra
ed3a3bdb 4INSTALL_MOD_PATH ?= $(DESTDIR)
d09f98a9 5
bced7e3a
MM
6all: modules
7distclean maintainer-clean: clean
8install: modules_install
9uninstall: modules_uninstall
10check:
11
0b032548
AS
12.PHONY: all distclean maintainer-clean install uninstall check distdir \
13 modules modules-Linux modules-FreeBSD modules-unknown \
14 clean clean-Linux clean-FreeBSD \
15 modules_install modules_install-Linux modules_install-FreeBSD \
0e6c493f
BB
16 modules_uninstall modules_uninstall-Linux modules_uninstall-FreeBSD \
17 cppcheck cppcheck-Linux cppcheck-FreeBSD
0b032548 18
ba74de88
RM
19# For FreeBSD, use debug options from ./configure if not overridden.
20export WITH_DEBUG ?= @WITH_DEBUG@
21export WITH_INVARIANTS ?= @WITH_INVARIANTS@
22
33982eb2
AS
23# Filter out options that FreeBSD make doesn't understand
24getflags = ( \
25set -- \
26 $(filter-out --%,$(firstword $(MFLAGS))) \
27 $(filter -I%,$(MFLAGS)) \
28 $(filter -j%,$(MFLAGS)); \
29fmakeflags=""; \
30while getopts :deiI:j:knqrstw flag; do \
31 case $$flag in \
32 \?) :;; \
33 :) if [ $$OPTARG = "j" ]; then \
34 ncpus=$$(sysctl -n kern.smp.cpus 2>/dev/null || :); \
35 if [ -n "$$ncpus" ]; then fmakeflags="$$fmakeflags -j$$ncpus"; fi; \
36 fi;; \
37 d) fmakeflags="$$fmakeflags -dA";; \
38 *) fmakeflags="$$fmakeflags -$$flag$$OPTARG";; \
39 esac; \
40done; \
41echo $$fmakeflags \
42)
43FMAKEFLAGS = -C @abs_srcdir@ -f Makefile.bsd $(shell $(getflags))
44
45ifneq (@abs_srcdir@,@abs_builddir@)
46FMAKEFLAGS += MAKEOBJDIR=@abs_builddir@
47endif
ba74de88 48
33982eb2
AS
49FMAKE = env -u MAKEFLAGS make $(FMAKEFLAGS)
50
bced7e3a 51modules-Linux:
ad9e7676
AZ
52 mkdir -p $(sort $(dir $(spl-objs) $(spl-)))
53 mkdir -p $(sort $(dir $(zfs-objs) $(zfs-)))
b66140c6
PL
54 $(MAKE) -C @LINUX_OBJ@ $(if @KERNEL_CC@,CC=@KERNEL_CC@) \
55 $(if @KERNEL_LD@,LD=@KERNEL_LD@) $(if @KERNEL_LLVM@,LLVM=@KERNEL_LLVM@) \
56 M="$$PWD" @KERNEL_MAKE@ CONFIG_ZFS=m modules
bced7e3a 57
9f0a21e6 58modules-FreeBSD:
33982eb2 59 +$(FMAKE)
9f0a21e6 60
bced7e3a
MM
61modules-unknown:
62 @true
63
64modules: modules-@ac_system@
c9c0d073 65
bced7e3a 66clean-Linux:
d433c206
BB
67 @# Only cleanup the kernel build directories when CONFIG_KERNEL
68 @# is defined. This indicates that kernel modules should be built.
ccc421ec 69@CONFIG_KERNEL_TRUE@ $(MAKE) -C @LINUX_OBJ@ M="$$PWD" @KERNEL_MAKE@ clean
d433c206 70
c5d8cd63
AZ
71 $(RM) @LINUX_SYMBOLS@ Module.markers
72 find . -name '*.ur-safe' -type f -delete
b669ab83 73
9f0a21e6 74clean-FreeBSD:
33982eb2 75 +$(FMAKE) clean
9f0a21e6 76
bced7e3a
MM
77clean: clean-@ac_system@
78
9b80d9e6
AZ
79.PHONY: modules_uninstall-Linux-legacy
80modules_uninstall-Linux-legacy:
81 $(RM) -r $(addprefix $(KMODDIR)/$(INSTALL_MOD_DIR)/,spl/ avl/ icp/ lua/ nvpair/ unicode/ zcommon/ zfs/ zstd/)
82
ad9e7676 83KMODDIR := $(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@
9b80d9e6 84modules_install-Linux: modules_uninstall-Linux-legacy
6283f55e 85 @# Install the kernel modules
ccc421ec 86 $(MAKE) -C @LINUX_OBJ@ M="$$PWD" modules_install \
ed3a3bdb 87 INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \
bb9d808c
AP
88 INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
89 KERNELRELEASE=@LINUX_VERSION@
fe0ed8f9 90 @# Remove extraneous build products when packaging
b0fe1ade 91 if [ -n "$(DESTDIR)" ]; then \
ad9e7676 92 find $(KMODDIR) -name 'modules.*' -delete; \
fe0ed8f9 93 fi
f68b9c81
RE
94 @# Debian ships tiny fake System.map files that are
95 @# syntactically valid but just say
96 @# "if you want system.map go install this package"
97 @# Naturally, depmod is less than amused by this.
98 @# So if we find it missing or with one of these present,
99 @# we check for the alternate path for the System.map
ed3a3bdb 100 sysmap=$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
f68b9c81
RE
101 { [ -f "$$sysmap" ] && [ $$(wc -l < "$$sysmap") -ge 100 ]; } || \
102 sysmap=$(INSTALL_MOD_PATH)/usr/lib/debug/boot/System.map-@LINUX_VERSION@; \
c9c0d073
BB
103 if [ -f $$sysmap ]; then \
104 depmod -ae -F $$sysmap @LINUX_VERSION@; \
105 fi
c9c0d073 106
9f0a21e6
MM
107modules_install-FreeBSD:
108 @# Install the kernel modules
33982eb2 109 +$(FMAKE) install
9f0a21e6 110
bced7e3a
MM
111modules_install: modules_install-@ac_system@
112
9b80d9e6 113modules_uninstall-Linux: modules_uninstall-Linux-legacy
6283f55e 114 @# Uninstall the kernel modules
ad9e7676 115 $(RM) $(addprefix $(KMODDIR)/$(INSTALL_MOD_DIR)/,zfs.ko spl.ko)
c9c0d073 116
9f0a21e6
MM
117modules_uninstall-FreeBSD:
118 @false
119
bced7e3a
MM
120modules_uninstall: modules_uninstall-@ac_system@
121
0e6c493f
BB
122cppcheck-Linux:
123 @CPPCHECK@ -j@CPU_COUNT@ --std=c99 --quiet --force --error-exitcode=2 \
6d680e61
DS
124 --inline-suppr \
125 --suppress=unmatchedSuppression \
126 --suppress=noValidConfiguration \
0e6c493f
BB
127 --enable=warning,information -D_KERNEL \
128 --include=@LINUX_OBJ@/include/generated/autoconf.h \
be91239e 129 --include=@top_builddir@/zfs_config.h \
0e6c493f 130 --config-exclude=@LINUX_OBJ@/include \
fe2ea67d 131 -i zstd/lib \
0e6c493f
BB
132 -I @LINUX_OBJ@/include \
133 -I @top_srcdir@/include/os/linux/kernel \
134 -I @top_srcdir@/include/os/linux/spl \
135 -I @top_srcdir@/include/os/linux/zfs \
136 -I @top_srcdir@/include \
ad9e7676 137 avl icp lua nvpair unicode zcommon zfs zstd os/linux
0e6c493f
BB
138
139cppcheck-FreeBSD:
140 @true
141
142cppcheck: cppcheck-@ac_system@
143
c9c0d073 144distdir:
ad9e7676 145 cd @srcdir@ && find . -name '*.[chS]' -exec sh -c 'for f; do mkdir -p $$distdir/$${f%/*}; cp @srcdir@/$$f $$distdir/$$f; done' _ {} +
7c902a51 146 cp @srcdir@/Makefile.bsd $$distdir/Makefile.bsd
ad9e7676
AZ
147
148gen-zstd-symbols:
149 for obj in $(addprefix zstd/,$(ZSTD_UPSTREAM_OBJS)); do echo; echo "/* $${obj#zstd/}: */"; @OBJDUMP@ -t $$obj | awk '$$2 == "g" && !/ zfs_/ {print "#define\t" $$6 " zfs_" $$6}' | sort; done >> zstd/include/zstd_compat_wrapper.h
150
151check-zstd-symbols:
152 @OBJDUMP@ -t $(addprefix zstd/,$(ZSTD_UPSTREAM_OBJS)) | awk '/file format/ {print} $$2 == "g" && !/ zfs_/ {++ret; print} END {exit ret}'