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 # VPATH contains at least SRCDIR
23 _INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y) \
24 $(RTE_OUTPUT)/kmod/$(MODULE).ko
27 SRCS_LINKS = $(addsuffix _link,$(SRCS-y))
29 compare = $(strip $(subst $(1),,$(2)) $(subst $(2),,$(1)))
35 install: build _postinstall
42 # Link all sources in build directory
44 $(if $(call compare,$(notdir $*),$*),\
45 @if [ ! -f $(notdir $(*)) ]; then ln -nfs $(SRCDIR)/$(*) . ; fi,\
46 @if [ ! -f $(notdir $(*)) ]; then ln -nfs $(SRCDIR)/$(*) . ; fi)
49 $(MODULE).ko: $(SRCS_LINKS)
50 @if [ ! -f $(notdir Makefile) ]; then ln -nfs $(SRCDIR)/Makefile . ; fi
51 @$(MAKE) -C $(RTE_KERNELDIR) M=$(CURDIR) O=$(RTE_KERNELDIR) \
52 CC="$(KERNELCC)" CROSS_COMPILE=$(CROSS) V=$(if $V,1,0)
54 # install module in $(RTE_OUTPUT)/kmod
55 $(RTE_OUTPUT)/kmod/$(MODULE).ko: $(MODULE).ko
56 @echo INSTALL-MODULE $(MODULE).ko
57 @[ -d $(RTE_OUTPUT)/kmod ] || mkdir -p $(RTE_OUTPUT)/kmod
58 @cp -f $(MODULE).ko $(RTE_OUTPUT)/kmod
62 @$(MAKE) -C $(RTE_KERNELDIR) M=$(CURDIR) O=$(RTE_KERNELDIR) \
68 # do a make clean and remove links
71 @if [ ! -f $(notdir Makefile) ]; then ln -nfs $(SRCDIR)/Makefile . ; fi
72 $(Q)$(MAKE) -C $(RTE_KERNELDIR) M=$(CURDIR) O=$(RTE_KERNELDIR) clean
73 @$(foreach FILE,$(SRCS-y) $(SRCS-n) $(SRCS-),\
74 if [ -h $(notdir $(FILE)) ]; then rm -f $(notdir $(FILE)) ; fi ;)
75 @if [ -h $(notdir Makefile) ]; then rm -f $(notdir Makefile) ; fi
76 @rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS) \
79 include $(RTE_SDK)/mk/internal/rte.install-post.mk
80 include $(RTE_SDK)/mk/internal/rte.clean-post.mk
81 include $(RTE_SDK)/mk/internal/rte.build-post.mk