Prepare for portable build process

This commit is contained in:
Jeremy Soller
2019-09-29 16:45:12 -06:00
parent af0a5f623f
commit 608326af30
4 changed files with 57 additions and 20 deletions

View File

@ -1,28 +1,38 @@
SRC=$(wildcard src/*.c) # Parameter for current board
INCLUDE=$(wildcard src/include/*.h) BOARD?=galp3-c
OBJ=$(patsubst src/%.c,build/%.rel,$(SRC))
all: build/ec.rom # Set build directory
BUILD=build/$(BOARD)
# Default target - build the board's EC firmware
all: $(BUILD)/ec.rom
# Target to remove build artifacts
clean: clean:
rm -rf build rm -rf build
sim: build/ec.rom # Include common source
cargo run \ SRC=$(wildcard src/*.c)
--release \ INCLUDE=$(wildcard src/include/*.h)
--manifest-path ecsim/Cargo.toml \
--no-default-features \
-- $<
build/ec.rom: build/ec.ihx # Include the board's source
mkdir -p build BOARD_DIR=src/board/$(BOARD)
makebin -p < $< > $@ SRC+=$(wildcard $(BOARD_DIR)/*.c)
INCLUDE+=$(wildcard $(BOARD_DIR)/include/*.h)
include $(BOARD_DIR)/board.mk
build/ec.ihx: $(OBJ) # The board will define the embedded controller
mkdir -p build # Include the embedded controller's source
sdcc -mmcs51 -o $@ $^ EC_DIR=src/ec/$(EC)
SRC+=$(wildcard $(EC_DIR)/*.c)
INCLUDE+=$(wildcard $(EC_DIR)/include/*.h)
include $(EC_DIR)/ec.mk
build/%.rel: src/%.c $(INCLUDE) # The EC will define the architecture
mkdir -p build # Include the architecture's source
cd build && \ ARCH_DIR=src/arch/$(ARCH)
sdcc -mmcs51 -c ../$< SRC+=$(wildcard $(ARCH_DIR)/*.c)
INCLUDE+=$(wildcard $(ARCH_DIR)/include/*.h)
include $(ARCH_DIR)/arch.mk
# The architecture defines build targets, no more is required

25
src/arch/8051/arch.mk Normal file
View File

@ -0,0 +1,25 @@
CC=sdcc -mmcs51
OBJ=$(patsubst src/%.c,$(BUILD)/%.rel,$(SRC))
# Run EC rom in simulator
sim: $(BUILD)/ec.rom
cargo run \
--release \
--manifest-path ecsim/Cargo.toml \
--no-default-features \
-- $<
# Convert from Intel Hex format to binary
$(BUILD)/ec.rom: $(BUILD)/ec.ihx
@mkdir -p $(@D)
makebin -p < $< > $@
# Link object files into Intel Hex format
$(BUILD)/ec.ihx: $(OBJ)
@mkdir -p $(@D)
$(CC) -o $@ $^
# Compile C files into object files
$(BUILD)/%.rel: src/%.c $(INCLUDE)
@mkdir -p $(@D)
$(CC) -o $@ -c $<

View File

@ -0,0 +1 @@
EC=it8587e

1
src/ec/it8587e/ec.mk Normal file
View File

@ -0,0 +1 @@
ARCH=8051