]>
Commit | Line | Data |
---|---|---|
71504277 | 1 | include Kbuild |
c9c0d073 | 2 | |
d09f98a9 BB |
3 | INSTALL_MOD_DIR ?= extra |
4 | ||
d99a0153 | 5 | SUBDIR_TARGETS = icp lua |
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 \ | |
17 | modules_uninstall modules_uninstall-Linux modules_uninstall-FreeBSD | |
18 | ||
33982eb2 AS |
19 | # Filter out options that FreeBSD make doesn't understand |
20 | getflags = ( \ | |
21 | set -- \ | |
22 | $(filter-out --%,$(firstword $(MFLAGS))) \ | |
23 | $(filter -I%,$(MFLAGS)) \ | |
24 | $(filter -j%,$(MFLAGS)); \ | |
25 | fmakeflags=""; \ | |
26 | while getopts :deiI:j:knqrstw flag; do \ | |
27 | case $$flag in \ | |
28 | \?) :;; \ | |
29 | :) if [ $$OPTARG = "j" ]; then \ | |
30 | ncpus=$$(sysctl -n kern.smp.cpus 2>/dev/null || :); \ | |
31 | if [ -n "$$ncpus" ]; then fmakeflags="$$fmakeflags -j$$ncpus"; fi; \ | |
32 | fi;; \ | |
33 | d) fmakeflags="$$fmakeflags -dA";; \ | |
34 | *) fmakeflags="$$fmakeflags -$$flag$$OPTARG";; \ | |
35 | esac; \ | |
36 | done; \ | |
37 | echo $$fmakeflags \ | |
38 | ) | |
39 | FMAKEFLAGS = -C @abs_srcdir@ -f Makefile.bsd $(shell $(getflags)) | |
40 | ||
41 | ifneq (@abs_srcdir@,@abs_builddir@) | |
42 | FMAKEFLAGS += MAKEOBJDIR=@abs_builddir@ | |
43 | endif | |
44 | FMAKE = env -u MAKEFLAGS make $(FMAKEFLAGS) | |
45 | ||
bced7e3a | 46 | modules-Linux: |
0b04990a TC |
47 | list='$(SUBDIR_TARGETS)'; for targetdir in $$list; do \ |
48 | $(MAKE) -C $$targetdir; \ | |
49 | done | |
bced7e3a MM |
50 | $(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ CONFIG_ZFS=m modules |
51 | ||
9f0a21e6 | 52 | modules-FreeBSD: |
33982eb2 | 53 | +$(FMAKE) |
9f0a21e6 | 54 | |
bced7e3a MM |
55 | modules-unknown: |
56 | @true | |
57 | ||
58 | modules: modules-@ac_system@ | |
c9c0d073 | 59 | |
bced7e3a | 60 | clean-Linux: |
d433c206 BB |
61 | @# Only cleanup the kernel build directories when CONFIG_KERNEL |
62 | @# is defined. This indicates that kernel modules should be built. | |
bced7e3a | 63 | @CONFIG_KERNEL_TRUE@ $(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ clean |
d433c206 | 64 | |
c9c0d073 BB |
65 | if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi |
66 | if [ -f Module.markers ]; then $(RM) Module.markers; fi | |
67 | ||
b669ab83 BB |
68 | find . -name '*.ur-safe' -type f -print | xargs $(RM) |
69 | ||
9f0a21e6 | 70 | clean-FreeBSD: |
33982eb2 | 71 | +$(FMAKE) clean |
9f0a21e6 | 72 | |
bced7e3a MM |
73 | clean: clean-@ac_system@ |
74 | ||
75 | modules_install-Linux: | |
6283f55e | 76 | @# Install the kernel modules |
bced7e3a | 77 | $(MAKE) -C @LINUX_OBJ@ M=`pwd` modules_install \ |
d09f98a9 | 78 | INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \ |
bb9d808c AP |
79 | INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \ |
80 | KERNELRELEASE=@LINUX_VERSION@ | |
fe0ed8f9 | 81 | @# Remove extraneous build products when packaging |
d09f98a9 | 82 | kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ |
b0fe1ade | 83 | if [ -n "$(DESTDIR)" ]; then \ |
d09f98a9 | 84 | find $$kmoddir -name 'modules.*' | xargs $(RM); \ |
fe0ed8f9 | 85 | fi |
d09f98a9 | 86 | sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \ |
c9c0d073 BB |
87 | if [ -f $$sysmap ]; then \ |
88 | depmod -ae -F $$sysmap @LINUX_VERSION@; \ | |
89 | fi | |
c9c0d073 | 90 | |
9f0a21e6 MM |
91 | modules_install-FreeBSD: |
92 | @# Install the kernel modules | |
33982eb2 | 93 | +$(FMAKE) install |
9f0a21e6 | 94 | |
bced7e3a MM |
95 | modules_install: modules_install-@ac_system@ |
96 | ||
97 | modules_uninstall-Linux: | |
6283f55e | 98 | @# Uninstall the kernel modules |
0b032548 | 99 | kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@ \ |
71504277 | 100 | list='$(ZFS_MODULES)'; for objdir in $$list; do \ |
ff4b68ee | 101 | $(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \ |
d09f98a9 | 102 | done |
c9c0d073 | 103 | |
9f0a21e6 MM |
104 | modules_uninstall-FreeBSD: |
105 | @false | |
106 | ||
bced7e3a MM |
107 | modules_uninstall: modules_uninstall-@ac_system@ |
108 | ||
c9c0d073 | 109 | distdir: |
71504277 | 110 | list='$(ZFS_MODULES)'; for objdir in $$list os/linux/spl os/linux/zfs; do \ |
9f0a21e6 MM |
111 | (cd @top_srcdir@/module && find $$objdir -name '*.[chS]' | \ |
112 | while read path; do \ | |
113 | mkdir -p @abs_top_builddir@/module/$$distdir/$${path%/*}; \ | |
114 | cp $$path @abs_top_builddir@/module/$$distdir/$$path; \ | |
115 | done); \ | |
47a4a6fd | 116 | done |