the Makefile now builds all artifacts, including final output s37 and bin files under "build" so as to not clutter up the root directory and making it easier to gitignore all build artifacts now and into the future. as well, the Makefile now has a new target to invoke srec2bin.py for us to build ready-to-flash artifacts srec2bin.py has been updated to be more flexible and do some minimal argument error checking. it now also will output a CSV file for use with FoenixMgr's flash-bulk option. this is useful as the number of 8k bin files can and will vary now and into the future, especially if you are building with -O2 optimizations for size, etc.
144 lines
4.6 KiB
Makefile
144 lines
4.6 KiB
Makefile
TARGET = toolbox
|
|
TARGET_RAM = $(TARGET)_ram
|
|
TARGET_ROM = $(TARGET)_rom
|
|
|
|
UNIT = F256K
|
|
|
|
SRCS_BASE = boot.c \
|
|
log.c \
|
|
memory.c \
|
|
proc.c \
|
|
ring_buffer.c \
|
|
simpleio.c \
|
|
sys_general.c \
|
|
timers.c \
|
|
toolbox.c \
|
|
utilities.c \
|
|
dev/block.c \
|
|
dev/channel.c \
|
|
dev/console.c \
|
|
dev/fsys.c \
|
|
dev/sprites.c \
|
|
dev/tiles.c \
|
|
dev/txt_screen.c \
|
|
dev/rtc.c \
|
|
dev/uart.c \
|
|
snd/codec_c256.c \
|
|
snd/psg.c \
|
|
snd/sid.c \
|
|
fatfs/ff.c \
|
|
fatfs/ffsystem.c \
|
|
fatfs/ffunicode.c
|
|
|
|
SRCS_BASE_F256 = cartridge.c \
|
|
dev/txt_f256.c \
|
|
dev/kbd_f256.c \
|
|
dev/indicators_c256.c \
|
|
dev/interrupts_f256.c \
|
|
dev/sdc_f256.c \
|
|
dev/iec.c \
|
|
fatfs/toolbox_bdev.c \
|
|
C256/extras.s \
|
|
C256/f256-cstartup.s \
|
|
C256/iecll.s \
|
|
C256/interrupts.s \
|
|
C256/io_stubs.c \
|
|
C256/jumptable.s
|
|
|
|
ifeq ($(UNIT),F256)
|
|
TOOLCHAIN = 65816
|
|
SRCS_FOR_UNIT = $(SRCS_BASE_F256) dev/kbd_f256jr.c
|
|
CFLAGS_FOR_UNIT = -DMODEL=2 -DCPU=255 --target=f256
|
|
LDFLAGS_FOR_UNIT_ROM = src/C256/f256-flash.scm --cstartup=f256
|
|
LDFLAGS_FOR_UNIT_RAM = src/C256/f256-ld_lc.scm --cstartup=f256
|
|
else ifeq ($(UNIT),F256JR2)
|
|
TOOLCHAIN = 65816
|
|
SRCS_FOR_UNIT = $(SRCS_BASE_F256) dev/kbd_f256jr.c
|
|
CFLAGS_FOR_UNIT = -DMODEL=35 -DCPU=255 --target=f256
|
|
LDFLAGS_FOR_UNIT_ROM = src/C256/f256k2-flash.scm --cstartup=f256
|
|
LDFLAGS_FOR_UNIT_RAM = src/C256/f256-ld_lc.scm --cstartup=f256
|
|
else ifeq ($(UNIT),F256K)
|
|
TOOLCHAIN = 65816
|
|
SRCS_FOR_UNIT = $(SRCS_BASE_F256) dev/kbd_f256k.c
|
|
CFLAGS_FOR_UNIT = -DMODEL=18 -DCPU=255 --target=f256
|
|
LDFLAGS_FOR_UNIT_ROM = src/C256/f256-flash.scm --cstartup=f256
|
|
LDFLAGS_FOR_UNIT_RAM = src/C256/f256-ld_lc.scm --cstartup=f256
|
|
else ifeq ($(UNIT),F256K2)
|
|
TOOLCHAIN = 65816
|
|
SRCS_FOR_UNIT = $(SRCS_BASE_F256) dev/kbd_f256k.c
|
|
CFLAGS_FOR_UNIT = -DMODEL=17 -DCPU=255 --target=f256
|
|
LDFLAGS_FOR_UNIT_ROM = src/C256/f256k2-flash.scm --cstartup=f256
|
|
LDFLAGS_FOR_UNIT_RAM = src/C256/f256-ld_lc.scm --cstartup=f256
|
|
else
|
|
$(error "Unrecognized UNIT: $(UNIT)")
|
|
endif
|
|
|
|
ifeq ($(TOOLCHAIN),65816)
|
|
ifeq ($(strip $(CALYPSI_65816_ROOT)),)
|
|
$(error "Please set CALYPSI_65816_ROOT in your environment!")
|
|
endif
|
|
|
|
CC = cc65816
|
|
AS = as65816
|
|
LD = ln65816
|
|
TOOLCHAIN_ROOT = $(CALYPSI_65816_ROOT)
|
|
else
|
|
$(error "Unrecognized TOOLCHAIN: $(TOOLCHAIN)")
|
|
endif
|
|
|
|
SRC_DIR = src
|
|
SRC_FILES = $(addprefix $(SRC_DIR)/, $(SRCS_BASE) $(SRCS_FOR_UNIT))
|
|
INCLUDE_DIRS = $(SRC_DIR) $(SRC_DIR)/include $(TOOLCHAIN_ROOT)/include
|
|
INCLUDES = $(foreach dir,$(INCLUDE_DIRS),-I$(dir))
|
|
|
|
BUILD_DIR = build
|
|
|
|
OBJ_DIR = $(BUILD_DIR)/obj
|
|
OBJ_FILES = $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(SRC_FILES)))
|
|
|
|
DEPS_DIR = $(OBJ_DIR)
|
|
DEPENDS = $(OBJ_FILES:.o=.d)
|
|
|
|
CFLAGS = --code-model=large --data-model=large --list-file=$@.lst $(INCLUDES) $(CFLAGS_FOR_UNIT)
|
|
AFLAGS = --code-model=large --data-model=large $(INCLUDES)
|
|
|
|
LDFLAGS_FOR_ROM = --rom-code $(LDFLAGS_FOR_UNIT_ROM)
|
|
LDFLAGS_FOR_RAM = $(LDFLAGS_FOR_UNIT_RAM)
|
|
|
|
.PHONY: clean
|
|
|
|
all: rom ram flashable
|
|
|
|
rom: $(BUILD_DIR)/$(TARGET_ROM).s37
|
|
|
|
ram: $(BUILD_DIR)/$(TARGET_RAM).s37
|
|
|
|
flashable: $(BUILD_DIR)/$(TARGET).bin
|
|
|
|
clean:
|
|
rm -f $(BUILD_DIR)/*.s37
|
|
rm -f $(BUILD_DIR)/*.lst
|
|
rm -f $(BUILD_DIR)/*.bin
|
|
rm -rf $(OBJ_DIR)
|
|
|
|
$(BUILD_DIR)/$(TARGET_ROM).s37: $(OBJ_FILES)
|
|
$(LD) -o $@ $^ $(LDFLAGS_FOR_ROM) --output-format=s37 --list-file=$@.lst
|
|
|
|
$(BUILD_DIR)/$(TARGET_RAM).s37: $(OBJ_FILES)
|
|
$(LD) -o $@ $^ $(LDFLAGS_FOR_RAM) --output-format=s37 --list-file=$@.lst
|
|
|
|
$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET_ROM).s37
|
|
python utils/srec2bin.py $(BUILD_DIR)/$(TARGET_ROM).s37
|
|
|
|
$(OBJ_DIR)/%.c.o: %.c
|
|
@mkdir -p $(dir $@)
|
|
$(CC) -MMD -MP -MF$(DEPS_DIR)/$*.d $(CFLAGS) -o $@ $<
|
|
|
|
$(OBJ_DIR)/%.s.o: %.s
|
|
@mkdir -p $(dir $@)
|
|
$(AS) $(AFLAGS) -o $@ $<
|
|
|
|
-include $(DEPENDS)
|
|
|
|
|