Support out-of-tree kmod build on FreeBSD
If srcdir != builddir, pass down MAKEOBJDIR to the FreeBSD make to support out-of-tree builds. Also allow passing all the gmake options that FreeBSD make understands to support useful flags like -k, -n, -q etc, and detect the number of CPUs if -j was specified without an argument. Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu> Closes #10493
This commit is contained in:
parent
f21de6883f
commit
33982eb24c
|
@ -10,16 +10,41 @@ install: modules_install
|
||||||
uninstall: modules_uninstall
|
uninstall: modules_uninstall
|
||||||
check:
|
check:
|
||||||
|
|
||||||
|
# Filter out options that FreeBSD make doesn't understand
|
||||||
|
getflags = ( \
|
||||||
|
set -- \
|
||||||
|
$(filter-out --%,$(firstword $(MFLAGS))) \
|
||||||
|
$(filter -I%,$(MFLAGS)) \
|
||||||
|
$(filter -j%,$(MFLAGS)); \
|
||||||
|
fmakeflags=""; \
|
||||||
|
while getopts :deiI:j:knqrstw flag; do \
|
||||||
|
case $$flag in \
|
||||||
|
\?) :;; \
|
||||||
|
:) if [ $$OPTARG = "j" ]; then \
|
||||||
|
ncpus=$$(sysctl -n kern.smp.cpus 2>/dev/null || :); \
|
||||||
|
if [ -n "$$ncpus" ]; then fmakeflags="$$fmakeflags -j$$ncpus"; fi; \
|
||||||
|
fi;; \
|
||||||
|
d) fmakeflags="$$fmakeflags -dA";; \
|
||||||
|
*) fmakeflags="$$fmakeflags -$$flag$$OPTARG";; \
|
||||||
|
esac; \
|
||||||
|
done; \
|
||||||
|
echo $$fmakeflags \
|
||||||
|
)
|
||||||
|
FMAKEFLAGS = -C @abs_srcdir@ -f Makefile.bsd $(shell $(getflags))
|
||||||
|
|
||||||
|
ifneq (@abs_srcdir@,@abs_builddir@)
|
||||||
|
FMAKEFLAGS += MAKEOBJDIR=@abs_builddir@
|
||||||
|
endif
|
||||||
|
FMAKE = env -u MAKEFLAGS make $(FMAKEFLAGS)
|
||||||
|
|
||||||
modules-Linux:
|
modules-Linux:
|
||||||
list='$(SUBDIR_TARGETS)'; for targetdir in $$list; do \
|
list='$(SUBDIR_TARGETS)'; for targetdir in $$list; do \
|
||||||
$(MAKE) -C $$targetdir; \
|
$(MAKE) -C $$targetdir; \
|
||||||
done
|
done
|
||||||
$(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ CONFIG_ZFS=m modules
|
$(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNEL_MAKE@ CONFIG_ZFS=m modules
|
||||||
|
|
||||||
# Only pass down gmake -j flag, if used.
|
|
||||||
modules-FreeBSD:
|
modules-FreeBSD:
|
||||||
flags="$$(echo $$MAKEFLAGS | awk -v RS=' ' /^-j/)"; \
|
+$(FMAKE)
|
||||||
env MAKEFLAGS="" make $${flags} -f Makefile.bsd
|
|
||||||
|
|
||||||
modules-unknown:
|
modules-unknown:
|
||||||
@true
|
@true
|
||||||
|
@ -37,8 +62,7 @@ clean-Linux:
|
||||||
find . -name '*.ur-safe' -type f -print | xargs $(RM)
|
find . -name '*.ur-safe' -type f -print | xargs $(RM)
|
||||||
|
|
||||||
clean-FreeBSD:
|
clean-FreeBSD:
|
||||||
flags="$$(echo $$MAKEFLAGS | awk -v RS=' ' /^-j/)"; \
|
+$(FMAKE) clean
|
||||||
env MAKEFLAGS="" make $${flags} -f Makefile.bsd clean
|
|
||||||
|
|
||||||
clean: clean-@ac_system@
|
clean: clean-@ac_system@
|
||||||
|
|
||||||
|
@ -87,8 +111,7 @@ cscopelist-am: $(am__tagged_files)
|
||||||
|
|
||||||
modules_install-FreeBSD:
|
modules_install-FreeBSD:
|
||||||
@# Install the kernel modules
|
@# Install the kernel modules
|
||||||
flags="$$(echo $$MAKEFLAGS | awk -v RS=' ' /^-j/)"; \
|
+$(FMAKE) install
|
||||||
env MAKEFLAGS="" make $${flags} -f Makefile.bsd install
|
|
||||||
|
|
||||||
modules_install: modules_install-@ac_system@
|
modules_install: modules_install-@ac_system@
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue