Viewing: Makefile
# SPDX-License-Identifier: GPL-2.0
#
# This file is part of Lustre, http://www.lustre.org/
#
.DEFAULT_GOAL := __default
#
# The top-level autoMakefile is only used for 'make install' and 'make dist'.
# For the remaining make targets (often run interactively), we want to avoid
# warnings about redefining make targets. Hence, we conditionally include
# the autoMakefile.
#
ALWAYS_TARGETS := help checkpatch utils modules \
TAGS tags etags ctags cscope mkid \
checkstack checkstack-update checkstack-clean
ifeq ($(MAKECMDGOALS),)
-include autoMakefile
else ifneq ($(filter-out $(ALWAYS_TARGETS), $(MAKECMDGOALS)),)
-include autoMakefile
endif
#
# Include Makefile.exports to import the autoconf variables as plain make
# variables. Include the remaining make files to import their specific
# make targets.
#
-include config/Makefile.exports
-include config/Makefile.codetags
-include config/Makefile.pkg-rpm
-include config/Makefile.dkms-rpm
-include config/Makefile.pkg-deb
-include config/Makefile.dkms-deb
-include config/Makefile.checkstack
#
# Pass all lines in the make recipe to a single invocation of the shell
# See: https://www.gnu.org/software/make/manual/html_node/One-Shell.html
#
.ONESHELL:
#
# Help text in the style of the Linux kernel. When in doubt, try to mimic Linux
# style. And don't bother including intermediate build targets if they are not
# likely to be run iteractively.
#
help:
@echo 'Cleaning targets:'
echo ' clean - Remove generated object files but keep the files'
echo ' generated by autotools; use `git clean -xdf` to'
echo ' purge all files not tracked by git'
echo ''
echo 'Generic targets:'
echo ' all - Build all modules and utilities enabled by'
echo ' autotools'
echo ' utils - Build only userspace utilities'
echo ' modules - Build only kernel modules'
echo ' checkpatch - Run checkpatch.pl on latest commit'
echo ' checkstack - Run checkstack.pl'
echo ' checkstack-update - Update checkstack.pl'
echo ' checkstack-clean - Remove checkstack.pl artifacts'
echo ''
echo 'Packaging targets:'
echo ' rpms - Create RPM packages'
echo ' srpm - Create source RPM packages'
echo ' dkms-rpm - Create DKMS RPM packages'
echo ' dkms-srpm - Create source DKMS RPM packages'
echo ' debs - Create Debian packages'
echo ' dkms-debs - Create DKMS Debian packages'
#
# Run Lustre's custom checkpatch.pl script against the latest commit.
#
checkpatch:
@git diff HEAD~1 | ./contrib/scripts/checkpatch.pl
#
# Several modules (like ldiskfs or in-kernel-o2iblnd) define sources targets.
# This generic make target assigns 'foobar_sources' to run
# 'make source -C foobar'.
#
SOURCE_SUBDIRS := $(LUSTRE_BUILT_IN_KO2IBLND_NT) \
$(LUSTRE_LDISKFS_MT)
SOURCE_SUBDIRS_TGT = $(addsuffix _sources,$(SOURCE_SUBDIRS))
.PHONY: $(SOURCE_SUBDIRS_TGT)
$(SOURCE_SUBDIRS_TGT):
$(MAKE) sources -C $(patsubst %_sources,%,$@)
#
# Generic make target to assigns 'foobar' to 'make -C foobar'.
#
SUBDIRS := $(LUSTRE_IOKIT_MT) $(LUSTRE_LDISKFS_MT) \
Documentation lustre/tests lustre/scripts \
lustre/conf lib lnet/utils lustre/utils
.PHONY: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
#
# lnet/klnds/o2iblnd is used to build the Infiniband LNet driver against the
# out-of-tree Mellanox driver. This is split to a separate build target so that
# the generic module build target doesn't require external symbol versions.
#
.PHONY: lnet/klnds/o2iblnd
lnet/klnds/o2iblnd: __modules
$(MAKE) BUILD_EXT_O2IB=yes \
KBUILD_EXTRA_SYMBOLS="$(PWD)/Module.symvers $(LUSTRE_EXT_O2IB_SYMBOLS) $(LUSTRE_EXTRA_SYMBOLS)" \
CC="$(LUSTRE_CC)" -C $(LUSTRE_LINUX_OBJ) \
M=$(PWD)/lnet/klnds/o2iblnd
#
# Build the in-kernel-o2iblnd module as ko2iblnd.ko and rename it to
# in-kernel-ko2iblnd.ko so that the kernel recognizes the module as
# ko2iblnd despite the file name being in-kernel-ko2iblnd.
#
.PHONY: lnet/klnds/in-kernel-o2iblnd
lnet/klnds/in-kernel-o2iblnd: __modules
cp -vf lnet/klnds/in-kernel-o2iblnd/ko2iblnd.ko \
lnet/klnds/in-kernel-o2iblnd/in-kernel-ko2iblnd.ko
#
# This is the entry point to the Linux build system. The top-level Kbuild file
# is the next file invoked by this target.
#
.PHONY: __modules
__modules: $(SOURCE_SUBDIRS_TGT)
$(MAKE) KBUILD_EXTRA_SYMBOLS="$(LUSTRE_INT_O2IB_SYMBOLS) $(LUSTRE_EXTRA_SYMBOLS) $(KBUILD_EXTRA_SYMBOLS)" \
CC="$(LUSTRE_CC)" -C $(LUSTRE_LINUX_OBJ) \
M=$(PWD)
#
# Express dependencies for the already defined make targets. Make automatically
# combines make targets with the same name if they are in the same file. By
# listing the dependencies at the end, we can define most targets using generic
# make targets.
#
lnet/utils: lib
lustre/utils: lib lnet/utils
utils: lib lnet/utils lustre/utils
lustre/tests: utils
ldiskfs: $(SOURCE_SUBDIRS_TGT)
modules: __modules $(LUSTRE_BUILT_IN_KO2IBLND_NT) $(LUSTRE_EXTERNAL_KO2IBLND_NT)
__default: utils $(LUSTRE_MODULES_MT) $(SUBDIRS)