]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/openzfs/module/Makefile.in
Update OpenZFS to 2.0.0-rc3-gfc5966
[FreeBSD/FreeBSD.git] / sys / contrib / openzfs / module / Makefile.in
1 include Kbuild
2
3 INSTALL_MOD_DIR ?= extra
4
5 SUBDIR_TARGETS = icp lua zstd
6
7 all: modules
8 distclean maintainer-clean: clean
9 install: modules_install
10 uninstall: modules_uninstall
11 check:
12
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
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
46 modules-Linux:
47         list='$(SUBDIR_TARGETS)'; for targetdir in $$list; do \
48                 $(MAKE) -C $$targetdir; \
49         done
50         $(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ CONFIG_ZFS=m modules
51
52 modules-FreeBSD:
53         +$(FMAKE)
54
55 modules-unknown:
56         @true
57
58 modules: modules-@ac_system@
59
60 clean-Linux:
61         @# Only cleanup the kernel build directories when CONFIG_KERNEL
62         @# is defined.  This indicates that kernel modules should be built.
63 @CONFIG_KERNEL_TRUE@    $(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ clean
64
65         if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi
66         if [ -f Module.markers ]; then $(RM) Module.markers; fi
67
68         find . -name '*.ur-safe' -type f -print | xargs $(RM)
69
70 clean-FreeBSD:
71         +$(FMAKE) clean
72
73 clean: clean-@ac_system@
74
75 modules_install-Linux:
76         @# Install the kernel modules
77         $(MAKE) -C @LINUX_OBJ@ M=`pwd` modules_install \
78                 INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \
79                 INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
80                 KERNELRELEASE=@LINUX_VERSION@
81         @# Remove extraneous build products when packaging
82         kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
83         if [ -n "$(DESTDIR)" ]; then \
84                 find $$kmoddir -name 'modules.*' | xargs $(RM); \
85         fi
86         sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
87         if [ -f $$sysmap ]; then \
88                 depmod -ae -F $$sysmap @LINUX_VERSION@; \
89         fi
90
91 modules_install-FreeBSD:
92         @# Install the kernel modules
93         +$(FMAKE) install
94
95 modules_install: modules_install-@ac_system@
96
97 modules_uninstall-Linux:
98         @# Uninstall the kernel modules
99         kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
100         for objdir in $(ZFS_MODULES); do \
101                 $(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \
102         done
103
104 modules_uninstall-FreeBSD:
105         @false
106
107 modules_uninstall: modules_uninstall-@ac_system@
108
109 distdir:
110         (cd @srcdir@ && find $(ZFS_MODULES) os -name '*.[chS]') | \
111         while read path; do \
112                 mkdir -p $$distdir/$${path%/*}; \
113                 cp @srcdir@/$$path $$distdir/$$path; \
114         done; \
115         cp @srcdir@/Makefile.bsd $$distdir/Makefile.bsd