fx2/firmware/Makefile

38 lines
1.3 KiB
Makefile

PROJECT_DEFAULT = atlys
PROJECT_NAME ?= $(PROJECT_DEFAULT)
PROJECT_DIR = fw_$(PROJECT_NAME)
FW_DIRS = $(wildcard fw_*)
COMMON_DIRS = lib
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)"
MAKE = $(if $(V),make, make -s)
TARGETS = help build clean build_all distclean
##### BUILD RULES #############################
.SILENT: help $(if $(V),,$(TARGETS))
.PHONY: $(TARGETS)
help:
echo -e "$$ make PROJECT_NAME=<top-file> <rule> [V=1]"
echo -e "\tprojects (*=default) .. : $(subst $(PROJECT_DEFAULT),*$(PROJECT_DEFAULT),$(subst fw_,,$(FW_DIRS)))"
echo -e "\trule .................. : $(TARGETS)"
echo -e "\tV ..................... : verbose"
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;)