]> git.sur5r.net Git - cc65/blob - test/ref/Makefile
Merge remote-tracking branch 'upstream/master' into testsuite
[cc65] / test / ref / Makefile
1
2 # makefile for the regression tests that generate output which has to be
3 # compared with reference output
4
5 ifneq ($(shell echo),)
6   CMD_EXE := 1
7 endif
8
9 ifdef CMD_EXE
10   S := $(subst /,\,/)
11   DEL = -del /f $(subst /,\,$1)
12 else
13   S := /
14   DEL = $(RM) $1
15 endif
16
17 CC65FLAGS := -t sim6502
18 SIM65FLAGS := -x 200000000
19
20 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
21 SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
22
23 WORKDIR := ..$S..$Stestwrk
24 DIFF := $(WORKDIR)/bdiff
25
26 CC := gcc
27 CFLAGS := -O2 -Wall -W -Wextra -fwrapv -fno-strict-overflow
28
29 .PHONY: all clean
30
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))
34
35 all: $(REFS) $(TESTS)
36
37 $(WORKDIR)/%.ref: %.c
38         $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host
39         $(WORKDIR)$S$*.host > $@
40
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.
45 #
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
50
51 $(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref
52         $(CL65) $(CC65FLAGS) $< -o $@
53         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
54         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
55
56 $(WORKDIR)/%.o.prg: %.c $(WORKDIR)/%.ref
57         $(CL65) -O $(CC65FLAGS) $< -o $@
58         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
59         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
60
61 $(WORKDIR)/%.os.prg: %.c $(WORKDIR)/%.ref
62         $(CL65) -Os $(CC65FLAGS) $< -o $@
63         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
64         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
65
66 $(WORKDIR)/%.osi.prg: %.c $(WORKDIR)/%.ref
67         $(CL65) -Osi $(CC65FLAGS) $< -o $@
68         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
69         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
70
71 $(WORKDIR)/%.osir.prg: %.c $(WORKDIR)/%.ref
72         $(CL65) -Osir $(CC65FLAGS) $< -o $@
73         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
74         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
75
76 $(WORKDIR)/%.oi.prg: %.c $(WORKDIR)/%.ref
77         $(CL65) -Oi $(CC65FLAGS) $< -o $@
78         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
79         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
80
81 $(WORKDIR)/%.oir.prg: %.c $(WORKDIR)/%.ref
82         $(CL65) -Oir $(CC65FLAGS) $< -o $@
83         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
84         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
85
86 $(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref
87         $(CL65) -Or $(CC65FLAGS) $< -o $@
88         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
89         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
90
91 clean:
92         @$(call DEL,$(TESTS))
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))