blob: 886b22f1e802223e232327b7a773a2b06fa4fb89 [file] [log] [blame]
# Common Makefile rules
#
# For linux_lib we don't build anything. Object files are just added
# when compiling modules depending on the libs
ifeq ("$(MOD_TYPE)", "linux_lib")
# Skip libraries that might have crept in dependencies
SKIP_LIB_MODULES = y
export SKIP_LIB_MODULES
endif
ifeq ("$(MOD_TYPE)", "linux_module")
# Skip libraries that might have crept in dependencies
SKIP_LIB_MODULES = y
export SKIP_LIB_MODULES
endif
ifeq ("$(MOD_TYPE)", "lib")
MODULE_IS_A_LIBRARY = y
else ifeq ("$(MOD_TYPE)", "shared_lib")
MODULE_IS_A_LIBRARY = y
else
MODULE_IS_A_LIBRARY = n
endif
# Include module's own auto-generated Makefile.config.$(MODULE) file if any
# It in turn includes all dependencies
ifeq (x"$(V)", x"2")
$(info !!!MOD_NAME=$(MOD_NAME) MOD_TYPE=$(MOD_TYPE) MOD_TARGET=$(MOD_TARGET))
$(info !!!Including own dependency file: $(OUT_DIR_BASE)/Makefile.config.$(MOD_NAME))
endif
-include $(OUT_DIR_BASE)/Makefile.config.$(MOD_NAME)
ifeq (x"$(V)", x"2")
$(info !!!After include of $(OUT_DIR_BASE)/Makefile.config.$(MOD_NAME))
endif
ifeq (x"$(V)", x"2")
$(info !!! Building $(MOD_TYPE) module $(MOD_NAME): depends on $(MOD_DEPS_FILES) SKIP_LIBS=$(SKIP_LIB_MODULES))
endif
# Skip default rules for custom module
ifneq ("$(MOD_CUSTOM)", "y")
# Default lib rule
ifeq ("$(MOD_TYPE)", "lib")
ifeq ("$(SKIP_LIB_MODULES)", "y")
$(MOD_TARGET):
# of ifneq ("$(SKIP_LIB_MODULES)", "y")
else
# Create library if there are any objects
$(MOD_TARGET): $(OBJS)
ifneq ("$(OBJS)", "")
$(SILENT_BUILD)$(BLD_AR) $(ARFLAGS) $@ $(OBJS)
ifeq ("$(MOD_POST_BUILD)", "")
@$(BOLD_PRINT) "done: $@"
endif
endif
ifneq ("$(MOD_POST_BUILD)", "")
$(SILENT_BUILD)$(MOD_POST_BUILD)
@$(BOLD_PRINT) "done: $@"
endif
$(SILENT_BUILD)touch $(OUT_DIR_BASE)/.$(MOD_NAME)
# end of ifeq ("$(SKIP_LIB_MODULES)", "y")
endif
# end of ifeq ("$(MOD_TYPE)", "lib")
endif
# Default shared_lib rule
ifeq ("$(MOD_TYPE)", "shared_lib")
EXTRA_CFLAGS += -fPIC
# Create library if there are any objects
$(MOD_TARGET): $(OBJS)
ifneq ("$(OBJS)", "")
$(SILENT_BUILD)$(BLD_CC) -shared -o $@ $(OBJS) $(LFLAGS)
$(SILENT_BUILD)mkdir -p $(SHARED_LIB_DIR)
$(SILENT_BUILD)cp $@ $(SHARED_LIB_DIR)/
ifeq ("$(MOD_POST_BUILD)", "")
@$(BOLD_PRINT) "done: $@"
endif
endif
ifneq ("$(MOD_POST_BUILD)", "")
$(SILENT_BUILD)$(MOD_POST_BUILD)
@$(BOLD_PRINT) "done: $@"
endif
$(SILENT_BUILD)touch $(OUT_DIR_BASE)/.$(MOD_NAME)
# end of ifeq ("$(MOD_TYPE)", "shared_lib")
endif
# Default app rule
ifeq ("$(MOD_TYPE)", "app")
$(MOD_TARGET): $(OBJS) $(MOD_DEPS_FILES)
$(SILENT_BUILD)$(BLD_CC) -o $@ $(OBJS) $(LFLAGS) $(EXTRA_LIBS_PATH) $(EXTRA_LIBS_NOREC_BEFORE) $(LIBS_START_MARKER) $(EXTRA_LIBS) $(LIBS_END_MARKER) $(EXTRA_LIBS_NOREC_AFTER) $(LIBS)
ifneq ("$(MOD_POST_BUILD)", "")
$(SILENT_BUILD)$(MOD_POST_BUILD)
endif
$(SILENT_BUILD)touch $(OUT_DIR_BASE)/.$(MOD_NAME)
@$(BOLD_PRINT) "done: $(OUT_DIR)/$(MOD_NAME)"
# endif of ifeq ("$(MOD_TYPE)", "app")
endif
# For linux_lib we don't build anything. Object files are just added
# when compiling modules depending on the libs
ifeq ("$(MOD_TYPE)", "linux_lib")
LINUX_LIB_OBJECTS := $(srcs:%.c=$(SRC_DIR)/%.o)
$(MOD_TARGET): $(SRCS) $(GEN_SRCS) $(MOD_DEPS_FILES)
$(SILENT_BUILD)touch $(MOD_TARGET)
$(SILENT_BUILD)touch $(OUT_DIR_BASE)/.$(MOD_NAME)
endif
# Default linux_module$(srcs:%=$(SRC_DIR)/%)
ifeq ("$(MOD_TYPE)", "linux_module")
obj-m += $(MOD_NAME).o
$(MOD_NAME)-objs := $(srcs:%.c=%.o)
LIB_OBJS_REL_PATH = $(foreach oo,$(ALL_LIB_OBJS),$(shell python -c "import os.path; print os.path.relpath('$(oo)', '$(SRC_DIR)')"))
_KERNEL_MAKEPARMS = -C $(KERNELDIR) M=$(SRC_DIR) KBUILD_EXTRA_SYMBOLS="$(KBUILD_EXTRA_SYMBOLS)" \
O=$(KERNEL_OUTDIR) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) V=$(V) EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
obj-m=$(obj-m) $(MOD_NAME)-objs="$($(MOD_NAME)-objs) $(LIB_OBJS_REL_PATH)"
KERNEL_MAKEPARMS = $(_KERNEL_MAKEPARMS:%os_abstraction/posix=%os_abstraction/linux)
# Prevent parallel build
.NOTPARALLEL:
# Only build linux module if not already being built by another make thread.
# Otherwise, linux build system get confused
# Also, remove -s flag using MAKEFLAGS. Otherwise, linux build system will not print names of the files
# being compiled
$(MOD_TARGET): $(SRCS) $(MOD_DEPS_FILES)
ifneq ("$(SRC_DIR)", "$(TOP_DIR)/$(MOD_DIR)")
@cp -f $(TOP_DIR)/$(MOD_DIR)/Makefile $(SRC_DIR)
endif
$(SILENT_BUILD)if [ ! -f $(SRC_DIR)/.$(MOD_NAME)_in_progress ]; then \
touch $(SRC_DIR)/.$(MOD_NAME)_in_progress; \
MAKEFLAGS= $(MAKE) $(KERNEL_MAKEPARMS) ;\
if [[ "$$?" != "0" ]]; then \
rm -f $(SRC_DIR)/.$(MOD_NAME)_in_progress;\
exit -2;\
fi; \
mkdir -p $(OUT_DIR_BASE)/linux_modules ;\
touch -c $(MOD_TARGET) ;\
cp $(SRC_DIR)/$(MOD_NAME).ko $(OUT_DIR_BASE)/linux_modules/ ;\
touch $(OUT_DIR_BASE)/.$(MOD_NAME) ;\
$(BOLD_PRINT) "done: $(MOD_TARGET)" ;\
rm -f $(SRC_DIR)/.$(MOD_NAME)_in_progress ;\
fi
# Take care of compiling generated code for linux kernel
ifneq ("$(SRC_DIR)", "$(TOP_DIR)/$(MOD_DIR)")
$(SRC_DIR)/%.c : $(CODEGEN_OUTPUT_DIR)/../%.c
$(SILENT_BUILD)cp -f $(CODEGEN_OUTPUT_DIR)/../*.[c,h] $(SRC_DIR)/
$(SRC_DIR)/%.h : $(CODEGEN_OUTPUT_DIR)/../%.h
$(SILENT_BUILD)cp -f $(CODEGEN_OUTPUT_DIR)/../*.[c,h] $(SRC_DIR)/
endif
# End of MOD_TYPE==linux_module
endif
# else of ifneq ("$(MOD_CUSTOM)", "y")
else
# only for MOD_CUSTOM include Module Makefile second time for propagate
# custom rules, first time included in Makefile.config for all modules
include $(SRC_DIR)/Makefile
# End of ifneq ($(MOD_CUSTOM), y)
endif
$(OUT_DIR)/%.o: $(SRC_DIR)/%.c $(OUT_DIR_BASE)/Makefile.config.$(MOD_NAME)
ifeq (x"$(V)", x"0")
@echo "CC $<"
endif
$(SILENT_BUILD)mkdir -p $(dir $@)
$(SILENT_BUILD)$(BLD_CC) $(CFLAGS) -D__BASENAME__=`basename $<` -c -o $@ $<
ifeq (x"$(USE_LINT)", x"yes")
ifeq (x"$(V)", x"0")
@echo "LINT $<"
endif
$(SILENT_BUILD)FORCE_LINT=$(FORCE_LINT) $(MAKE_DEVICE_DIR)/lint.sh $(LINT_FLAGS) $(filter -I% -D%, $(CFLAGS)) $< || { rm $@; false; }
endif
ifeq (x"$(USE_CLANG)", x"y")
ifeq (x"$(V)", x"0")
_fn=`basename "$<" .c` ;\
eval "_disable_fn_set=\$${DISABLE_CLANG_$$_fn}"; \
if test "$$_disable_fn_set" != "y" ; then echo "CLANG $<"; else echo "CLANG $< ... skipped"; fi
endif
_fn=`basename "$<" .c` ;\
eval "_disable_fn_set=\$${DISABLE_CLANG_$$_fn}"; \
if test "$$_disable_fn_set" != "y" ; then $(CLANG) $(CLANG_FLAGS) -c $< -o $@.clang && rm -f $@.clang; fi
# end of ifeq (x"$(USE_CLANG)", x"y")
endif
$(OUT_DIR)/%.o: $(SRC_DIR)/%.s $(OUT_DIR_BASE)/Makefile.config.$(MOD_NAME)
ifeq (x"$(V)", x"0")
@echo "AS $<"
endif
$(SILENT_BUILD)mkdir -p $(dir $@)
$(SILENT_BUILD)$(BLD_AS) $(asFLAGS) -o $@ $<
$(OUT_DIR)/%.o: $(SRC_DIR)/%.S $(OUT_DIR_BASE)/Makefile.config.$(MOD_NAME)
ifeq (x"$(V)", x"0")
@echo "AS $<"
endif
$(SILENT_BUILD)mkdir -p $(dir $@)
$(SILENT_BUILD)$(BLD_CC) $(ASFLAGS) -o $@ $<
$(OUT_DIR)/%.d: $(SRC_DIR)/%.c $(SRC_DIR)/Makefile
ifneq ("$(BUILD_DEPS_IN_CC)", "y")
ifeq (x"$(V)", x"0")
@echo "DP $<"
endif
$(SILENT_BUILD)mkdir -p $(dir $@)
$(SILENT_BUILD)$(BLD_DEP) -MM -MT $(@:.d=.o) $(DEP_FLAGS) $< > $@ && sed 's,\($*\.o\)[ :]*,\1 $@ : ,g' -i $@
endif
$(CODEGEN_OUTPUT_DIR)/%.o: $(CODEGEN_OUTPUT_DIR)/%.c $(OUT_DIR_BASE)/Makefile.config.$(MOD_NAME)
ifeq (x"$(V)", x"0")
@echo "CC $<"
endif
$(SILENT_BUILD)mkdir -p $(dir $@)
$(SILENT_BUILD)$(BLD_CC) $(CFLAGS) -D__BASENAME__=`basename $<` -c -o $@ $<
$(CODEGEN_OUTPUT_DIR)/%.d: $(CODEGEN_OUTPUT_DIR)/%.c $(SRC_DIR)/Makefile
ifneq ("$(BUILD_DEPS_IN_CC)", "y")
ifeq (x"$(V)", x"0")
@echo "DP $<"
endif
$(SILENT_BUILD)mkdir -p $(dir $@)
$(SILENT_BUILD)$(BLD_DEP) -MM -MT $(@:.d=.o) $(DEP_FLAGS) $< > $@ && sed 's,\($*\.o\)[ :]*,\1 $@ : ,g' -i $@
endif
ifneq ("$(SKIP_DEPS)", "yes")
ifneq ("$(MOD_TYPE)", "linux_module")
ifneq ("$(MOD_TYPE)", "linux_lib")
-include $(OBJS:.o=.d)
endif
endif
endif
BUILD_UNITEST = $(UNITEST)
ifeq ("$(OBJS)", "")
BUILD_UNITEST = n
endif
# Only build unitest if library objects are included
ifeq ("$(BUILD_UNITEST)", "y")
unitest: $(OUT_DIR)/unitest
$(OUT_DIR)/unitest: $(OUT_DIR)/unitest.o $(TARGET_LIB_FNAME) $(MOD_DEPS_FILES)
$(SILENT_BUILD)$(BLD_CC) -o $@ $(OUT_DIR)/unitest.o $(LFLAGS) $(EXTRA_LIBS_PATH) $(LIBS_START_MARKER) $(EXTRA_LIBS) $(LIBS_END_MARKER) $(LIBS)
$(SILENT_BUILD)touch $(OUT_DIR_BASE)/.$(MOD_NAME)
@$(BOLD_PRINT) "done: $@"
# else of ifneq ("$(BUILD_UNITEST)", "y")
else
unitest: $(TARGET_LIB_FNAME) $(MOD_DEPS_FILES)
# endif of ifneq ("$(BUILD_UNITEST)", "y")
endif
# Generate sources if necessary
ifneq ("$(GEN_SRCS)$(GEN_HDRS)$(GEN_OMCI_SRCS)$(GEN_OMCI_HDRS)$(GEN_OMCI_STACK_SRCS)$(GEN_OMCI_STACK_HDRS)", "")
$(GEN_BAL_SRCS) $(GEN_BAL_HDRS): $(OUT_DIR)/.$(MOD_NAME)_generated_bal
$(GEN_OMCI_SRCS) $(GEN_OMCI_HDRS): $(OUT_DIR)/.$(MOD_NAME)_generated_omci
$(GEN_OMCI_STACK_SRCS) $(GEN_OMCI_STACK_HDRS): $(OUT_DIR)/.$(MOD_NAME)_generated_omci_stack
$(OUT_DIR)/.$(MOD_NAME)_generated_bal: $(BAL_MODEL_FILE) $(wildcard $(CODEGEN_DIR)/*) $(wildcard $(CODEGEN_INPUT_DIR)/*)
$(call gen_cmd,$(GEN_BAL_SRCS),$(GEN_BAL_HDRS),$(BAL_MODEL_FILE),"bcmbal")
$(OUT_DIR)/.$(MOD_NAME)_generated_omci: $(OMCI_MODEL_FILE) $(wildcard $(CODEGEN_DIR)/*) $(wildcard $(CODEGEN_INPUT_DIR)/*)
$(call gen_cmd,$(GEN_OMCI_SRCS),$(GEN_OMCI_HDRS),$(OMCI_MODEL_FILE),"bcmomci")
$(OMCI_STACK_CODEGEN_EXE): $(OMCI_STACK_CODEGEN_INPUT_DIR)/omci_me_codegen.c
mkdir -p $(OUT_DIR)
$(BLD_CC_HOST) $(EXTRA_CFLAGS) -gdwarf-3 -o $@ $< -I$(TOP_DIR)/src/common/os_abstraction -I$(TOP_DIR)/src/common/os_abstraction/posix -I$(TOP_DIR)/src/common/config -I$(TOP_DIR)/src/core/platform -I$(TOP_DIR)/src/common/include
$(OUT_DIR)/.$(MOD_NAME)_generated_omci_stack: $(OMCI_STACK_MODEL_FILE) $(wildcard $(CODEGEN_DIR)/*) $(wildcard $(CODEGEN_INPUT_DIR)/*) $(OMCI_STACK_CODEGEN_EXE)
$(call gen_omci_stack_cmd,$(GEN_OMCI_STACK_SRCS),$(GEN_OMCI_STACK_HDRS),$(OMCI_STACK_MODEL_FILE),"bcm_omci")
define gen_cmd
mkdir -p $(CODEGEN_OUTPUT_DIR)
echo "Generating code from model: $(notdir $1 $2)"
$(MONO_PATH) $(CODEGEN_EXE) --genobjmodel -objset="$3" -style=bal -prefix=$4 \
-templatedir="$(CODEGEN_INPUT_DIR)" -outdir="$(CODEGEN_OUTPUT_DIR)"
touch $@
echo "Code generation complete!"
endef
define gen_omci_stack_cmd
echo "Generating code from model: $(notdir $1 $2)"
$(OMCI_STACK_CODEGEN_EXE) $4 $(OUT_DIR) $3 $(addprefix $(OMCI_STACK_CODEGEN_INPUT_DIR)/, $(addsuffix .tmpl, $(notdir $1 $2)))
for file in $(GEN_OMCI_STACK_HDRS) $(GEN_OMCI_STACK_SRCS); do \
$(TOP_DIR)/tools/copyright_tools/insert_copyright.pl -t c -l $(TOP_DIR)/COPYRIGHT $$file > $$file.tmp; \
mv $$file.tmp $$file; \
done
touch $@
echo "Code generation complete!"
endef
# end of ifneq ("$(GEN_SRCS)$(GEN_HDRS)$(GEN_OMCI_SRCS)$(GEN_OMCI_HDRS)$(GEN_OMCI_STACK_SRCS)$(GEN_OMCI_STACK_HDRS)", "")
endif
#
# Dependency rules generation: --> Makefile.config.$(MOD_NAME)
#
MOD_CONFIG_FILE = $(OUT_DIR_BASE)/Makefile.config.$(MOD_NAME)
MOD_CONFIG_DEF = $(MOD_NAME)_DEP_DEFINED
ifneq ("$(MOD_INC_DIRS)", "")
# Make sure that each directory is an absolute path
MOD_INCS = $(addprefix -I, $(abspath $(subst -I,,$(subst $(TOP_DIR)/,,$(MOD_INC_DIRS)))))
else
MOD_INCS = -I$(SRC_DIR)
ifneq ("$(GEN_HDRS)", "")
MOD_INCS += -I$(CODEGEN_OUTPUT_DIR)
endif
endif
#
# Generate Makefile.config.$(MODULE) capable of re-creating the module
#
moddep: $(GEN_SRCS) $(GEN_HDRS)
ifeq (x"$(V)", x"3")
@echo "!!!!! moddep for MOD_NAME=$(MOD_NAME) MOD_TYPE=$(MOD_TYPE) MOD_CUSTOM=$(MOD_CUSTOM)!!!"
endif
$(SILENT_BUILD)mkdir -p $(OUT_DIR_BASE)
@rm -fr $(MOD_CONFIG_FILE)
@rm -fr $(OBJS:.o=.d)
@echo "ifeq (x\"$$""(V)\", x\"2\")" >> $(MOD_CONFIG_FILE)
@echo " $$""(info !!! MODULE=$$""(MOD_NAME) --> $(MOD_CONFIG_FILE): $(MOD_CONFIG_DEF)=$$""($(MOD_CONFIG_DEF)), DEPS=$(MOD_DEPS))" >> $(MOD_CONFIG_FILE)
@echo "endif" >> $(MOD_CONFIG_FILE)
# Prevent double inclusion
@echo "ifneq (\"$$""($(MOD_CONFIG_DEF))\", \"y\")" >> $(MOD_CONFIG_FILE)
@echo "" >> $(MOD_CONFIG_FILE)
@echo "$(MOD_CONFIG_DEF) := y" >> $(MOD_CONFIG_FILE)
@echo "export $(MOD_NAME)_DIR := $(SRC_DIR)" >> $(MOD_CONFIG_FILE)
@echo "export $(MOD_NAME)_OUT_DIR := $(OUT_DIR)" >> $(MOD_CONFIG_FILE)
ifeq ("$(MODULE_IS_A_LIBRARY)", "y")
@echo "_skip_it := y" >> $(MOD_CONFIG_FILE)
else
@echo "_skip_it := n" >> $(MOD_CONFIG_FILE)
endif
@echo "ifneq (\"$$""(SKIP_LIB_MODULES)\", \"y\")" >> $(MOD_CONFIG_FILE)
@echo " _skip_it := n" >> $(MOD_CONFIG_FILE)
@echo "endif" >> $(MOD_CONFIG_FILE)
@echo "ifneq (\"$$""(_skip_it)\", \"y\")" >> $(MOD_CONFIG_FILE)
ifeq ("$(MODULE_IS_A_LIBRARY)", "y")
ifneq ("$(OBJS)", "")
@echo "EXTRA_LIBS += $(LIBS_MARKER)$(TARGET_LIB)" >> $(MOD_CONFIG_FILE)
@echo "EXTRA_LIBS_PATH += $(LIBS_PATH_MARKER)$(OUT_DIR)" >> $(MOD_CONFIG_FILE)
endif
ifneq ("$(MOD_LIBS)", "")
@echo "EXTRA_LIBS += $(MOD_LIBS)" >> $(MOD_CONFIG_FILE)
endif
ifneq ("$(MOD_LIBS_NOREC_BEFORE)", "")
@echo "EXTRA_LIBS_NOREC_BEFORE += $(MOD_LIBS_NOREC_BEFORE)" >> $(MOD_CONFIG_FILE)
endif
ifneq ("$(MOD_LIBS_NOREC_AFTER)", "")
@echo "EXTRA_LIBS_NOREC_AFTER += $(MOD_LIBS_NOREC_AFTER)" >> $(MOD_CONFIG_FILE)
endif
@echo "ifneq (x\"$$""(MOD_NAME)\", x\"$(MOD_NAME)\")" >> $(MOD_CONFIG_FILE)
@echo " MOD_DEPS_FILES += $(OUT_DIR_BASE)/.$(MOD_NAME)" >> $(MOD_CONFIG_FILE)
@echo "endif" >> $(MOD_CONFIG_FILE)
endif
ifeq ("$(MOD_TYPE)", "linux_lib")
ifneq ("$(OBJS)", "")
@echo "ALL_LIB_OBJS += $(LINUX_LIB_OBJECTS)" >> $(MOD_CONFIG_FILE)
endif
@echo "ifneq (x\"$$""(MOD_NAME)\", x\"$(MOD_NAME)\")" >> $(MOD_CONFIG_FILE)
@echo " MOD_DEPS_FILES += $(OUT_DIR_BASE)/.$(MOD_NAME)" >> $(MOD_CONFIG_FILE)
@echo "endif" >> $(MOD_CONFIG_FILE)
endif
ifeq ("$(MOD_TYPE)", "linux_module")
@echo "ifneq (x\"$$""(MOD_NAME)\", x\"$(MOD_NAME)\")" >> $(MOD_CONFIG_FILE)
@echo " KBUILD_EXTRA_SYMBOLS += $(SRC_DIR)/Module.symvers" >> $(MOD_CONFIG_FILE)
@echo " MOD_DEPS_FILES += $(OUT_DIR_BASE)/.$(MOD_NAME)" >> $(MOD_CONFIG_FILE)
@echo "endif" >> $(MOD_CONFIG_FILE)
endif
# Module creation rules
@echo "$(MOD_NAME)_$(SUBSYSTEM): $(OUT_DIR_BASE)/.$(MOD_NAME)" >> $(MOD_CONFIG_FILE)
@echo "" >> $(MOD_CONFIG_FILE)
@echo "$(OUT_DIR_BASE)/.$(MOD_NAME): .FORCE" >> $(MOD_CONFIG_FILE)
ifeq ("$(MOD_CUSTOM)", "y")
@echo " $$""(MAKE) MOD_DIR=$(MOD_DIR) -f $(MAKE_DIR)/Makefile.template $(MOD_TARGET)" >> $(MOD_CONFIG_FILE)
else
ifneq ("$(OBJS)", "")
@echo " $$""(MAKE) MOD_DIR=$(MOD_DIR) -f $(MAKE_DIR)/Makefile.template $(MOD_TARGET)" >> $(MOD_CONFIG_FILE)
endif
ifeq ("$(OBJS)", "")
@echo " if [ ! -f $(OUT_DIR_BASE)/.$(MOD_NAME) ]; then touch $(OUT_DIR_BASE)/.$(MOD_NAME); fi" >> $(MOD_CONFIG_FILE)
endif
endif
@echo "" >> $(MOD_CONFIG_FILE)
@echo ".FORCE:" >> $(MOD_CONFIG_FILE)
@echo "" >> $(MOD_CONFIG_FILE)
ifneq ("$(MOD_DEFS)", "")
@echo "EXTRA_CFLAGS += $(MOD_DEFS)" >> $(MOD_CONFIG_FILE)
endif
@echo "endif" >> $(MOD_CONFIG_FILE)
# If it is a library and this file is included as someone's dependency - extend MOD_DEP_FULL_NAMES
# and generate a rule to rebuilt the library
ifneq ("$(MOD_DEPS)$(MOD_DEPS_OPT)", "")
@echo "ifeq (x\"$$""(V)\", x\"2\")" >> $(MOD_CONFIG_FILE)
@echo " $$""(info !!! Now include dependencies $(MOD_DEPS) $(MOD_DEPS_OPT)" >> $(MOD_CONFIG_FILE)
@echo "endif" >> $(MOD_CONFIG_FILE)
ifneq ("$(MOD_DEPS)", "")
@echo "$(MOD_NAME)_MOD_DEPS = $(MOD_DEPS)" >> $(MOD_CONFIG_FILE)
@echo "ifneq (x\"$$""(SKIP_DEPS)\", x\"yes\")" >> $(MOD_CONFIG_FILE)
@echo "include $$""($(MOD_NAME)_MOD_DEPS:%=$(OUT_DIR_BASE)/Makefile.config.%)" >> $(MOD_CONFIG_FILE)
@echo "endif" >> $(MOD_CONFIG_FILE)
endif
ifneq ("$(MOD_DEPS_OPT)", "")
@echo "$(MOD_NAME)_MOD_DEPS_OPT = $(MOD_DEPS_OPT)" >> $(MOD_CONFIG_FILE)
@echo "ifneq (x\"$$""(SKIP_DEPS)\", x\"yes\")" >> $(MOD_CONFIG_FILE)
@echo "-include $$""($(MOD_NAME)_MOD_DEPS_OPT:%=$(OUT_DIR_BASE)/Makefile.config.%)" >> $(MOD_CONFIG_FILE)
@echo "endif" >> $(MOD_CONFIG_FILE)
endif
@echo "ifeq (x\"$$""(V)\", x\"2\")" >> $(MOD_CONFIG_FILE)
@echo " $$""(info !!! $(MOD_NAME) finished including dependencies)" >> $(MOD_CONFIG_FILE)
@echo "endif" >> $(MOD_CONFIG_FILE)
endif
@echo "EXTRA_CFLAGS += $(MOD_INCS)" >> $(MOD_CONFIG_FILE)
@echo "" >> $(MOD_CONFIG_FILE)
@echo "endif" >> $(MOD_CONFIG_FILE)
#
# end of moddep: target
#
clean_module::
ifeq ("$(MOD_TYPE)", "linux_module")
$(SILENT_BUILD)-test -f $(SRC_DIR)/Makefile && $(MAKE) $(KERNEL_MAKEPARMS) clean
$(SILENT_BUILD)cd $(SRC_DIR) && rm -fr $($(MOD_NAME)-objs) $($(MOD_NAME)-objs:../%=../.%.cmd)
$(SILENT_BUILD)rm -fr $(OUT_DIR_BASE)/linux_modules/$(MOD_NAME).ko
endif
ifeq ("$(MOD_TYPE)", "linux_lib")
$(SILENT_BUILD)rm -fr $(LINUX_LIB_OBJECTS)
endif
$(SILENT_BUILD)cd $(SRC_DIR) && rm -fr $(patsubst %.c,.%.o.cmd,$(srcs))
$(SILENT_BUILD)[ ! -d $(OUT_DIR) ] || find $(OUT_DIR) -name '*.[o,d,a]' -print0 | xargs -0 rm -rf
$(SILENT_BUILD)[ ! -d $(OUT_DIR) ] || find $(OUT_DIR) -name '*~' -print0 | xargs -0 rm -rf
$(SILENT_BUILD)[ ! -d $(OUT_DIR) ] || find $(OUT_DIR) -name '*.ko' -print0 | xargs -0 rm -rf
$(SILENT_BUILD)[ ! -d $(OUT_DIR) ] || find $(OUT_DIR) -name '.*.cmd' -print0 | xargs -0 rm -rf
$(SILENT_BUILD)rm -fr $(SRC_DIR)/*.mod.c $(SRC_DIR)/modules.order $(SRC_DIR)/Module.symvers $(SRC_DIR)/.tmp_versions
$(SILENT_BUILD)rm -fr $(MOD_TARGET) $(OUT_DIR)/$(TARGET) $(OUT_DIR)/unitest $(TARGET_LIB_FNAME)
$(SILENT_BUILD)rm -fr $(ALL_LIB_OBJS)
$(SILENT_BUILD)rm -fr $(GEN_SRCS) $(GEN_HDRS) $(OUT_DIR)/.$(MOD_NAME)_generated_*
ifneq ("$(MOD_NAME)", "")
$(SILENT_BUILD)rm -fr $(OUT_DIR_BASE)/.$(MOD_NAME)
$(SILENT_BUILD)rm -fr $(SRC_DIR)/.$(MOD_NAME)_in_progress
endif
clobber: clean_module
$(SILENT_BUILD)rm -fr $(OUT_DIR)
# Optional subsystem-specific rules
-include mk/$(SUBSYSTEM)/Makefile.$(SUBSYSTEM).rules
# Generate board-specific environment if any
board_env: $(BOARD_ENV_RULE)
module_name:
$(info $(MOD_NAME))