make: Move arch.mk to toolchain.mk

The arch.mk file contains variables/rules to build, so rename it. Leave
an empty arch.mk so it can still be used in a follow-up commit.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford
2022-10-14 08:14:54 -06:00
committed by Tim Crawford
parent c5b737f505
commit ce66685c70
5 changed files with 59 additions and 57 deletions

View File

@ -53,6 +53,8 @@ INCLUDE+=$(wildcard $(ARCH_DIR)/include/arch/*.h) $(ARCH_DIR)/arch.mk
CFLAGS+=-I$(ARCH_DIR)/include -D__ARCH__=$(ARCH) CFLAGS+=-I$(ARCH_DIR)/include -D__ARCH__=$(ARCH)
include $(ARCH_DIR)/arch.mk include $(ARCH_DIR)/arch.mk
include $(ARCH_DIR)/toolchain.mk
# The architecture defines build targets, no more is required # The architecture defines build targets, no more is required
endif endif

View File

@ -1,27 +0,0 @@
# SPDX-License-Identifier: GPL-3.0-only
CC=sdcc -mmcs51 --model-large --code-size $(CODE_SIZE) --xram-size $(SRAM_SIZE) --Werror
OBJ=$(sort $(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 file to binary file
$(BUILD)/ec.rom: $(BUILD)/ec.ihx
@mkdir -p $(@D)
objcopy -I ihex -O binary --gap-fill=0xFF $< $@
# Link object files into Intel Hex file
$(BUILD)/ec.ihx: $(OBJ)
@mkdir -p $(@D)
$(CC) $(LDFLAGS) -o $@ $^
# Compile C files into object files
$(OBJ): $(BUILD)/%.rel: src/%.c $(INCLUDE)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -o $@ -c $<

View File

@ -0,0 +1,27 @@
# SPDX-License-Identifier: GPL-3.0-only
CC=sdcc -mmcs51 --model-large --code-size $(CODE_SIZE) --xram-size $(SRAM_SIZE) --Werror
OBJ=$(sort $(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 file to binary file
$(BUILD)/ec.rom: $(BUILD)/ec.ihx
@mkdir -p $(@D)
objcopy -I ihex -O binary --gap-fill=0xFF $< $@
# Link object files into Intel Hex file
$(BUILD)/ec.ihx: $(OBJ)
@mkdir -p $(@D)
$(CC) $(LDFLAGS) -o $@ $^
# Compile C files into object files
$(OBJ): $(BUILD)/%.rel: src/%.c $(INCLUDE)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -o $@ -c $<

View File

@ -1,30 +0,0 @@
# SPDX-License-Identifier: GPL-3.0-only
CC=avr-gcc -mmcu=$(EC_VARIANT)
CFLAGS+=-Os -fstack-usage -Wall -Werror -Wl,--gc-sections -Wl,-u,vfprintf -lprintf_flt
OBJCOPY = avr-objcopy
OBJ=$(sort $(patsubst src/%.c,$(BUILD)/%.o,$(SRC)))
# Run EC rom in simulator
sim: $(BUILD)/ec.elf
simavr $< --mcu $(EC_VARIANT)
# Convert from Intel Hex file to binary file
$(BUILD)/ec.rom: $(BUILD)/ec.ihx
@mkdir -p $(@D)
$(OBJCOPY) -I ihex -O binary --gap-fill 0xFF $< $@
# Convert from ELF file to Intel Hex file
$(BUILD)/ec.ihx: $(BUILD)/ec.elf
@mkdir -p $(@D)
$(OBJCOPY) -j .text -j .data -O ihex $< $@
# Link object files into ELF file
$(BUILD)/ec.elf: $(OBJ)
@mkdir -p $(@D)
$(CC) -o $@ $^
# Compile C files into object files
$(BUILD)/%.o: src/%.c $(INCLUDE)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -o $@ -c $<

30
src/arch/avr/toolchain.mk Normal file
View File

@ -0,0 +1,30 @@
# SPDX-License-Identifier: GPL-3.0-only
CC=avr-gcc -mmcu=$(EC_VARIANT)
CFLAGS+=-Os -fstack-usage -Wall -Werror -Wl,--gc-sections -Wl,-u,vfprintf -lprintf_flt
OBJCOPY = avr-objcopy
OBJ=$(sort $(patsubst src/%.c,$(BUILD)/%.o,$(SRC)))
# Run EC rom in simulator
sim: $(BUILD)/ec.elf
simavr $< --mcu $(EC_VARIANT)
# Convert from Intel Hex file to binary file
$(BUILD)/ec.rom: $(BUILD)/ec.ihx
@mkdir -p $(@D)
$(OBJCOPY) -I ihex -O binary --gap-fill 0xFF $< $@
# Convert from ELF file to Intel Hex file
$(BUILD)/ec.ihx: $(BUILD)/ec.elf
@mkdir -p $(@D)
$(OBJCOPY) -j .text -j .data -O ihex $< $@
# Link object files into ELF file
$(BUILD)/ec.elf: $(OBJ)
@mkdir -p $(@D)
$(CC) -o $@ $^
# Compile C files into object files
$(BUILD)/%.o: src/%.c $(INCLUDE)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -o $@ -c $<