2023-12-20 12:27:54 +01:00
|
|
|
ROM = ../rom.bin
|
|
|
|
SPI = ../spi.bin
|
2023-10-26 19:51:20 +02:00
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
OBJ_DIR = build
|
2023-10-26 19:51:20 +02:00
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
SRC_DIRS = . programs system util
|
2023-10-26 19:51:20 +02:00
|
|
|
|
|
|
|
# VASM = ~/6502/vasm6502
|
|
|
|
ASM = ca65
|
2023-10-30 22:15:40 +01:00
|
|
|
ASMFLAGS = -g --cpu 65C02 $(foreach srcdir, $(SRC_DIRS), -I $(srcdir))
|
2023-10-26 19:51:20 +02:00
|
|
|
|
|
|
|
LD = ld65
|
2023-12-08 22:56:35 +01:00
|
|
|
LDFLAGS = -C linker.conf --obj-path $(OBJ_DIR) -Ln labels
|
2023-10-26 19:51:20 +02:00
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
SRC = $(wildcard *.s65) $(wildcard */*.s65)
|
|
|
|
OBJ = $($(notdir SRC):%.s65=$(OBJ_DIR)/%.o)
|
|
|
|
OBJ_DIRS = $(OBJ_DIR) $(foreach dir_,$(SRC_DIRS),$(OBJ_DIR)/$(dir_))
|
|
|
|
DEP = $(wildcard $(OBJ_DIR)/*/*.d)
|
2023-10-26 19:51:20 +02:00
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
# DEPENDS = $(shell $(VASM) -depend=make $(MAIN))
|
2023-10-26 19:51:20 +02:00
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
-include $(DEP)
|
2023-10-27 16:50:58 +02:00
|
|
|
|
2023-12-20 12:27:54 +01:00
|
|
|
.PHONY: default test clean print spi
|
2023-12-08 00:01:30 +01:00
|
|
|
.DEFAULT_GOAL = default
|
2023-10-28 03:48:27 +02:00
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
FMT_MESSAGE="\e[1;34m%s\e[0m %s\n"
|
|
|
|
FMT_ASM="\e[1;34mAssembling\e[0m: \e[34m%s\e[39m from %s\e[0m\n"
|
|
|
|
FMT_VAR="\e[1;35m%s\e[0m: %s\n"
|
2023-10-27 16:50:58 +02:00
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
test: ../test.bin
|
|
|
|
print:
|
|
|
|
@printf $(FMT_VAR) "ASMFLAGS" "$(ASMFLAGS)"
|
|
|
|
@printf $(FMT_VAR) "LDFLAGS" "$(LDFLAGS)"
|
|
|
|
@printf $(FMT_VAR) "SRC" "$(SRC)"
|
|
|
|
@printf $(FMT_VAR) "OBJ" "$(OBJ)"
|
2023-12-20 12:27:54 +01:00
|
|
|
default: $(ROM) $(SPI)
|
|
|
|
|
|
|
|
spi: default
|
|
|
|
./../ad-spi/spi-transfer -f $(SPI)
|
2023-10-27 16:50:58 +02:00
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
$(OBJ_DIRS):
|
|
|
|
mkdir -p $@
|
2023-10-27 16:50:58 +02:00
|
|
|
|
2023-12-20 12:27:54 +01:00
|
|
|
$(SPI) $(ROM): $(OBJ) linker.conf
|
2023-12-08 22:56:35 +01:00
|
|
|
@printf $(FMT_MESSAGE) "Linking" "$@"
|
|
|
|
$(LD) $(LDFLAGS) $(OBJ) -o $@
|
|
|
|
|
|
|
|
../test.bin: $(OBJ_DIR)/test.o
|
|
|
|
$(LD) $(LDFLAGS) $< -o $@
|
2023-10-28 03:48:27 +02:00
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
$(OBJ_DIR)/%.o: %.s65 | $(OBJ_DIRS)
|
|
|
|
@printf $(FMT_ASM) "$@" "$<"
|
|
|
|
$(ASM) $(ASMFLAGS) --create-dep $(patsubst %.o,%.d,$@) $< -o $@
|
2023-10-28 03:48:27 +02:00
|
|
|
|
2023-10-27 16:50:58 +02:00
|
|
|
clean:
|
2023-12-08 22:56:35 +01:00
|
|
|
rm -r $(OBJ_DIR)
|
2023-10-27 16:50:58 +02:00
|
|
|
rm $(ROM)
|
2023-12-20 12:27:54 +01:00
|
|
|
rm $(SPI)
|