1 # Makefile for the regression tests that generate output which has to be
2 # compared with reference output
12 MKDIR = mkdir $(subst /,\,$1)
13 RMDIR = -rmdir /s /q $(subst /,\,$1)
14 DEL = del /f $(subst /,\,$1)
26 NULLERR = 2>$(NULLDEV)
29 SIM65FLAGS = -x 200000000
31 CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
32 SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
34 WORKDIR = ..$S..$Stestwrk$Sref
36 OPTIONS = g O Os Osi Osir Osr Oi Oir Or
38 DIFF = $(WORKDIR)$Sbdiff$(EXE)
41 CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow
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))
53 $(call MKDIR,$(WORKDIR))
55 $(WORKDIR)/%.ref: %.c | $(WORKDIR)
56 $(if $(QUIET),echo ref/$*.host)
57 $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(NULLERR)
58 $(WORKDIR)$S$*.host > $@
60 $(DIFF): ../bdiff.c | $(WORKDIR)
61 $(CC) $(CFLAGS) -o $@ $<
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.
68 $(WORKDIR)/init.%.prg \
69 $(WORKDIR)/switch.%.prg \
70 $(WORKDIR)/yacc.%.prg \
71 $(WORKDIR)/yaccdbg.%.prg: CC65FLAGS += -Wc --all-cdecl
73 # "yaccdbg.c" includes "yacc.c".
74 # yaccdbg's built files must depend on both of them.
76 $(WORKDIR)/yaccdbg.ref: yacc.c
77 $(WORKDIR)/yaccdbg.%.prg: yacc.c
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
89 $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502)))
90 $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
93 @$(call RMDIR,$(WORKDIR))
94 @$(call DEL,$(SOURCES:.c=.o))