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