]> git.sur5r.net Git - cc65/blob - test/ref/Makefile
Added a missing -O configuration.
[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   EXE = .exe
11   NULLDEV = nul:
12   MKDIR = mkdir $(subst /,\,$1)
13   RMDIR = -rmdir /s /q $(subst /,\,$1)
14   DEL = del /f $(subst /,\,$1)
15 else
16   S = /
17   EXE =
18   NULLDEV = /dev/null
19   MKDIR = mkdir -p $1
20   RMDIR = $(RM) -r $1
21   DEL = $(RM) $1
22 endif
23
24 ifdef QUIET
25   .SILENT:
26   NULLERR = 2>$(NULLDEV)
27 endif
28
29 SIM65FLAGS = -x 200000000
30
31 CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
32 SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
33
34 WORKDIR = ..$S..$Stestwrk$Sref
35
36 OPTIONS = g O Os Osi Osir Osr Oi Oir Or
37
38 DIFF = $(WORKDIR)$Sbdiff$(EXE)
39
40 CC = gcc
41 CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow
42
43 .PHONY: all clean
44
45 SOURCES := $(wildcard *.c)
46 REFS = $(SOURCES:%.c=$(WORKDIR)/%.ref)
47 TESTS  = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg))
48 TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg))
49
50 all: $(REFS) $(TESTS)
51
52 $(WORKDIR):
53         $(call MKDIR,$(WORKDIR))
54
55 $(WORKDIR)/%.ref: %.c | $(WORKDIR)
56         $(if $(QUIET),echo ref/$*.host)
57         $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(NULLERR)
58         $(WORKDIR)$S$*.host > $@
59
60 $(DIFF): ../bdiff.c | $(WORKDIR)
61         $(CC) $(CFLAGS) -o $@ $<
62
63 # Some files have "K & R"-style syntax.  Therefore, some forward
64 # function-declarations don't match the later function definitions.
65 # Those programs fail when fastcall is used; but, the cdecl calling convention
66 # tolerates those conflicts.  Therefore, make their functions default to cdecl.
67 #
68 $(WORKDIR)/init.%.prg   \
69 $(WORKDIR)/switch.%.prg \
70 $(WORKDIR)/yacc.%.prg   \
71 $(WORKDIR)/yaccdbg.%.prg: CC65FLAGS += -Wc --all-cdecl
72
73 # "yaccdbg.c" includes "yacc.c".
74 # yaccdbg's built files must depend on both of them.
75 #
76 $(WORKDIR)/yaccdbg.ref:   yacc.c
77 $(WORKDIR)/yaccdbg.%.prg: yacc.c
78
79 define PRG_template
80
81 $(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(DIFF)
82         $(if $(QUIET),echo ref/$$*.$1.$2.prg)
83         $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
84         $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.out
85         $(DIFF) $(WORKDIR)/$$*.out $(WORKDIR)/$$*.ref
86
87 endef # PRG_template
88
89 $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502)))
90 $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
91
92 clean:
93         @$(call RMDIR,$(WORKDIR))
94         @$(call DEL,$(SOURCES:.c=.o))