2 # makefile for the regression tests that generate output which has to be
3 # compared with reference output
9 CC65FLAGS := -t sim6502
10 SIM65FLAGS := -x 200000000
12 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
13 SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
21 WORKDIR := ../../testwrk
23 DIFF := $(WORKDIR)/bdiff
25 CFLAGS := -O2 -Wall -W -Wextra -fwrapv -fno-strict-overflow
29 SOURCES := $(wildcard *.c)
30 REFS := $(SOURCES:%.c=$(WORKDIR)/%.ref)
31 TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg))
36 $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host
37 $(WORKDIR)/$*.host > $@
39 # Some files have "K & R"-style syntax. Therefore, some forward
40 # function-declarations don't match the later function definitions.
41 # Those programs fail when fastcall is used; but, the cdecl calling convention
42 # tolerates those conflicts. Therefore, make their functions default to cdecl.
44 $(WORKDIR)/init%prg: CC65FLAGS += -Wc --all-cdecl
45 $(WORKDIR)/switch.%rg: CC65FLAGS += -Wc --all-cdecl
47 # Also, yacc.c does some things that fail when stack operations are optimized.
48 # Therefore, don't optimize them.
50 $(WORKDIR)/yacc.%rg: CC65FLAGS += -Wc --all-cdecl,--disable-opt,OptStackOps
51 $(WORKDIR)/yaccdbg%prg: CC65FLAGS += -Wc --all-cdecl,--disable-opt,OptStackOps
53 $(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref
54 $(CL65) $(CC65FLAGS) $< -o $@
55 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
56 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
58 $(WORKDIR)/%.o.prg: %.c $(WORKDIR)/%.ref
59 $(CL65) -O $(CC65FLAGS) $< -o $@
60 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
61 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
63 $(WORKDIR)/%.os.prg: %.c $(WORKDIR)/%.ref
64 $(CL65) -Os $(CC65FLAGS) $< -o $@
65 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
66 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
68 $(WORKDIR)/%.osi.prg: %.c $(WORKDIR)/%.ref
69 $(CL65) -Osi $(CC65FLAGS) $< -o $@
70 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
71 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
73 $(WORKDIR)/%.osir.prg: %.c $(WORKDIR)/%.ref
74 $(CL65) -Osir $(CC65FLAGS) $< -o $@
75 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
76 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
78 $(WORKDIR)/%.oi.prg: %.c $(WORKDIR)/%.ref
79 $(CL65) -Oi $(CC65FLAGS) $< -o $@
80 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
81 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
83 $(WORKDIR)/%.oir.prg: %.c $(WORKDIR)/%.ref
84 $(CL65) -Oir $(CC65FLAGS) $< -o $@
85 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
86 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
88 $(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref
89 $(CL65) -Or $(CC65FLAGS) $< -o $@
90 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
91 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
95 @$(RM) $(SOURCES:.c=.o)
96 @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.out)
97 @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.ref)
98 @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.host)