1. Introduce a “project lock” mechanism alongside the existing “build lock”; the lock file is now generated within the platform-specific Makefile. 2. Set `project` as the default Makefile goal for consistency. 3. Remove the `standalone` target to improve compatibility, especially when invoked via `make -f`. 4. Simplify target dependencies for better maintainability and clarity.
85 lines
2.3 KiB
Makefile
85 lines
2.3 KiB
Makefile
ifeq ($(VERBOSE),y)
|
|
else
|
|
HIDE = > /dev/zero
|
|
.SILENT:
|
|
endif
|
|
|
|
TIMESTAMP = $(shell date +"%T")
|
|
cmd_copy = cp -a $(1) $(2)
|
|
cmd_link = ln -sfr $(1) $(2)
|
|
cmd_remove = rm -rf $(1)
|
|
cmd_mkdir = mkdir -p $(1)
|
|
cmd_cat = cat $(1) 2>/dev/null
|
|
cmd_print_lines = echo $(1) | tr ' ' '\n'
|
|
|
|
color_green = \033[32m$(1)\033[0m
|
|
log = @printf "$(call color_green,[$(TIMESTAMP)]) %s\n" "$(1)"
|
|
show_build_type = $(call log,Building for $(call green,$(1)))
|
|
|
|
check-var = $(if $(strip $($(1))),,$(error [ERROR] Missing required variable: $(1)))
|
|
check_command = $(shell which $(1) > /dev/null 2>&1 && echo y || echo n)
|
|
|
|
$(call check-var,PROJECT)
|
|
$(call check-var,PLATFORM)
|
|
$(call check-var,BUILD_DIR)
|
|
$(call check-var,CONFIG_FILE)
|
|
$(call check-var,LINK_SRCS)
|
|
|
|
ifndef SCRIPT_DIR
|
|
CURRENT_FILE := $(lastword $(MAKEFILE_LIST))
|
|
CURRENT_DIR := $(patsubst %/,%,$(dir $(CURRENT_FILE)))
|
|
SCRIPT_DIR := $(CURRENT_DIR)
|
|
endif
|
|
|
|
ifeq ($(strip $(LINK_SRCS)),y)
|
|
update_files = $(call cmd_link,$(1),$(2))
|
|
update_dir = $(call cmd_link,$(1),$(2))
|
|
ACTION = Linking
|
|
else
|
|
update_files = $(call cmd_copy,$(1),$(dir $(2)))
|
|
update_dir = $(call cmd_copy,$(1),$(2))
|
|
ACTION = Copying
|
|
endif
|
|
|
|
#------------------------------------------------------------------------------
|
|
# COMMON INITIALIZATION
|
|
#------------------------------------------------------------------------------
|
|
PLATFORM_TOOLS = $(SCRIPT_DIR)/platform/$(PLATFORM)
|
|
BUILD_LOCK = $(BUILD_DIR)/.build.lock
|
|
PROJECT_LOCK = $(BUILD_DIR)/.project.lock
|
|
|
|
ifeq ('xilinx', '$(PLATFORM)')
|
|
include $(PLATFORM_TOOLS)/xilinx.mk
|
|
endif
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
# Generic Goals
|
|
#------------------------------------------------------------------------------
|
|
|
|
PHONY := clean reset project build sdkopen
|
|
.DEFAULT_GOAL := project
|
|
|
|
# Create project using corresponding SDK
|
|
project: $(PLATFORM)_project
|
|
|
|
# Build project using corresponding compiler
|
|
build: project $(PLATFORM)_sdkbuild
|
|
|
|
# Open the project using the corresponding SDK
|
|
sdkopen: project $(PLATFORM)_sdkopen
|
|
|
|
# Remove build artefacts
|
|
ifneq ($(wildcard $(BUILD_LOCK)),)
|
|
clean: $(PLATFORM)_sdkclean
|
|
else
|
|
clean: reset
|
|
endif
|
|
|
|
# Remove the whole build directory
|
|
reset: $(PLATFORM)_reset
|
|
@$(call log,[Delete] $(BUILD_DIR))
|
|
@$(call cmd_remove,$(BUILD_DIR))
|
|
|
|
.PHONY: $(PHONY)
|