.PHONY: dummy X_INSTALL ?= n #### set "is do install action, =n, do install, =y, don't install first_rule: pre_target sub_dirs all_targets all: pre_target sub_dirs all_targets ## add by yellow ## at ## host_tools ## router/open_source ## router/thirdparty_source ## router/cybertan_source, ## dynamic create symbolink to pkgs/* ## ifdef pkg-y PKGS_LN = $(foreach p,$(pkg-y),$(if $(wildcard pkgs/$(p)),$(p))) pkgs-list += $(patsubst %,_symln_%,$(PKGS_LN)) subdir_ln-y += $(foreach p,$(PKGS_LN),$(notdir $(call get_package_without_version,$(p)))) get_package_without_version = $(shell echo $(1) | sed -e 's,-[vV0-9].*$$,,') $(pkgs-list): dummy if [ -e $(notdir $(call get_package_without_version,$(patsubst _symln_%,%,$@))) ]; then \ /bin/rm -rf $(notdir $(call get_package_without_version,$(patsubst _symln_%,%,$@))); \ fi ln -sf pkgs/$(patsubst _symln_%,%,$@) \ $(notdir $(call get_package_without_version,$(patsubst _symln_%,%,$@))); echo "subdir_ln-y += $(notdir $(call get_package_without_version,$(patsubst _symln_%,%,$@)))" >> pkgs_ln.mk endif # board specific defines # general SUB_DIRS = $(subdir_ln-y) $(subdir-y) CFLAGS += $(CY_CFLAGS) $(cflags-y) LDFLAGS += $(ldflags-y) LDFLAGS_O += $(ldflags_o-y) LDFLAGS_SO += $(ldflags_so-y) LDFLAGS_EXE += $(ldflags_exe-y) #INSTALL_FLAGS += $(install_flags-y) SRCDIR = $(TOPDIR)/src INCLUDE = $(SRCDIR)/include CMLIBDIR = $(SRCDIR)/lib # main directory list subdir-list = $(patsubst %, _subdir_%, $(SUB_DIRS)) subdir-list-install = $(patsubst %, _subdir_install%, $(SUB_DIRS)) subdir-list-clean = $(patsubst %, _subdir_clean%, $(shell for subd in $(SUB_DIRS); do tmp_subd="$${subd} $${tmp_subd}"; done; echo $${tmp_subd} )) sub_dirs: dummy $(subdir-list) ifdef SUB_DIRS get_subdir: echo "$(SUB_DIRS)" $(subdir-list) : dummy if [ -f $(patsubst _subdir_%,%,$@)/Makefile.cyt ]; then \ $(MAKE) -C $(patsubst _subdir_%,%,$@) -f Makefile.cyt; \ else \ $(MAKE) -C $(patsubst _subdir_%,%,$@); \ fi #$(subdir-list-install): pre_install $(subdir-list-install): if [ -e $(FW_IMAGE_DIR) ]; then rm -rf $(FW_IMAGE_DIR); fi install -d $(FW_IMAGE_DIR) if [ -f $(patsubst _subdir_install%,%,$@)/Makefile.cyt ]; then \ $(MAKE) -C $(patsubst _subdir_install%,%,$@) -f Makefile.cyt install; \ else \ $(MAKE) -C $(patsubst _subdir_install%,%,$@) install; \ fi $(subdir-list-clean) : if [ -e $(patsubst _subdir_clean%,%,$@) ]; then \ if [ -f $(patsubst _subdir_clean%,%,$@)/Makefile.cyt ]; then \ $(MAKE) -C $(patsubst _subdir_clean%,%,$@) -f Makefile.cyt \ clean; \ else \ $(MAKE) -C $(patsubst _subdir_clean%,%,$@) clean; \ fi; \ fi pre_install: dummy if [ -n "$(INSTALLDIR)" ]; then \ if [ -e "$(INSTALLDIR)" ]; then /bin/rm -rf $(INSTALLDIR); fi install -d $(INSTALLDIR)/sbin; \ fi #install: install: $(subdir-list-install) endif # dependency directory list dep-subdir-list = $(patsubst %, dep_subdir_%, $(SUB_DIRS)) dep-sub_dirs: dummy $(dep-subdir-list) ifdef SUB_DIRS $(dep-subdir-list) : dummy @ $(MAKE) -C $(patsubst dep_subdir_%,%,$@) dep endif #SRC_FILES=$(shell ls *.c 2> /dev/null) SRC_FILES = $(wildcard *.c) dep-files-list = $(patsubst %, dep_file_%, $(SRC_FILES)) dep-files: emptydep $(dep-files-list) emptydep: @ > .depend ifdef SRC_FILES $(dep-files-list) : dummy @ $(CC) $(CFLAGS) -MM $(patsubst dep_file_%,%,$@) >> .depend endif dep: dep-sub_dirs dep-files # all binary targets all_targets: $(O_TARGET) $(SO_TARGET) $(A_TARGET) $(TARGET) $(EXTRA_TARGET) ifdef O_TARGET #ifdef obj-y $(O_TARGET) : $(obj-y) $(obj_o-y) $(depend_o-y) rm -f $@ $(LD) -r -o $@ $(filter $(obj-y) $(obj_o-y), $^) $(LDFLAGS_O) $(LDFLAGS) #endif endif ifdef TARGET #ifdef obj-y $(TARGET) : $(obj-y) $(obj_exe-y) $(depend_exe-y) rm -f $@ $(CC) -o $@ $(filter $(obj-y) $(obj_exe-y), $^) $(LDFLAGS_EXE) $(LDFLAGS) #endif endif ifdef A_TARGET #ifdef obj-y $(A_TARGET): $(obj-y) $(obj_a-y) $(depend_a-y) rm -f $@ $(AR) rc $@ $(filter $(obj-y) $(obj_a-y), $^) $(RANLIB) $@ #endif endif ifdef SO_TARGET #ifdef obj-y $(SO_TARGET): $(obj-y) $(obj_so-y) $(depend_so-y) rm -f $@ $(CC) -shared -o $@ $(filter $(obj-y) $(obj_so-y), $^) $(LDFLAGS_SO) $(LDFLAGS) #endif endif # clean #clean: $(subdir-list-clean) clean: $(subdir-list-clean) ifdef subdir_ln-y #ifneq ($(wildcard pkgs),) ifneq ($(wildcard $(CY_PROFILE)/pkgs.mk),) @echo "subdir_ln-y: rm -rf $(subdir_ln-y)" /bin/rm -rf $(subdir_ln-y) /bin/rm -rf pkgs_ln.mk endif endif delete_obj: dummy find . \( -name '*.[oas]' -o -name core -o -name '*~' -o -name '.*~' -o -name '.#*' -o -name '*.so' \) -type f -print | xargs rm -f find . \( -name '*.depend' \) -type f -print | xargs rm -f #pre_target: pre_target: $(pkgs-list) echo "PWD = $(PWD)" echo "NOW = $(NOW)" dummy: ifneq ($(wildcard .depend),) include .depend endif %.o: .%.depend .%.depend: %.c $(CC) $(CFLAGS) -M $< > $@ -include $(obj-y:%.o=.%.depend) -include $(obj_o-y:%.o=.%.depend) -include $(obj_exe-y:%.o=.%.depend) -include $(obj_a-y:%.o=.%.depend) -include $(obj_so-y:%.o=.%.depend)