FW_DIRS = $(wildcard fw_*) COMMON_DIRS = lib PROJECT_DEFAULT = atlys PROJECT_NAME ?= $(PROJECT_DEFAULT) PROJECT_DIR = fw_$(PROJECT_NAME) DIRS = $(COMMON_DIRS) $(PROJECT_DIR) ##### PRINT ################################### PW=\033[1m\033[0m GR=\E[40;32m WH=\E[40;37m B=\033[1m pr_info = "$(B) $(GR)[$(1)]\t $(WH)$(2)$(PW)" ##### BUILD RULES ############################# .PHONY: help build clean build_all distclean help: @echo -e "$$ make PROJECT_NAME= " @echo -e "\tprojects (*=default) .. : $(shell echo $(FW_DIRS) | sed 's/fw_//g' | sed 's/$(PROJECT_DEFAULT)/\*$(PROJECT_DEFAULT)/')" @echo -e "\trule .................. : help build clean build_all distclean" build: $(DIRS) @$(foreach dir,$^, echo -e $(call pr_info,MK,Building $(dir)); $(MAKE) -C $(dir) || exit 1;) clean: $(DIRS) @$(foreach dir,$^, echo -e $(call pr_info,MK,Cleaning $(dir)); $(MAKE) -C $(dir) clean || exit 1;) build_all: $(COMMON_DIRS) $(FW_DIRS) @$(foreach dir,$^, echo -e $(call pr_info,MK,Building $(dir)); $(MAKE) -C $(dir) || exit 1;) distclean: $(COMMON_DIRS) $(FW_DIRS) @$(foreach dir,$^, echo -e $(call pr_info,MK,Cleaning $(dir)); $(MAKE) -C $(dir) clean || exit 1;)