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