Prepare for portable build process
This commit is contained in:
50
Makefile
50
Makefile
@ -1,28 +1,38 @@
|
||||
SRC=$(wildcard src/*.c)
|
||||
INCLUDE=$(wildcard src/include/*.h)
|
||||
OBJ=$(patsubst src/%.c,build/%.rel,$(SRC))
|
||||
# Parameter for current board
|
||||
BOARD?=galp3-c
|
||||
|
||||
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:
|
||||
rm -rf build
|
||||
|
||||
sim: build/ec.rom
|
||||
cargo run \
|
||||
--release \
|
||||
--manifest-path ecsim/Cargo.toml \
|
||||
--no-default-features \
|
||||
-- $<
|
||||
# Include common source
|
||||
SRC=$(wildcard src/*.c)
|
||||
INCLUDE=$(wildcard src/include/*.h)
|
||||
|
||||
build/ec.rom: build/ec.ihx
|
||||
mkdir -p build
|
||||
makebin -p < $< > $@
|
||||
# Include the board's source
|
||||
BOARD_DIR=src/board/$(BOARD)
|
||||
SRC+=$(wildcard $(BOARD_DIR)/*.c)
|
||||
INCLUDE+=$(wildcard $(BOARD_DIR)/include/*.h)
|
||||
include $(BOARD_DIR)/board.mk
|
||||
|
||||
build/ec.ihx: $(OBJ)
|
||||
mkdir -p build
|
||||
sdcc -mmcs51 -o $@ $^
|
||||
# The board will define the embedded controller
|
||||
# Include the embedded controller's source
|
||||
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)
|
||||
mkdir -p build
|
||||
cd build && \
|
||||
sdcc -mmcs51 -c ../$<
|
||||
# The EC will define the architecture
|
||||
# Include the architecture's source
|
||||
ARCH_DIR=src/arch/$(ARCH)
|
||||
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