Files

101 lines
2.7 KiB
Makefile
Raw Permalink Normal View History

2020-09-17 06:47:11 -06:00
# SPDX-License-Identifier: GPL-3.0-only
-include config.mk
2023-01-13 13:11:23 -07:00
# Disable built-in rules and variables
MAKEFLAGS += -rR
2023-01-13 13:23:53 -07:00
# Default to silent builds
ifneq ($(VERBOSE),1)
MAKEFLAGS += -s
endif
2019-09-29 16:45:12 -06:00
# Parameter for current board
2020-02-06 13:06:13 -07:00
ifeq ($(BOARD),)
all:
2023-01-09 10:38:48 -07:00
@echo -e "\x1B[31mBOARD must be specified\x1B[0m"
@exit 1
else
2020-02-16 12:24:02 -07:00
# Calculate version
DATE=$(shell git show --format="%cd" --date="format:%Y-%m-%d" --no-patch --no-show-signature)
REV=$(shell git rev-parse --short HEAD)
2020-04-06 14:59:41 -06:00
VERSION?=$(DATE)_$(REV)
2020-02-16 12:24:02 -07:00
2019-09-29 16:45:12 -06:00
# Set build directory
2023-01-13 13:23:53 -07:00
obj = build
BUILD = $(obj)/$(BOARD)/$(VERSION)
2019-09-27 17:02:51 -06:00
2019-09-29 16:45:12 -06:00
# Default target - build the board's EC firmware
all: $(BUILD)/ec.rom
2023-01-13 13:23:53 -07:00
$(info Built $(VERSION) for $(BOARD))
2019-09-29 16:45:12 -06:00
# Include common source
COMMON_DIR=src/common
2023-01-11 12:28:13 -07:00
INCLUDE += $(COMMON_DIR)/common.mk
2020-02-18 15:35:41 -07:00
CFLAGS=-I$(COMMON_DIR)/include -D__FIRMWARE_VERSION__=$(VERSION)
include $(COMMON_DIR)/common.mk
2022-10-14 08:48:11 -06:00
SRC += $(foreach src, $(common-y), $(COMMON_DIR)/$(src))
2019-09-27 17:33:06 -06:00
2019-09-29 16:45:12 -06:00
# Include the board's source
BOARD_DIR=src/board/$(BOARD)
2023-01-11 12:28:13 -07:00
INCLUDE += $(BOARD_DIR)/board.mk
CFLAGS+=-I$(BOARD_DIR)/include -D__BOARD__=$(BOARD)
2019-09-29 16:45:12 -06:00
include $(BOARD_DIR)/board.mk
2022-10-14 08:48:11 -06:00
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))
2019-09-27 17:02:51 -06:00
2019-09-29 16:45:12 -06:00
# The board will define the embedded controller
# Include the embedded controller's source
EC_DIR=src/ec/$(EC)
2023-01-11 12:28:13 -07:00
INCLUDE += $(EC_DIR)/ec.mk
2022-10-17 10:12:06 -06:00
CFLAGS+=-I$(EC_DIR)/include
2019-09-29 16:45:12 -06:00
include $(EC_DIR)/ec.mk
2022-10-14 08:48:11 -06:00
SRC += $(foreach src, $(ec-y), $(EC_DIR)/$(src))
2019-09-27 17:02:51 -06:00
2019-09-29 16:45:12 -06:00
# The EC will define the architecture
# Include the architecture's source
ARCH_DIR=src/arch/$(ARCH)
2023-01-11 12:28:13 -07:00
INCLUDE += $(ARCH_DIR)/arch.mk
CFLAGS+=-I$(ARCH_DIR)/include -D__ARCH__=$(ARCH)
2019-09-29 16:45:12 -06:00
include $(ARCH_DIR)/arch.mk
2022-10-14 08:48:11 -06:00
SRC += $(foreach src, $(arch-y), $(ARCH_DIR)/$(src))
2019-09-29 16:45:12 -06:00
2022-10-14 08:14:54 -06:00
include $(ARCH_DIR)/toolchain.mk
2019-09-29 16:45:12 -06:00
# The architecture defines build targets, no more is required
endif
2023-01-09 10:38:48 -07:00
.PHONY: clean
clean:
2023-01-13 13:23:53 -07:00
rm -rf $(obj)
2023-01-09 10:38:48 -07:00
2023-01-09 10:38:48 -07:00
.PHONY: fmt
fmt:
./scripts/clang-format.sh apply
2023-01-09 10:38:48 -07:00
.PHONY: lint
lint:
./scripts/lint/lint.sh
2023-01-09 10:38:48 -07:00
2023-01-09 10:38:48 -07:00
.PHONY: list-boards
list-boards:
@cd src/board && for board in */*/board.mk; do \
echo "$$(dirname "$$board")"; \
done
# This target is run during setup, and is not shown in the help text.
2023-01-09 10:38:48 -07:00
.PHONY: git-config
git-config:
$(eval HOOKS = "$(shell git rev-parse --git-dir)/hooks")
ln -sfrv scripts/hooks/pre-commit.sh "$(HOOKS)/pre-commit"
2023-01-09 10:38:48 -07:00
.PHONY: help
help:
@echo "System76 EC build targets"
@echo " [all] BOARD=<B> Build the specified board"
@echo " list-boards List available target boards"
@echo " clean Remove build artifacts"
@echo " fmt Format the source code"
@echo " lint Run lint checks"
@echo " help Print this message"