Last active
October 31, 2017 14:54
-
-
Save thelbane/0b2930e64376173a78b641482aba8a99 to your computer and use it in GitHub Desktop.
makefile for cross-development on Mac OSX targeting Apple II 6502 object binary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The name of the destination disk image | |
IMAGE_TARGET = tetris.dsk | |
# Apple II command issued by the "run" recipe after booting the disk image. | |
RUN_CMD = "BRUN TETRIS" | |
# Paths and flags for build/processing applications | |
DASM = dasm | |
DASM_FLAGS = -v0 -f2 | |
AC = java -jar /usr/local/bin/ac.jar | |
# Source folder. All files in this folder will produce an object file (No subfolders) | |
SDIR = ./src | |
# Include folder. Changes to files in this folder will invalidate the current build (No subfolders) | |
IDIR = ./include | |
# Output folder for build product | |
BDIR = ./build | |
# Resources required by this makefile | |
RDIR = ./res | |
# Path to the runner script | |
RUNNER = osascript $(RDIR)/runner.scpt | |
# Paths to source files | |
SRC_FILES = $(shell ls $(SDIR)) | |
ASM_FILES = $(filter %.asm,$(SRC_FILES)) | |
# BAS_FILES = $(filter %.bas,$(SRC_FILES)) | |
SRC = $(patsubst %,$(SDIR)/%,$(ASM_FILES)) | |
# BAS = $(patsubst %,$(SDIR)/%,$(BAS_FILES)) | |
# Paths to include files | |
_DEPS = $(shell ls $(IDIR)) | |
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS)) | |
# Destination paths to object files | |
OBJ = $(patsubst %.asm,$(BDIR)/%,$(ASM_FILES)) | |
# Path to disk image | |
IMAGE = $(abspath $(BDIR)/$(IMAGE_TARGET)) | |
# Path to the blank bootable disk image | |
BOOTIMAGE = $(RDIR)/dos3.3bootable.dsk | |
# Shell commands to copy object files to the disk image | |
COPY_OBJ = $(foreach FN,$(OBJ),$(AC) -cc65 $(IMAGE) $(shell echo $(notdir $(FN)) | tr a-z A-Z) B < $(FN);) | |
# COPY_BAS = $(foreach FN,$(BAS),$(AC) -p $(IMAGE) $(shell echo $(notdir $(FN)) | tr a-z A-Z) A < $(FN);) | |
.PHONY: all | |
all: $(IMAGE) | |
.PHONY: clean | |
clean: | |
@rm -rf $(BDIR) | |
@echo All clean. | |
# Build all object files | |
$(OBJ): $(DEPS) $(SRC) | |
@mkdir -p $(BDIR) | |
$(eval OBJNAME = $(notdir $@)) | |
$(eval SRCPATH = $(patsubst %,$(SDIR)/%.asm,$(OBJNAME))) | |
$(eval LSTPATH = $(BDIR)/$(OBJNAME).lst) | |
$(DASM) $(SRCPATH) -o$@ -l$(LSTPATH) $(DASM_FLAGS) | |
# Create disk image | |
$(IMAGE): $(OBJ) | |
cp $(BOOTIMAGE) $(IMAGE) | |
$(COPY_OBJ) | |
$(COPY_BAS) | |
# Boot disk image in emulator | |
.PHONY: run | |
run: $(IMAGE) | |
$(RUNNER) $(IMAGE) $(RUN_CMD) | |
@echo Running... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment