1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2014 Intel Corporation
4 ##### if sourced from kernel Kbuild system
5 ifneq ($(KERNELRELEASE),)
6 override EXTRA_CFLAGS = $(MODULE_CFLAGS) $(EXTRA_KERNEL_CFLAGS)
8 ifneq ($(MODULE),$(notdir $(SRCS-y:%.c=%)))
9 $(MODULE)-objs += $(notdir $(SRCS-y:%.c=%.o))
12 ##### if launched from rte build system
15 include $(RTE_SDK)/mk/internal/rte.install-pre.mk
16 include $(RTE_SDK)/mk/internal/rte.clean-pre.mk
17 include $(RTE_SDK)/mk/internal/rte.build-pre.mk
19 # DPDK uses a more up-to-date gcc, so clear the override here.
21 override CFLAGS = $(MODULE_CFLAGS)
23 # VPATH contains at least SRCDIR
27 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y) \
28 $(RTE_OUTPUT)/kmod/$(MODULE).ko
31 SRCS_LINKS = $(addsuffix _link,$(SRCS-y))
33 compare = $(strip $(subst $(1),,$(2)) $(subst $(2),,$(1)))
39 install: build _postinstall
46 # Link all sources in build directory
48 $(if $(call compare,$(notdir $*),$*),\
49 $(Q)if [ ! -f $(notdir $(*)) ]; then ln -nfs $(SRCDIR)/$(*) . ; fi,\
50 $(Q)if [ ! -f $(notdir $(*)) ]; then ln -nfs $(SRCDIR)/$(*) . ; fi)
53 $(MODULE).ko: $(SRCS_LINKS)
54 $(Q)if [ ! -f $(notdir Makefile) ]; then ln -nfs $(SRCDIR)/Makefile . ; fi
55 $(Q)if [ ! -f $(notdir BSDmakefile) ]; then ln -nfs $(SRCDIR)/BSDmakefile . ; fi
56 $(Q)MAKEFLAGS= $(BSDMAKE)
58 # install module in $(RTE_OUTPUT)/kmod
59 $(RTE_OUTPUT)/kmod/$(MODULE).ko: $(MODULE).ko
60 $(Q)echo INSTALL-MODULE $(MODULE).ko
61 $(Q)[ -d $(RTE_OUTPUT)/kmod ] || mkdir -p $(RTE_OUTPUT)/kmod
62 $(Q)cp -f $(MODULE).ko $(RTE_OUTPUT)/kmod
66 $(Q)MAKEFLAGS= $(BSDMAKE) install
71 # do a make clean and remove links
74 $(Q)if [ ! -f $(notdir Makefile) ]; then ln -nfs $(SRCDIR)/Makefile . ; fi
75 $(Q)$(MAKE) -C $(RTE_KERNELDIR) M=$(CURDIR) O=$(RTE_KERNELDIR) clean
76 $(Q)$(foreach FILE,$(SRCS-y) $(SRCS-n) $(SRCS-),\
77 if [ -h $(notdir $(FILE)) ]; then rm -f $(notdir $(FILE)) ; fi ;)
78 $(Q)if [ -h $(notdir Makefile) ]; then rm -f $(notdir Makefile) ; fi
79 $(Q)rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS) \
82 include $(RTE_SDK)/mk/internal/rte.install-post.mk
83 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
84 include $(RTE_SDK)/mk/internal/rte.build-post.mk