]>
Commit | Line | Data |
---|---|---|
71504277 | 1 | include Kbuild |
c9c0d073 | 2 | |
d09f98a9 | 3 | INSTALL_MOD_DIR ?= extra |
ed3a3bdb | 4 | INSTALL_MOD_PATH ?= $(DESTDIR) |
d09f98a9 | 5 | |
10b3c7f5 | 6 | SUBDIR_TARGETS = icp lua zstd |
0b04990a | 7 | |
bced7e3a MM |
8 | all: modules |
9 | distclean maintainer-clean: clean | |
10 | install: modules_install | |
11 | uninstall: modules_uninstall | |
12 | check: | |
13 | ||
0b032548 AS |
14 | .PHONY: all distclean maintainer-clean install uninstall check distdir \ |
15 | modules modules-Linux modules-FreeBSD modules-unknown \ | |
16 | clean clean-Linux clean-FreeBSD \ | |
17 | modules_install modules_install-Linux modules_install-FreeBSD \ | |
0e6c493f BB |
18 | modules_uninstall modules_uninstall-Linux modules_uninstall-FreeBSD \ |
19 | cppcheck cppcheck-Linux cppcheck-FreeBSD | |
0b032548 | 20 | |
ba74de88 RM |
21 | # For FreeBSD, use debug options from ./configure if not overridden. |
22 | export WITH_DEBUG ?= @WITH_DEBUG@ | |
23 | export WITH_INVARIANTS ?= @WITH_INVARIANTS@ | |
24 | ||
33982eb2 AS |
25 | # Filter out options that FreeBSD make doesn't understand |
26 | getflags = ( \ | |
27 | set -- \ | |
28 | $(filter-out --%,$(firstword $(MFLAGS))) \ | |
29 | $(filter -I%,$(MFLAGS)) \ | |
30 | $(filter -j%,$(MFLAGS)); \ | |
31 | fmakeflags=""; \ | |
32 | while getopts :deiI:j:knqrstw flag; do \ | |
33 | case $$flag in \ | |
34 | \?) :;; \ | |
35 | :) if [ $$OPTARG = "j" ]; then \ | |
36 | ncpus=$$(sysctl -n kern.smp.cpus 2>/dev/null || :); \ | |
37 | if [ -n "$$ncpus" ]; then fmakeflags="$$fmakeflags -j$$ncpus"; fi; \ | |
38 | fi;; \ | |
39 | d) fmakeflags="$$fmakeflags -dA";; \ | |
40 | *) fmakeflags="$$fmakeflags -$$flag$$OPTARG";; \ | |
41 | esac; \ | |
42 | done; \ | |
43 | echo $$fmakeflags \ | |
44 | ) | |
45 | FMAKEFLAGS = -C @abs_srcdir@ -f Makefile.bsd $(shell $(getflags)) | |
46 | ||
47 | ifneq (@abs_srcdir@,@abs_builddir@) | |
48 | FMAKEFLAGS += MAKEOBJDIR=@abs_builddir@ | |
49 | endif | |
ba74de88 | 50 | |
33982eb2 AS |
51 | FMAKE = env -u MAKEFLAGS make $(FMAKEFLAGS) |
52 | ||
bced7e3a | 53 | modules-Linux: |
ccc421ec AZ |
54 | list='$(SUBDIR_TARGETS)'; for td in $$list; do $(MAKE) -C $$td; done |
55 | $(MAKE) -C @LINUX_OBJ@ M="$$PWD" @KERNEL_MAKE@ CONFIG_ZFS=m modules | |
bced7e3a | 56 | |
9f0a21e6 | 57 | modules-FreeBSD: |
33982eb2 | 58 | +$(FMAKE) |
9f0a21e6 | 59 | |
bced7e3a MM |
60 | modules-unknown: |
61 | @true | |
62 | ||
63 | modules: modules-@ac_system@ | |
c9c0d073 | 64 | |
bced7e3a | 65 | clean-Linux: |
d433c206 BB |
66 | @# Only cleanup the kernel build directories when CONFIG_KERNEL |
67 | @# is defined. This indicates that kernel modules should be built. | |
ccc421ec | 68 | @CONFIG_KERNEL_TRUE@ $(MAKE) -C @LINUX_OBJ@ M="$$PWD" @KERNEL_MAKE@ clean |
d433c206 | 69 | |
c9c0d073 BB |
70 | if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi |
71 | if [ -f Module.markers ]; then $(RM) Module.markers; fi | |
72 | ||
b669ab83 BB |
73 | find . -name '*.ur-safe' -type f -print | xargs $(RM) |
74 | ||
9f0a21e6 | 75 | clean-FreeBSD: |
33982eb2 | 76 | +$(FMAKE) clean |
9f0a21e6 | 77 | |
bced7e3a MM |
78 | clean: clean-@ac_system@ |
79 | ||
80 | modules_install-Linux: | |
6283f55e | 81 | @# Install the kernel modules |
ccc421ec | 82 | $(MAKE) -C @LINUX_OBJ@ M="$$PWD" modules_install \ |
ed3a3bdb | 83 | INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \ |
bb9d808c AP |
84 | INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \ |
85 | KERNELRELEASE=@LINUX_VERSION@ | |
fe0ed8f9 | 86 | @# Remove extraneous build products when packaging |
ed3a3bdb | 87 | kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ |
b0fe1ade | 88 | if [ -n "$(DESTDIR)" ]; then \ |
d09f98a9 | 89 | find $$kmoddir -name 'modules.*' | xargs $(RM); \ |
fe0ed8f9 | 90 | fi |
f68b9c81 RE |
91 | @# Debian ships tiny fake System.map files that are |
92 | @# syntactically valid but just say | |
93 | @# "if you want system.map go install this package" | |
94 | @# Naturally, depmod is less than amused by this. | |
95 | @# So if we find it missing or with one of these present, | |
96 | @# we check for the alternate path for the System.map | |
ed3a3bdb | 97 | sysmap=$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \ |
f68b9c81 RE |
98 | { [ -f "$$sysmap" ] && [ $$(wc -l < "$$sysmap") -ge 100 ]; } || \ |
99 | sysmap=$(INSTALL_MOD_PATH)/usr/lib/debug/boot/System.map-@LINUX_VERSION@; \ | |
c9c0d073 BB |
100 | if [ -f $$sysmap ]; then \ |
101 | depmod -ae -F $$sysmap @LINUX_VERSION@; \ | |
102 | fi | |
c9c0d073 | 103 | |
9f0a21e6 MM |
104 | modules_install-FreeBSD: |
105 | @# Install the kernel modules | |
33982eb2 | 106 | +$(FMAKE) install |
9f0a21e6 | 107 | |
bced7e3a MM |
108 | modules_install: modules_install-@ac_system@ |
109 | ||
110 | modules_uninstall-Linux: | |
6283f55e | 111 | @# Uninstall the kernel modules |
ed3a3bdb | 112 | kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ |
7c902a51 | 113 | for objdir in $(ZFS_MODULES); do \ |
ff4b68ee | 114 | $(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \ |
d09f98a9 | 115 | done |
c9c0d073 | 116 | |
9f0a21e6 MM |
117 | modules_uninstall-FreeBSD: |
118 | @false | |
119 | ||
bced7e3a MM |
120 | modules_uninstall: modules_uninstall-@ac_system@ |
121 | ||
0e6c493f BB |
122 | cppcheck-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 \ | |
129 | --include=@top_srcdir@/zfs_config.h \ | |
130 | --config-exclude=@LINUX_OBJ@/include \ | |
131 | -I @LINUX_OBJ@/include \ | |
132 | -I @top_srcdir@/include/os/linux/kernel \ | |
133 | -I @top_srcdir@/include/os/linux/spl \ | |
134 | -I @top_srcdir@/include/os/linux/zfs \ | |
135 | -I @top_srcdir@/include \ | |
136 | avl icp lua nvpair spl unicode zcommon zfs zstd os/linux | |
137 | ||
138 | cppcheck-FreeBSD: | |
139 | @true | |
140 | ||
141 | cppcheck: cppcheck-@ac_system@ | |
142 | ||
c9c0d073 | 143 | distdir: |
7c902a51 AS |
144 | (cd @srcdir@ && find $(ZFS_MODULES) os -name '*.[chS]') | \ |
145 | while read path; do \ | |
146 | mkdir -p $$distdir/$${path%/*}; \ | |
147 | cp @srcdir@/$$path $$distdir/$$path; \ | |
148 | done; \ | |
149 | cp @srcdir@/Makefile.bsd $$distdir/Makefile.bsd |