55 lines
1.2 KiB
Makefile
55 lines
1.2 KiB
Makefile
ROM = ../rom.bin
|
|
|
|
OBJ_DIR = build
|
|
|
|
SRC_DIRS = . programs system util
|
|
|
|
# VASM = ~/6502/vasm6502
|
|
ASM = ca65
|
|
ASMFLAGS = -g --cpu 65C02 $(foreach srcdir, $(SRC_DIRS), -I $(srcdir))
|
|
|
|
LD = ld65
|
|
LDFLAGS = -C linker.conf --obj-path $(OBJ_DIR) -Ln labels
|
|
|
|
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)
|
|
|
|
# DEPENDS = $(shell $(VASM) -depend=make $(MAIN))
|
|
|
|
-include $(DEP)
|
|
|
|
.PHONY: default test clean print
|
|
.DEFAULT_GOAL = default
|
|
|
|
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"
|
|
|
|
test: ../test.bin
|
|
print:
|
|
@printf $(FMT_VAR) "ASMFLAGS" "$(ASMFLAGS)"
|
|
@printf $(FMT_VAR) "LDFLAGS" "$(LDFLAGS)"
|
|
@printf $(FMT_VAR) "SRC" "$(SRC)"
|
|
@printf $(FMT_VAR) "OBJ" "$(OBJ)"
|
|
default: $(ROM)
|
|
|
|
$(OBJ_DIRS):
|
|
mkdir -p $@
|
|
|
|
$(ROM): $(OBJ)
|
|
@printf $(FMT_MESSAGE) "Linking" "$@"
|
|
$(LD) $(LDFLAGS) $(OBJ) -o $@
|
|
|
|
../test.bin: $(OBJ_DIR)/test.o
|
|
$(LD) $(LDFLAGS) $< -o $@
|
|
|
|
$(OBJ_DIR)/%.o: %.s65 | $(OBJ_DIRS)
|
|
@printf $(FMT_ASM) "$@" "$<"
|
|
$(ASM) $(ASMFLAGS) --create-dep $(patsubst %.o,%.d,$@) $< -o $@
|
|
|
|
clean:
|
|
rm -r $(OBJ_DIR)
|
|
rm $(ROM)
|