]> git.sur5r.net Git - cc65/blob - test/ref/Makefile
Merge pull request #162 from greg-king5/fastcall
[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 CC65FLAGS := -t sim6502
10 SIM65FLAGS := -x 200000000
11
12 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
13 SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
14
15 ifdef CMD_EXE
16 RM := del /f
17 else
18 RM := rm -f
19 endif
20
21 WORKDIR := ../../testwrk
22
23 DIFF := $(WORKDIR)/bdiff
24
25 CFLAGS := -O2 -Wall -W -Wextra -fwrapv -fno-strict-overflow
26
27 .PHONY: all clean
28
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))
32
33 all: $(REFS) $(TESTS)
34
35 $(WORKDIR)/%.ref: %.c
36         $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host
37         $(WORKDIR)/$*.host > $@
38
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.
43 #
44 $(WORKDIR)/init%prg: CC65FLAGS += -Wc --all-cdecl
45 $(WORKDIR)/switch.%rg: CC65FLAGS += -Wc --all-cdecl
46
47 # Also, yacc.c does some things that fail when stack operations are optimized.
48 # Therefore, don't optimize them.
49 #
50 $(WORKDIR)/yacc.%rg: CC65FLAGS += -Wc --all-cdecl,--disable-opt,OptStackOps
51 $(WORKDIR)/yaccdbg%prg: CC65FLAGS += -Wc --all-cdecl,--disable-opt,OptStackOps
52
53 $(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref
54         $(CL65) $(CC65FLAGS) $< -o $@
55         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
56         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
57
58 $(WORKDIR)/%.o.prg: %.c $(WORKDIR)/%.ref
59         $(CL65) -O $(CC65FLAGS) $< -o $@
60         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
61         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
62
63 $(WORKDIR)/%.os.prg: %.c $(WORKDIR)/%.ref
64         $(CL65) -Os $(CC65FLAGS) $< -o $@
65         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
66         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
67
68 $(WORKDIR)/%.osi.prg: %.c $(WORKDIR)/%.ref
69         $(CL65) -Osi $(CC65FLAGS) $< -o $@
70         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
71         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
72
73 $(WORKDIR)/%.osir.prg: %.c $(WORKDIR)/%.ref
74         $(CL65) -Osir $(CC65FLAGS) $< -o $@
75         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
76         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
77
78 $(WORKDIR)/%.oi.prg: %.c $(WORKDIR)/%.ref
79         $(CL65) -Oi $(CC65FLAGS) $< -o $@
80         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
81         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
82
83 $(WORKDIR)/%.oir.prg: %.c $(WORKDIR)/%.ref
84         $(CL65) -Oir $(CC65FLAGS) $< -o $@
85         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
86         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
87
88 $(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref
89         $(CL65) -Or $(CC65FLAGS) $< -o $@
90         $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
91         $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
92
93 clean:
94         @$(RM) $(TESTS)
95         @$(RM) $(SOURCES:.c=.o)
96         @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.out)
97         @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.ref)
98         @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.host)