1 # makefile for the regression tests that generate output which has to be
2 # compared with reference output
10 DEL = -del /f $(subst /,\,$1)
16 CC65FLAGS := -t sim6502
17 SIM65FLAGS := -x 200000000
19 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
20 SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
22 WORKDIR := ..$S..$Stestwrk
23 DIFF := $(WORKDIR)/bdiff
26 CFLAGS := -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow
30 SOURCES := $(wildcard *.c)
31 REFS := $(SOURCES:%.c=$(WORKDIR)/%.ref)
32 TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg))
36 # "yaccdbg.c" includes "yacc.c".
37 # yaccdbg's built files must depend on both of them.
39 $(WORKDIR)/yaccdbg.ref: yacc.c
42 $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host
43 $(WORKDIR)$S$*.host > $@
45 # Some files have "K & R"-style syntax. Therefore, some forward
46 # function-declarations don't match the later function definitions.
47 # Those programs fail when fastcall is used; but, the cdecl calling convention
48 # tolerates those conflicts. Therefore, make their functions default to cdecl.
50 $(WORKDIR)/init%prg: CC65FLAGS += -Wc --all-cdecl
51 $(WORKDIR)/switch.%rg: CC65FLAGS += -Wc --all-cdecl
52 $(WORKDIR)/yacc.%rg: CC65FLAGS += -Wc --all-cdecl
53 $(WORKDIR)/yaccdbg%prg: CC65FLAGS += -Wc --all-cdecl
55 $(WORKDIR)/yaccdbg%prg: yacc.c
57 $(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref
58 $(CL65) $(CC65FLAGS) $< -o $@
59 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
60 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
62 $(WORKDIR)/%.o.prg: %.c $(WORKDIR)/%.ref
63 $(CL65) -O $(CC65FLAGS) $< -o $@
64 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
65 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
67 $(WORKDIR)/%.os.prg: %.c $(WORKDIR)/%.ref
68 $(CL65) -Os $(CC65FLAGS) $< -o $@
69 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
70 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
72 $(WORKDIR)/%.osi.prg: %.c $(WORKDIR)/%.ref
73 $(CL65) -Osi $(CC65FLAGS) $< -o $@
74 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
75 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
77 $(WORKDIR)/%.osir.prg: %.c $(WORKDIR)/%.ref
78 $(CL65) -Osir $(CC65FLAGS) $< -o $@
79 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
80 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
82 $(WORKDIR)/%.oi.prg: %.c $(WORKDIR)/%.ref
83 $(CL65) -Oi $(CC65FLAGS) $< -o $@
84 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
85 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
87 $(WORKDIR)/%.oir.prg: %.c $(WORKDIR)/%.ref
88 $(CL65) -Oir $(CC65FLAGS) $< -o $@
89 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
90 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
92 $(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref
93 $(CL65) -Or $(CC65FLAGS) $< -o $@
94 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
95 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
99 @$(call DEL,$(SOURCES:.c=.o))
100 @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.out))
101 @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.ref))
102 @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.host))