xref: /freebsd/sys/contrib/openzfs/module/Makefile.in (revision eda14cbc264d6969b02f2b1994cef11148e914f1)
1*eda14cbcSMatt Macyinclude Kbuild
2*eda14cbcSMatt Macy
3*eda14cbcSMatt MacyINSTALL_MOD_DIR ?= extra
4*eda14cbcSMatt Macy
5*eda14cbcSMatt MacySUBDIR_TARGETS = icp lua zstd
6*eda14cbcSMatt Macy
7*eda14cbcSMatt Macyall: modules
8*eda14cbcSMatt Macydistclean maintainer-clean: clean
9*eda14cbcSMatt Macyinstall: modules_install
10*eda14cbcSMatt Macyuninstall: modules_uninstall
11*eda14cbcSMatt Macycheck:
12*eda14cbcSMatt Macy
13*eda14cbcSMatt Macy.PHONY: all distclean maintainer-clean install uninstall check distdir \
14*eda14cbcSMatt Macy	modules modules-Linux modules-FreeBSD modules-unknown \
15*eda14cbcSMatt Macy	clean clean-Linux clean-FreeBSD \
16*eda14cbcSMatt Macy	modules_install modules_install-Linux modules_install-FreeBSD \
17*eda14cbcSMatt Macy	modules_uninstall modules_uninstall-Linux modules_uninstall-FreeBSD
18*eda14cbcSMatt Macy
19*eda14cbcSMatt Macy# Filter out options that FreeBSD make doesn't understand
20*eda14cbcSMatt Macygetflags = ( \
21*eda14cbcSMatt Macyset -- \
22*eda14cbcSMatt Macy  $(filter-out --%,$(firstword $(MFLAGS))) \
23*eda14cbcSMatt Macy  $(filter -I%,$(MFLAGS)) \
24*eda14cbcSMatt Macy  $(filter -j%,$(MFLAGS)); \
25*eda14cbcSMatt Macyfmakeflags=""; \
26*eda14cbcSMatt Macywhile getopts :deiI:j:knqrstw flag; do \
27*eda14cbcSMatt Macy  case $$flag in \
28*eda14cbcSMatt Macy    \?) :;; \
29*eda14cbcSMatt Macy    :) if [ $$OPTARG = "j" ]; then \
30*eda14cbcSMatt Macy	 ncpus=$$(sysctl -n kern.smp.cpus 2>/dev/null || :); \
31*eda14cbcSMatt Macy	 if [ -n "$$ncpus" ]; then fmakeflags="$$fmakeflags -j$$ncpus"; fi; \
32*eda14cbcSMatt Macy       fi;; \
33*eda14cbcSMatt Macy    d) fmakeflags="$$fmakeflags -dA";; \
34*eda14cbcSMatt Macy    *) fmakeflags="$$fmakeflags -$$flag$$OPTARG";; \
35*eda14cbcSMatt Macy  esac; \
36*eda14cbcSMatt Macydone; \
37*eda14cbcSMatt Macyecho $$fmakeflags \
38*eda14cbcSMatt Macy)
39*eda14cbcSMatt MacyFMAKEFLAGS = -C @abs_srcdir@ -f Makefile.bsd $(shell $(getflags))
40*eda14cbcSMatt Macy
41*eda14cbcSMatt Macyifneq (@abs_srcdir@,@abs_builddir@)
42*eda14cbcSMatt MacyFMAKEFLAGS += MAKEOBJDIR=@abs_builddir@
43*eda14cbcSMatt Macyendif
44*eda14cbcSMatt MacyFMAKE = env -u MAKEFLAGS make $(FMAKEFLAGS)
45*eda14cbcSMatt Macy
46*eda14cbcSMatt Macymodules-Linux:
47*eda14cbcSMatt Macy	list='$(SUBDIR_TARGETS)'; for targetdir in $$list; do \
48*eda14cbcSMatt Macy		$(MAKE) -C $$targetdir; \
49*eda14cbcSMatt Macy	done
50*eda14cbcSMatt Macy	$(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ CONFIG_ZFS=m modules
51*eda14cbcSMatt Macy
52*eda14cbcSMatt Macymodules-FreeBSD:
53*eda14cbcSMatt Macy	+$(FMAKE)
54*eda14cbcSMatt Macy
55*eda14cbcSMatt Macymodules-unknown:
56*eda14cbcSMatt Macy	@true
57*eda14cbcSMatt Macy
58*eda14cbcSMatt Macymodules: modules-@ac_system@
59*eda14cbcSMatt Macy
60*eda14cbcSMatt Macyclean-Linux:
61*eda14cbcSMatt Macy	@# Only cleanup the kernel build directories when CONFIG_KERNEL
62*eda14cbcSMatt Macy	@# is defined.  This indicates that kernel modules should be built.
63*eda14cbcSMatt Macy@CONFIG_KERNEL_TRUE@	$(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ clean
64*eda14cbcSMatt Macy
65*eda14cbcSMatt Macy	if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi
66*eda14cbcSMatt Macy	if [ -f Module.markers ]; then $(RM) Module.markers; fi
67*eda14cbcSMatt Macy
68*eda14cbcSMatt Macy	find . -name '*.ur-safe' -type f -print | xargs $(RM)
69*eda14cbcSMatt Macy
70*eda14cbcSMatt Macyclean-FreeBSD:
71*eda14cbcSMatt Macy	+$(FMAKE) clean
72*eda14cbcSMatt Macy
73*eda14cbcSMatt Macyclean: clean-@ac_system@
74*eda14cbcSMatt Macy
75*eda14cbcSMatt Macymodules_install-Linux:
76*eda14cbcSMatt Macy	@# Install the kernel modules
77*eda14cbcSMatt Macy	$(MAKE) -C @LINUX_OBJ@ M=`pwd` modules_install \
78*eda14cbcSMatt Macy		INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \
79*eda14cbcSMatt Macy		INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
80*eda14cbcSMatt Macy		KERNELRELEASE=@LINUX_VERSION@
81*eda14cbcSMatt Macy	@# Remove extraneous build products when packaging
82*eda14cbcSMatt Macy	kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
83*eda14cbcSMatt Macy	if [ -n "$(DESTDIR)" ]; then \
84*eda14cbcSMatt Macy		find $$kmoddir -name 'modules.*' | xargs $(RM); \
85*eda14cbcSMatt Macy	fi
86*eda14cbcSMatt Macy	sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
87*eda14cbcSMatt Macy	if [ -f $$sysmap ]; then \
88*eda14cbcSMatt Macy		depmod -ae -F $$sysmap @LINUX_VERSION@; \
89*eda14cbcSMatt Macy	fi
90*eda14cbcSMatt Macy
91*eda14cbcSMatt Macymodules_install-FreeBSD:
92*eda14cbcSMatt Macy	@# Install the kernel modules
93*eda14cbcSMatt Macy	+$(FMAKE) install
94*eda14cbcSMatt Macy
95*eda14cbcSMatt Macymodules_install: modules_install-@ac_system@
96*eda14cbcSMatt Macy
97*eda14cbcSMatt Macymodules_uninstall-Linux:
98*eda14cbcSMatt Macy	@# Uninstall the kernel modules
99*eda14cbcSMatt Macy	kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@ \
100*eda14cbcSMatt Macy	for objdir in $(ZFS_MODULES); do \
101*eda14cbcSMatt Macy		$(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \
102*eda14cbcSMatt Macy	done
103*eda14cbcSMatt Macy
104*eda14cbcSMatt Macymodules_uninstall-FreeBSD:
105*eda14cbcSMatt Macy	@false
106*eda14cbcSMatt Macy
107*eda14cbcSMatt Macymodules_uninstall: modules_uninstall-@ac_system@
108*eda14cbcSMatt Macy
109*eda14cbcSMatt Macydistdir:
110*eda14cbcSMatt Macy	(cd @srcdir@ && find $(ZFS_MODULES) os -name '*.[chS]') | \
111*eda14cbcSMatt Macy	while read path; do \
112*eda14cbcSMatt Macy		mkdir -p $$distdir/$${path%/*}; \
113*eda14cbcSMatt Macy		cp @srcdir@/$$path $$distdir/$$path; \
114*eda14cbcSMatt Macy	done; \
115*eda14cbcSMatt Macy	cp @srcdir@/Makefile.bsd $$distdir/Makefile.bsd
116