Skip to content

Commit 583e7f9

Browse files
Reorganize project and move all code into src directory, build products to build directory.
1 parent 33e6c97 commit 583e7f9

79 files changed

Lines changed: 158 additions & 151 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
.vscode
22
.DS_Store
33
*.code-workspace
4-
*.o
5-
*.d
6-
*.dbg
7-
*.map
8-
basic_ac6502
9-
basic_apple2
10-
basic_apple2_lc
11-
basic_atari
12-
basic_sim6502
13-
basic_vc83_serial
14-
basic_vc83_serial.mem
15-
*_test
16-
*_test.s
17-
constants.inc
18-
constants.h
19-
zeropage.inc
20-
zeropage.h
21-
zeropage.s
22-
version.inc
4+
build/
5+
src/constants.inc
6+
src/constants.h
7+
src/zeropage.inc
8+
src/zeropage.h
9+
src/zeropage.s
10+
src/version.inc

Makefile

Lines changed: 67 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ TEST_TARGET = sim6502
88
TESTS = $(notdir $(basename $(wildcard tests/*_test.c)))
99
EXPECT_TESTS = $(notdir $(basename $(wildcard expect_tests/*.exp)))
1010

11-
ASMFLAGS = --create-dep $(@:.o=.d)
12-
CFLAGS = --create-dep $(@:.o=.d)
11+
ASMFLAGS = --create-dep $(@:.o=.d) --asm-include-dir src
12+
CFLAGS = --create-dep $(@:.o=.d) -I src
1313
LDFLAGS = -m $@.map -vm
1414

1515
GIT_VERSION := .byte "$(shell git describe --always --dirty 2>/dev/null || echo unknown)"
@@ -27,97 +27,115 @@ CFLAGS += -g
2727
LDFLAGS += -Wl --dbgfile,$@.dbg
2828
endif
2929

30-
all: $(addprefix basic_,$(TARGETS))
30+
all: $(addprefix build/basic_,$(TARGETS))
3131

3232
# Goal: basic_sim6502
33-
basic_sim6502.o: basic_sim6502.s basic.s constants.inc zeropage.s version.inc
34-
cl65 -t sim6502 -c $(ASMFLAGS) -o $@ $<
33+
build/basic_sim6502.o: targets/sim6502/basic_sim6502.s src/basic.s src/constants.inc src/zeropage.s src/version.inc
34+
@mkdir -p $(@D)
35+
cl65 -t sim6502 -c $(ASMFLAGS) --asm-include-dir targets/sim6502 -o $@ $<
3536

36-
basic_sim6502: basic_sim6502.o
37-
cl65 -t sim6502 -C sim6502/sim6502.cfg $(LDFLAGS) -o $@ $<
37+
build/basic_sim6502: build/basic_sim6502.o
38+
@mkdir -p $(@D)
39+
cl65 -t sim6502 -C targets/sim6502/sim6502.cfg $(LDFLAGS) -o $@ $<
3840
$(PRINT_SIZE)
3941

4042
# Goal: basic_apple2
41-
basic_apple2.o: basic_apple2.s basic.s constants.inc zeropage.s version.inc
42-
cl65 -t apple2 -c $(ASMFLAGS) -o $@ $<
43+
build/basic_apple2.o: targets/apple2/basic_apple2.s src/basic.s src/constants.inc src/zeropage.s src/version.inc
44+
@mkdir -p $(@D)
45+
cl65 -t apple2 -c $(ASMFLAGS) --asm-include-dir targets/apple2 -o $@ $<
4346

44-
basic_apple2: basic_apple2.o
45-
cl65 -t apple2 -C apple2/apple2.cfg $(LDFLAGS) -o $@ $<
47+
build/basic_apple2: build/basic_apple2.o
48+
@mkdir -p $(@D)
49+
cl65 -t apple2 -C targets/apple2/apple2.cfg $(LDFLAGS) -o $@ $<
4650
$(PRINT_SIZE)
4751

4852
# Goal: basic_apple2_lc
49-
basic_apple2_lc.o: basic_apple2_lc.s basic.s constants.inc zeropage.s version.inc
50-
cl65 -t apple2 -c $(ASMFLAGS) -o $@ $<
53+
build/basic_apple2_lc.o: targets/apple2/basic_apple2_lc.s src/basic.s src/constants.inc src/zeropage.s src/version.inc
54+
@mkdir -p $(@D)
55+
cl65 -t apple2 -c $(ASMFLAGS) --asm-include-dir targets/apple2 -o $@ $<
5156

52-
basic_apple2_lc: basic_apple2_lc.o
53-
cl65 -t apple2 -C apple2/apple2_lc.cfg $(LDFLAGS) -o $@ $<
57+
build/basic_apple2_lc: build/basic_apple2_lc.o
58+
@mkdir -p $(@D)
59+
cl65 -t apple2 -C targets/apple2/apple2_lc.cfg $(LDFLAGS) -o $@ $<
5460
$(PRINT_SIZE)
5561

5662
# Goal: basic_atari
57-
basic_atari.o: basic_atari.s basic.s constants.inc zeropage.s version.inc
58-
cl65 -t atari -c $(ASMFLAGS) -o $@ $<
63+
build/basic_atari.o: targets/atari/basic_atari.s src/basic.s src/constants.inc src/zeropage.s src/version.inc
64+
@mkdir -p $(@D)
65+
cl65 -t atari -c $(ASMFLAGS) --asm-include-dir targets/atari -o $@ $<
5966

60-
basic_atari: basic_atari.o
61-
cl65 -t atari -C atari/atari.cfg $(LDFLAGS) -o $@ $<
67+
build/basic_atari: build/basic_atari.o
68+
@mkdir -p $(@D)
69+
cl65 -t atari -C targets/atari/atari.cfg $(LDFLAGS) -o $@ $<
6270
$(PRINT_SIZE)
6371

6472
# Goal: basic_ac6502
65-
basic_ac6502.o: basic_ac6502.s basic.s constants.inc zeropage.s version.inc
66-
cl65 -t none -c $(ASMFLAGS) -o $@ $<
73+
build/basic_ac6502.o: targets/ac6502/basic_ac6502.s src/basic.s src/constants.inc src/zeropage.s src/version.inc
74+
@mkdir -p $(@D)
75+
cl65 -t none -c $(ASMFLAGS) --asm-include-dir targets/ac6502 -o $@ $<
6776

68-
basic_ac6502: basic_ac6502.o
69-
cl65 -t none -C ac6502/ac6502.cfg $(LDFLAGS) -o $@ $<
77+
build/basic_ac6502: build/basic_ac6502.o
78+
@mkdir -p $(@D)
79+
cl65 -t none -C targets/ac6502/ac6502.cfg $(LDFLAGS) -o $@ $<
7080
$(PRINT_SIZE)
7181

7282
# Goal: basic_vc83_serial
73-
basic_vc83_serial.o: basic_vc83_serial.s basic.s constants.inc zeropage.s version.inc
74-
cl65 -t none -c $(ASMFLAGS) -o $@ $<
83+
build/basic_vc83_serial.o: targets/vc83_serial/basic_vc83_serial.s src/basic.s src/constants.inc src/zeropage.s src/version.inc
84+
@mkdir -p $(@D)
85+
cl65 -t none -c $(ASMFLAGS) --asm-include-dir targets/vc83_serial -o $@ $<
7586

76-
basic_vc83_serial: basic_vc83_serial.o
77-
cl65 -t none -C vc83_serial/vc83_serial.cfg $(LDFLAGS) -o $@ $<
87+
build/basic_vc83_serial: build/basic_vc83_serial.o
88+
@mkdir -p $(@D)
89+
cl65 -t none -C targets/vc83_serial/vc83_serial.cfg $(LDFLAGS) -o $@ $<
7890
$(PRINT_SIZE)
7991

80-
basic_vc83_serial.mem: basic_vc83_serial
92+
build/basic_vc83_serial.mem: build/basic_vc83_serial
93+
@mkdir -p $(@D)
8194
if command -v srec_cat >/dev/null; then srec_cat $< -Binary -offset 0x0400 -Output $@ -VMem 8; else echo "srec_cat not installed"; touch $@; fi
8295

8396
# Rule for version.inc
84-
version.inc: FORCE
97+
src/version.inc: FORCE
98+
@mkdir -p $(@D)
8599
@echo '$(GIT_VERSION)' | cmp -s - $@ || echo '$(GIT_VERSION)' > $@
86100

87101
# Rules for building the constants files:
88-
constants.inc: constants.m4
102+
src/constants.inc: src/constants.m4
103+
@mkdir -p $(@D)
89104
m4 $< >$@
90105

91-
constants.h: constants.m4
106+
src/constants.h: src/constants.m4
107+
@mkdir -p $(@D)
92108
m4 -D__C__ $< >$@
93109

94110
# Rules for building the zero page files:
95-
zeropage.s: zeropage.m4
111+
src/zeropage.s: src/zeropage.m4
112+
@mkdir -p $(@D)
96113
m4 -DOUTPUT=s $< >$@
97114

98-
zeropage.h: zeropage.m4
115+
src/zeropage.h: src/zeropage.m4
116+
@mkdir -p $(@D)
99117
m4 -DOUTPUT=h $< >$@
100118

101119
# Unit tests
102120
test: $(addprefix run_,$(TESTS))
103121

104-
run_%: tests/%
122+
run_%: build/tests/%
105123
sim65 $<
106124

107-
tests/%: tests/%.o basic_tests.o
108-
cl65 -t $(TEST_TARGET) -C $(TEST_TARGET)/$(TEST_TARGET).cfg $(LDFLAGS) -o $@ $^
125+
build/tests/%: build/tests/%.o build/tests/basic_tests.o
126+
@mkdir -p $(@D)
127+
cl65 -t $(TEST_TARGET) -C targets/$(TEST_TARGET)/$(TEST_TARGET).cfg $(LDFLAGS) -o $@ $^
109128

110-
tests/%.o: tests/%.c constants.h zeropage.h tests/test.h
111-
cl65 -t $(TEST_TARGET) -C $(TEST_TARGET)/$(TEST_TARGET).cfg -c $(CFLAGS) -o $@ $<
129+
build/tests/%.o: tests/%.c src/constants.h src/zeropage.h tests/test.h
130+
@mkdir -p $(@D)
131+
cl65 -t $(TEST_TARGET) -C targets/$(TEST_TARGET)/$(TEST_TARGET).cfg -c $(CFLAGS) -o $@ $<
112132

113-
basic_tests.o: basic_tests.s basic.s constants.inc zeropage.s version.inc
114-
cl65 -t $(TEST_TARGET) -C $(TEST_TARGET)/$(TEST_TARGET).cfg -c $(ASMFLAGS) -o $@ $<
115-
116-
clean::
117-
rm -f $(addprefix tests/,$(TESTS))
133+
build/tests/basic_tests.o: tests/basic_tests.s src/basic.s src/constants.inc src/zeropage.s src/version.inc
134+
@mkdir -p $(@D)
135+
cl65 -t $(TEST_TARGET) -C targets/$(TEST_TARGET)/$(TEST_TARGET).cfg -c $(ASMFLAGS) --asm-include-dir targets/sim6502 --asm-include-dir tests -o $@ $<
118136

119137
# Integration tests
120-
expect_test: basic_sim6502 $(addprefix run_expect_test_,$(EXPECT_TESTS))
138+
expect_test: build/basic_sim6502 $(addprefix run_expect_test_,$(EXPECT_TESTS))
121139

122140
run_expect_test_%:
123141
expect expect_tests/$*.exp
@@ -126,8 +144,9 @@ run_expect_test_%:
126144
.SECONDARY:
127145

128146
clean::
129-
rm -f $(addprefix basic_,$(TARGETS)) basic_tests.o constants.inc constants.h zeropage.s zeropage.h version.inc *.o *.d *.map *.dbg tests/*.o tests/*.d tests/*.map tests/*.dbg
147+
rm -rf build/
148+
rm -f src/constants.inc src/constants.h src/zeropage.s src/zeropage.h src/version.inc
130149

131-
-include $(addsuffix .d,$(addprefix basic_,$(TARGETS)))
132-
-include $(addsuffix .d,$(addprefix tests/,$(TESTS)))
133-
-include basic_tests.d
150+
-include $(addsuffix .d,$(addprefix build/basic_,$(TARGETS)))
151+
-include $(addsuffix .d,$(addprefix build/tests/,$(TESTS)))
152+
-include build/tests/basic_tests.d

basic_ac6502.s

Lines changed: 0 additions & 11 deletions
This file was deleted.

basic_apple2.s

Lines changed: 0 additions & 14 deletions
This file was deleted.

basic_apple2_lc.s

Lines changed: 0 additions & 15 deletions
This file was deleted.

basic_atari.s

Lines changed: 0 additions & 11 deletions
This file was deleted.

basic_sim6502.s

Lines changed: 0 additions & 10 deletions
This file was deleted.

basic_tests.s

Lines changed: 0 additions & 9 deletions
This file was deleted.

basic_vc83_serial.s

Lines changed: 0 additions & 11 deletions
This file was deleted.

expect_tests/common.expinc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
proc spawn_basic {} {
99
global spawn_id
10-
spawn sim65 basic_sim6502
10+
spawn sim65 build/basic_sim6502
1111
fconfigure $spawn_id -translation { crlf lf }
1212
expect "VC83 BASIC*BYTES FREE\n"
1313
expect_before {

0 commit comments

Comments
 (0)