|
| 1 | +# |
| 2 | +# Makefile for CCGMS Term, resurrected from antiquity, September 2016 |
| 3 | +# (C) Craig Smith, 2016 |
| 4 | +# Permission is granted to modify and redistribute this software under |
| 5 | +# the terms of the GPL v3, see LICENSE for details. |
| 6 | +# |
| 7 | +# Building requires cc65 6502 cross-compiler package; |
| 8 | +# see http://cc65.github.io/cc65 or 'git clone https://github.com/cc65/cc65.git' |
| 9 | +# to build yourself. |
| 10 | +# Optionally creating a .d64 image of the resulting C64 prg requires the c1541 |
| 11 | +# utility from VICE in your path. |
| 12 | + |
| 13 | +OUTPUT_PRG = ccgmsterm |
| 14 | +D64IMAGE = ccgmsterm.d64 |
| 15 | +SRC = ccgmsterm.s |
| 16 | + |
| 17 | +LSTF = $(SRC:.s=.lst) |
| 18 | +OBJF = $(SRC:.s=.o) |
| 19 | + |
| 20 | +OBJDIR = obj |
| 21 | +OBJ = $(OBJF:%=$(OBJDIR)/%) |
| 22 | +LST = $(LSTF:%=$(OBJDIR)/%) |
| 23 | + |
| 24 | +# Define HISTORICAL=1 below to re-enable script-kiddie protection |
| 25 | +# (and a baud rate bug), so the assembled output is exactly like |
| 26 | +# the historical CCGMS Term 5.5 |
| 27 | +# Or just use the 'make history' rule [sorry :-)] |
| 28 | +# |
| 29 | +HISTORICAL?=0 |
| 30 | + |
| 31 | +ifneq (0,$(HISTORICAL)) |
| 32 | + HISTARG = -Dhistorical=$(HISTORICAL) |
| 33 | + HISTENCODE = encode |
| 34 | +endif |
| 35 | + |
| 36 | +all: term image |
| 37 | + echo $(OBJ) |
| 38 | + |
| 39 | +term: $(OUTPUT_PRG) $(HISTENCODE) |
| 40 | + |
| 41 | +$(OBJ): $(SRC) $(OBJDIR) |
| 42 | + ca65 $(HISTARG) -t c64 -l $(LST) $(SRC) -o $(OBJ) |
| 43 | + |
| 44 | +$(OUTPUT_PRG): precheck $(OBJDIR) $(OBJ) |
| 45 | + cl65 $(HISTARG) -t c64 -C c64-asm.cfg $(OBJ) -o $(OUTPUT_PRG) |
| 46 | + @echo $(OUTPUT_PRG) created. |
| 47 | + |
| 48 | +$(OBJDIR): |
| 49 | + @mkdir -p $(OBJDIR) |
| 50 | + |
| 51 | +encode: $(OUTPUT_PRG) |
| 52 | + mv $(OUTPUT_PRG) $(OUTPUT_PRG).pre && \ |
| 53 | + perl encode.pl $(OUTPUT_PRG).pre > $(OUTPUT_PRG) && \ |
| 54 | + rm -f $(OUTPUT_PRG).pre |
| 55 | + |
| 56 | +image: $(OUTPUT_PRG) |
| 57 | + @c1541 -h >/dev/null 2>&1 || (echo "c1541 not found in path; skipping creation of .d64 image." ; exit 0) |
| 58 | + @dd if=/dev/zero of=$(D64IMAGE) bs=256 count=683 >/dev/null 2>&1 |
| 59 | + c1541 -attach $(D64IMAGE) -format "ccgmsterm 5.5,cg" -write $(OUTPUT_PRG) -list |
| 60 | + |
| 61 | +history: # couldn't resist |
| 62 | + @make HISTORICAL=1 OUTPUT_PRG=ccgmsterm5.5 term image |
| 63 | +hclean: |
| 64 | + @make HISTORICAL=1 OUTPUT_PRG=ccgmsterm5.5 clean |
| 65 | + |
| 66 | +clean: |
| 67 | + rm -f $(OBJ) $(LST) $(OUTPUT_PRG) $(D64IMAGE) ./*~ |
| 68 | + @test -d $(OBJDIR) && rmdir $(OBJDIR) || exit 0 |
| 69 | + |
| 70 | +precheck: |
| 71 | + @cl65 >/dev/null 2>/dev/null || (echo "cl65 6502 assembler is not in path." && exit 1) |
| 72 | + @(cl65 -V 2>&1 | egrep 'V2\.1[56789]|V2\.[23456789]|V[3456789]\.') > /dev/null || (echo Requirement ca65 version 2.15 or later not found && cl65 -V && exit 1) |
| 73 | + |
| 74 | +.PHONY: precheck encode history image |
| 75 | + |
0 commit comments