Prepare for portable build process
This commit is contained in:
50
Makefile
50
Makefile
@ -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
25
src/arch/8051/arch.mk
Normal 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 $<
|
1
src/board/galp3-c/board.mk
Normal file
1
src/board/galp3-c/board.mk
Normal file
@ -0,0 +1 @@
|
|||||||
|
EC=it8587e
|
1
src/ec/it8587e/ec.mk
Normal file
1
src/ec/it8587e/ec.mk
Normal file
@ -0,0 +1 @@
|
|||||||
|
ARCH=8051
|
Reference in New Issue
Block a user