2 # makefile for the regression tests that generate output which has to be
3 # compared with reference output
11 DEL = -del /f $(subst /,\,$1)
17 CC65FLAGS := -t sim6502
18 SIM65FLAGS := -x 200000000
20 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
21 SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
23 WORKDIR := ..$S..$Stestwrk
24 DIFF := $(WORKDIR)/bdiff
27 CFLAGS := -O2 -Wall -W -Wextra -fwrapv -fno-strict-overflow
31 SOURCES := $(wildcard *.c)
32 REFS := $(SOURCES:%.c=$(WORKDIR)/%.ref)
33 TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg))
38 $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host
39 $(WORKDIR)$S$*.host > $@
41 # Some files have "K & R"-style syntax. Therefore, some forward
42 # function-declarations don't match the later function definitions.
43 # Those programs fail when fastcall is used; but, the cdecl calling convention
44 # tolerates those conflicts. Therefore, make their functions default to cdecl.
46 $(WORKDIR)/init%prg: CC65FLAGS += -Wc --all-cdecl
47 $(WORKDIR)/switch.%rg: CC65FLAGS += -Wc --all-cdecl
48 $(WORKDIR)/yacc.%rg: CC65FLAGS += -Wc --all-cdecl
49 $(WORKDIR)/yaccdbg%prg: CC65FLAGS += -Wc --all-cdecl
51 $(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref
52 $(CL65) $(CC65FLAGS) $< -o $@
53 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
54 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
56 $(WORKDIR)/%.o.prg: %.c $(WORKDIR)/%.ref
57 $(CL65) -O $(CC65FLAGS) $< -o $@
58 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
59 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
61 $(WORKDIR)/%.os.prg: %.c $(WORKDIR)/%.ref
62 $(CL65) -Os $(CC65FLAGS) $< -o $@
63 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
64 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
66 $(WORKDIR)/%.osi.prg: %.c $(WORKDIR)/%.ref
67 $(CL65) -Osi $(CC65FLAGS) $< -o $@
68 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
69 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
71 $(WORKDIR)/%.osir.prg: %.c $(WORKDIR)/%.ref
72 $(CL65) -Osir $(CC65FLAGS) $< -o $@
73 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
74 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
76 $(WORKDIR)/%.oi.prg: %.c $(WORKDIR)/%.ref
77 $(CL65) -Oi $(CC65FLAGS) $< -o $@
78 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
79 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
81 $(WORKDIR)/%.oir.prg: %.c $(WORKDIR)/%.ref
82 $(CL65) -Oir $(CC65FLAGS) $< -o $@
83 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
84 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
86 $(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref
87 $(CL65) -Or $(CC65FLAGS) $< -o $@
88 $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
89 $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
93 @$(call DEL,$(SOURCES:.c=.o))
94 @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.out))
95 @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.ref))
96 @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.host))