Default to silent builds, only outputting the file being generated. This gives output similar to Linux/coreboot output when building. `VERBOSE=1` can be passed to show the actual commands. Signed-off-by: Tim Crawford <tcrawford@system76.com>
75 lines
2.0 KiB
Makefile
75 lines
2.0 KiB
Makefile
# SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
-include config.mk
|
|
|
|
# Disable built-in rules and variables
|
|
MAKEFLAGS += -rR
|
|
|
|
# Default to silent builds
|
|
ifneq ($(VERBOSE),1)
|
|
MAKEFLAGS += -s
|
|
endif
|
|
|
|
# Parameter for current board
|
|
ifeq ($(BOARD),)
|
|
all:
|
|
@echo "Please set BOARD to one of the following:"
|
|
@cd src/board && for board in */*/board.mk; do \
|
|
echo " $$(dirname "$$board")"; \
|
|
done
|
|
@exit 1
|
|
else
|
|
# Calculate version
|
|
DATE=$(shell git show --format="%cd" --date="format:%Y-%m-%d" --no-patch)
|
|
REV=$(shell git describe --abbrev=7 --always --dirty)
|
|
VERSION?=$(DATE)_$(REV)
|
|
|
|
# Set build directory
|
|
obj = build
|
|
BUILD = $(obj)/$(BOARD)/$(VERSION)
|
|
|
|
# Default target - build the board's EC firmware
|
|
all: $(BUILD)/ec.rom
|
|
$(info Built $(VERSION) for $(BOARD))
|
|
|
|
# Include common source
|
|
COMMON_DIR=src/common
|
|
INCLUDE += $(COMMON_DIR)/common.mk
|
|
CFLAGS=-I$(COMMON_DIR)/include -D__FIRMWARE_VERSION__=$(VERSION)
|
|
include $(COMMON_DIR)/common.mk
|
|
SRC += $(foreach src, $(common-y), $(COMMON_DIR)/$(src))
|
|
|
|
# Include the board's source
|
|
BOARD_DIR=src/board/$(BOARD)
|
|
INCLUDE += $(BOARD_DIR)/board.mk
|
|
CFLAGS+=-I$(BOARD_DIR)/include -D__BOARD__=$(BOARD)
|
|
include $(BOARD_DIR)/board.mk
|
|
SRC += $(foreach src, $(board-y), $(BOARD_DIR)/$(src))
|
|
SRC += $(foreach src, $(board-common-y), $(SYSTEM76_COMMON_DIR)/$(src))
|
|
SRC += $(foreach src, $(keyboard-y), $(KEYBOARD_DIR)/$(src))
|
|
|
|
# The board will define the embedded controller
|
|
# Include the embedded controller's source
|
|
EC_DIR=src/ec/$(EC)
|
|
INCLUDE += $(EC_DIR)/ec.mk
|
|
CFLAGS+=-I$(EC_DIR)/include
|
|
include $(EC_DIR)/ec.mk
|
|
SRC += $(foreach src, $(ec-y), $(EC_DIR)/$(src))
|
|
|
|
# The EC will define the architecture
|
|
# Include the architecture's source
|
|
ARCH_DIR=src/arch/$(ARCH)
|
|
INCLUDE += $(ARCH_DIR)/arch.mk
|
|
CFLAGS+=-I$(ARCH_DIR)/include -D__ARCH__=$(ARCH)
|
|
include $(ARCH_DIR)/arch.mk
|
|
SRC += $(foreach src, $(arch-y), $(ARCH_DIR)/$(src))
|
|
|
|
include $(ARCH_DIR)/toolchain.mk
|
|
|
|
# The architecture defines build targets, no more is required
|
|
endif
|
|
|
|
# Target to remove build artifacts
|
|
clean:
|
|
rm -rf $(obj)
|