| # Main Makefile body |
| # It is included in the central Makefile twice - for host and embedded subsystems |
| # PARAMATER: SUBSYSTEM |
| |
| UC_SUBSYSTEM = $(shell echo $(SUBSYSTEM) | tr a-z A-Z) |
| |
| $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_$(BOARD): $(MAKE_DEVICE_DIR)/modules.$(SUBSYSTEM) \ |
| $(MAKE_DIR)/Makefile.config $(MAKE_DIR)/Makefile.rules $(MAKE_DIR)/Makefile.template $(MAKE_DIR)/Makefile.main |
| @if ! test -f $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_$(BOARD); then\ |
| if ls $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_* 2>/dev/null >/dev/null; then\ |
| olddeps=`ls $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_*` ; \ |
| old_board=`echo $$olddeps | sed 's@$(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_@@'` ; \ |
| $(BOLD_PRINT) "Previous build was for different board $$old_board. cleaning up..";\ |
| $(MAKE) -s BOARD=$$old_board V=0 clean_$(SUBSYSTEM); \ |
| fi;\ |
| fi |
| @$(BOLD_PRINT) "Generating list of $(SUBSYSTEM) modules for $(PLATFORM)" |
| @rm -fr $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_* |
| @rm -fr $(OUT_$(UC_SUBSYSTEM)_DIR)/all_modules.$(SUBSYSTEM) |
| @rm -fr $(OUT_$(UC_SUBSYSTEM)_DIR)/all_lib_modules.$(SUBSYSTEM) |
| @rm -fr $(OUT_$(UC_SUBSYSTEM)_DIR)/all_app_modules.$(SUBSYSTEM) |
| @mkdir -p $(OUT_$(UC_SUBSYSTEM)_DIR) |
| @touch $(OUT_$(UC_SUBSYSTEM)_DIR)/all_modules.$(SUBSYSTEM) |
| @touch $(OUT_$(UC_SUBSYSTEM)_DIR)/all_lib_modules.$(SUBSYSTEM) |
| @touch $(OUT_$(UC_SUBSYSTEM)_DIR)/all_app_modules.$(SUBSYSTEM) |
| @for mod_dir in `awk '{print $$1}' $(MAKE_DEVICE_DIR)/modules.$(SUBSYSTEM)`; do\ |
| if test "$$mod_dir" = "" ; then continue; fi; \ |
| mod_name=`$(MAKE) -s V=0 SUBSYSTEM=$(SUBSYSTEM) MOD_DIR=$$mod_dir SKIP_DEPS=yes -f $(MAKE_DIR)/Makefile.template module_name`;\ |
| if test "$$mod_name" = "" ; then continue; fi; \ |
| mod_name=$${mod_name}_$(SUBSYSTEM);\ |
| mod_type=`grep -e '^[[:space:]]*MOD_TYPE[[:space:]]*=' $$mod_dir/Makefile | awk -F= '{sub(/\r/,""); print $$2}' | sed -e 's/^[ \t]*//'`; \ |
| echo -n "$$mod_name " >> $(OUT_$(UC_SUBSYSTEM)_DIR)/all_modules.$(SUBSYSTEM); \ |
| if test "`echo -n $$mod_type | sed -e 's/linux_lib lib/lib/' | sed -e 's/lib linux_lib/lib/'`" = "lib" ; then\ |
| echo -n "$$mod_name " >> $(OUT_$(UC_SUBSYSTEM)_DIR)/all_lib_modules.$(SUBSYSTEM); \ |
| fi;\ |
| if test "$$mod_type" = "app" ; then\ |
| echo -n "$$mod_name " >> $(OUT_$(UC_SUBSYSTEM)_DIR)/all_app_modules.$(SUBSYSTEM); \ |
| fi;\ |
| done |
| @touch $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_$(BOARD) |
| |
| $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_$(BOARD): $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_$(BOARD) |
| @$(BOLD_PRINT) "Building $(BOARD) board environment for $(PLATFORM)" |
| $(MAKE) SUBSYSTEM=$(SUBSYSTEM) MOD_DIR=$$mod_dir OUT_DIR_BASE=$(OUT_$(UC_SUBSYSTEM)_DIR) SKIP_DEPS=yes \ |
| ALL_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_modules.$(SUBSYSTEM)`" \ |
| ALL_LIB_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_lib_modules.$(SUBSYSTEM)`" \ |
| ALL_APP_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_app_modules.$(SUBSYSTEM)`" \ |
| -f $(MAKE_DIR)/Makefile.template board_env |
| @$(BOLD_PRINT) "Generating $(SUBSYSTEM) dependencies for $(PLATFORM)" |
| @for mod_dir in `awk '{print $$1}' $(MAKE_DEVICE_DIR)/modules.$(SUBSYSTEM)`; do\ |
| if test "$$mod_dir" = "" ; then continue; fi; \ |
| mod_name=`$(MAKE) -s V=0 SUBSYSTEM=$(SUBSYSTEM) MOD_DIR=$$mod_dir SKIP_DEPS=yes -f $(MAKE_DIR)/Makefile.template module_name`;\ |
| if test "$$mod_name" = "" ; then continue; fi; \ |
| if ! $(MAKE) $(SILENT) SUBSYSTEM=$(SUBSYSTEM) MOD_DIR=$$mod_dir OUT_DIR_BASE=$(OUT_$(UC_SUBSYSTEM)_DIR) SKIP_DEPS=yes \ |
| ALL_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_modules.$(SUBSYSTEM)`" \ |
| ALL_LIB_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_lib_modules.$(SUBSYSTEM)`" \ |
| ALL_APP_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_app_modules.$(SUBSYSTEM)`" \ |
| -f $(MAKE_DIR)/Makefile.template moddep; then exit 1;\ |
| fi;\ |
| done |
| @touch $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_$(BOARD) |
| |
| .PHONY: |
| |
| # Make sure that none of module Makefiles changed. |
| # If there is a change - we need to regenerate dependencies |
| _deps_$(SUBSYSTEM)_: $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_$(BOARD) .PHONY |
| @cat $(MAKE_DEVICE_DIR)/modules.$(SUBSYSTEM) | while read -r mod_dir_targ; do\ |
| mod_dir=`echo $$mod_dir_targ | awk '{print $$1}'`;\ |
| if test "$$mod_dir" = "" ; then continue; fi; \ |
| if test $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_$(BOARD) -ot $$mod_dir/Makefile; then\ |
| echo $$mod_dir/Makefile changed, must regenerate dependencies.;\ |
| echo PLEASE RE-RUN make;\ |
| rm -f $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_$(BOARD);\ |
| exit -1;\ |
| fi;\ |
| done |
| |
| build_$(SUBSYSTEM): _deps_$(SUBSYSTEM)_ |
| @$(BOLD_PRINT) "Building $(SUBSYSTEM) image for $(PLATFORM)" |
| @cat $(MAKE_DEVICE_DIR)/modules.$(SUBSYSTEM) | while read -r mod_dir_targ; do\ |
| mod_dir=`echo $$mod_dir_targ | awk '{print $$1}'`;\ |
| if test "$$mod_dir" = "" ; then continue; fi; \ |
| mod_targets=`echo $$mod_dir_targ | awk '{print $$2 $$3 $$4 $$5}'`;\ |
| if ! $(MAKE) $(SILENT) SUBSYSTEM=$(SUBSYSTEM) MOD_DIR=$$mod_dir OUT_DIR_BASE=$(OUT_$(UC_SUBSYSTEM)_DIR) \ |
| ALL_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_modules.$(SUBSYSTEM)`" \ |
| ALL_LIB_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_lib_modules.$(SUBSYSTEM)`" \ |
| ALL_APP_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_app_modules.$(SUBSYSTEM)`" \ |
| -f $(MAKE_DIR)/Makefile.template $$mod_targets; then exit 1;\ |
| fi;\ |
| done |
| @$(BOLD_PRINT) "Finished building $(SUBSYSTEM) image for $(PLATFORM)" |
| |
| clean_$(SUBSYSTEM): BOARD=$(shell ls $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_* 2>/dev/null | sed 's@$(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)_list_@@') |
| |
| clean_$(SUBSYSTEM): |
| @$(BOLD_PRINT) "Clean $(PLATFORM) $(SUBSYSTEM) BOARD=$(BOARD)" |
| @for mod_dir in `awk '{print $$1}' $(MAKE_DEVICE_DIR)/modules.$(SUBSYSTEM)`; do\ |
| if test "$$mod_dir" = "" ; then continue; fi; \ |
| if ! $(MAKE) $(SILENT) SUBSYSTEM=$(SUBSYSTEM) MOD_DIR=$$mod_dir OUT_DIR_BASE=$(OUT_$(UC_SUBSYSTEM)_DIR) SKIP_DEPS=yes \ |
| -f $(MAKE_DIR)/Makefile.template clean_module; then exit 1; fi;\ |
| done |
| $(SILENT_BUILD)rm -f $(OUT_$(UC_SUBSYSTEM)_DIR)/Makefile.config.* |
| $(SILENT_BUILD)rm -f $(OUT_$(UC_SUBSYSTEM)_DIR)/.deps_$(SUBSYSTEM)* |
| $(SILENT_BUILD)rm -f $(OUT_$(UC_SUBSYSTEM)_DIR)/all_*modules.$(SUBSYSTEM) |
| $(SILENT_BUILD)find $(SUBSYSTEM) -name '*~' -print0 2>/dev/null | xargs -0 rm -rf |
| $(SILENT_BUILD)find $(SUBSYSTEM) -name '*.ko' -print0 2>/dev/null | xargs -0 rm -rf |
| $(SILENT_BUILD)find $(SUBSYSTEM) -name '.*.cmd' -print0 2>/dev/null | xargs -0 rm -rf |
| $(SILENT_BUILD)find $(SUBSYSTEM) -name '*.o' -print0 2>/dev/null | xargs -0 rm -rf |
| $(SILENT_BUILD)find $(SUBSYSTEM) -name '*.mod.c' -print0 2>/dev/null | xargs -0 rm -rf |
| $(SILENT_BUILD)find $(SUBSYSTEM) -name modules.order -print0 2>/dev/null | xargs -0 rm -rf |
| $(SILENT_BUILD)find $(SUBSYSTEM) -name Module.symvers -print0 2>/dev/null | xargs -0 rm -rf |
| $(SILENT_BUILD)find $(SUBSYSTEM) -name .tmp_versions -print0 2>/dev/null | xargs -0 rm -rf |
| |
| help_$(SUBSYSTEM): |
| @echo "$$PLATFORM $(SUBSYSTEM) modules:" |
| @cat $(MAKE_DEVICE_DIR)/modules.$(SUBSYSTEM) | while read -r mod_dir_targ; do\ |
| mod_dir=`echo $$mod_dir_targ | awk '{print $$1}'`;\ |
| if test "$$mod_dir" = "" ; then continue; fi; \ |
| mod_name=`$(MAKE) -s V=0 SUBSYSTEM=$(SUBSYSTEM) MOD_DIR=$$mod_dir SKIP_DEPS=yes -f $(MAKE_DIR)/Makefile.template module_name`;\ |
| if test "$$mod_name" = "" ; then continue; fi; \ |
| echo " " $${mod_name}_$(SUBSYSTEM);\ |
| done |
| |
| # Targets for building individual $(SUBSYSTEM) module |
| %_$(SUBSYSTEM):: _deps_$(SUBSYSTEM)_ |
| @while read -r mod_dir_targ; do\ |
| mod_dir=`echo $$mod_dir_targ | awk '{print $$1}'`;\ |
| if test "$$mod_dir" = "" ; then continue; fi; \ |
| mod_name=`$(MAKE) -s V=0 SUBSYSTEM=$(SUBSYSTEM) MOD_DIR=$$mod_dir SKIP_DEPS=yes -f $(MAKE_DIR)/Makefile.template module_name`;\ |
| if test "$$mod_name" = "" ; then continue; fi; \ |
| mod_name=$${mod_name}_$(SUBSYSTEM);\ |
| mod_targets=`echo $$mod_dir_targ | awk '{print $$2 $$3 $$4 $$5}'`;\ |
| if test "$$mod_name" = "$@" ; then\ |
| target_found=y;\ |
| $(MAKE) $(SILENT) SUBSYSTEM=$(SUBSYSTEM) MOD_DIR=$$mod_dir OUT_DIR_BASE=$(OUT_$(UC_SUBSYSTEM)_DIR) \ |
| ALL_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_modules.$(SUBSYSTEM)`" \ |
| ALL_LIB_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_lib_modules.$(SUBSYSTEM)`" \ |
| ALL_APP_MODULES="`cat $(OUT_$(UC_SUBSYSTEM)_DIR)/all_app_modules.$(SUBSYSTEM)`" \ |
| -f $(MAKE_DIR)/Makefile.template $$mod_targets || exit 1;\ |
| fi;\ |
| done < $(MAKE_DEVICE_DIR)/modules.$(SUBSYSTEM);\ |
| if test "$$target_found" != "y" ; then\ |
| echo No rule to make target $@;\ |
| exit 1;\ |
| fi |
| |
| docs_$(SUBSYSTEM): _deps_$(SUBSYSTEM)_ |
| mkdir -p $(OUT_DOCS_DIR) |
| sed -e 's@%OUT_DOCS_DIR@$(OUT_DOCS_DIR)@g' -e 's@%MODEL_DIR@$(OUT_$(UC_SUBSYSTEM)_DIR)/common/model/$(PLATFORM)@g' \ |
| -e 's@%API_DIR@$(TOP_DIR)/$(SUBSYSTEM)/api/$(PLATFORM)@g' doc_config/Doxyfile > $(OUT_DOCS_DIR)/Doxyfile |
| doxygen $(OUT_DOCS_DIR)/Doxyfile |
| |