-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
81 lines (56 loc) · 1.78 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
CC=cl65
AC=aplc
C2T=c2t
START_ADDRESS=2000
CFLAGS= -t apple2 --start-addr 0x$(START_ADDRESS) -Wl -D__EXEHDR__=0
SRC_DIR=src
OBJ_DIR=obj
BIN_DIR=bin
DISK_IMAGE=lib/TEMPLATE.dsk
TARGET=$(BIN_DIR)/main
# C_SOURCES:=$(wildcard $(SRC_DIR)/*.c)
C_SOURCES:= $(SRC_DIR)/main.c $(SRC_DIR)/song.c
# ASM_SOURCES:=$(wildcard $(SRC_DIR)/*.asm)
ASM_SOURCES:=$(SRC_DIR)/note.asm
OBJECTS=$(C_SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) $(ASM_SOURCES:${SRC_DIR}/%.asm=$(OBJ_DIR)/%.o)
ASM=$(C_SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.asm)
all: target wav aif disk
asm: $(ASM)
target: $(TARGET)
wav: $(TARGET).wav
aif: $(TARGET).aif
disk: $(TARGET).dsk
install:
scripts/install
uninstall:
scripts/uninstall
# Rule to generate assembly
$(OBJ_DIR)/%.asm: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) -S $(CFLAGS) -c -o $@ $<
# Rule to make object files from .c files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CFLAGS) -c -o $@ $<
# Rule to make object files from .asm files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm | $(OBJ_DIR)
$(CC) $(CFLAGS) -c -o $@ $<
# Rule to make target
$(TARGET): $(OBJECTS) | $(BIN_DIR)
$(CC) $(CFLAGS) -o $@ $^
# Generate .wav file using c2t
$(TARGET).wav: $(TARGET)
$(C2T) -bc8 $(TARGET),$(START_ADDRESS) $(TARGET).wav
# Generate .aif file using c2t
$(TARGET).aif: $(TARGET)
$(C2T) -bc8 $(TARGET),$(START_ADDRESS) $(TARGET).aif
# Generate disk image using AppleCommander
$(TARGET).dsk: $(TARGET)
cp $(DISK_IMAGE) $(TARGET).dsk
aplc -p $(TARGET).dsk main.system sys 0x$(START_ADDRESS) < $(TARGET)
# Rule to make directories
$(SRC_DIR) $(BIN_DIR) $(OBJ_DIR):
mkdir -p $@
clean:
@[ -n "${OBJ_DIR}" ] || { echo "OBJ_DIR unset or null"; exit 127; }
@[ -n "${BIN_DIR}" ] || { echo "BIN_DIR unset or null"; exit 127; }
rm -rf $(BIN_DIR) $(OBJ_DIR)
.PHONY: all target wav aif disk clean dir init uninstall