1 # Makefile for the regression tests that generate output which has to be
2 # compared with reference output
11 MKDIR = mkdir $(subst /,\,$1)
12 RMDIR = -rmdir /s /q $(subst /,\,$1)
13 DEL = del /f $(subst /,\,$1)
22 CC65FLAGS = -t sim6502
23 SIM65FLAGS = -x 200000000
25 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
26 SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
28 WORKDIR = ..$S..$Stestwrk$Sref
30 OPTIONS = g O Os Osi Osir Oi Oir Or
32 DIFF = $(WORKDIR)$Sbdiff$(EXE)
35 CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow
39 SOURCES := $(wildcard *.c)
40 REFS = $(SOURCES:%.c=$(WORKDIR)/%.ref)
41 TESTS = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).prg))
46 $(call MKDIR,$(WORKDIR))
48 $(WORKDIR)/%.ref: %.c | $(WORKDIR)
49 $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $<
50 $(WORKDIR)$S$*.host > $@
52 $(DIFF): ../bdiff.c | $(WORKDIR)
53 $(CC) $(CFLAGS) -o $@ $<
55 # Some files have "K & R"-style syntax. Therefore, some forward
56 # function-declarations don't match the later function definitions.
57 # Those programs fail when fastcall is used; but, the cdecl calling convention
58 # tolerates those conflicts. Therefore, make their functions default to cdecl.
60 $(WORKDIR)/init.%.prg \
61 $(WORKDIR)/switch.%.prg \
62 $(WORKDIR)/yacc.%.prg \
63 $(WORKDIR)/yaccdbg.%.prg: CC65FLAGS += -Wc --all-cdecl
65 # "yaccdbg.c" includes "yacc.c".
66 # yaccdbg's built files must depend on both of them.
68 $(WORKDIR)/yaccdbg.ref: yacc.c
69 $(WORKDIR)/yaccdbg.%.prg: yacc.c
73 $(WORKDIR)/%.$1.prg: %.c $(WORKDIR)/%.ref $(DIFF)
74 $(CL65) $$(CC65FLAGS) -$1 -o $$@ $$<
75 $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.out
76 $(DIFF) $(WORKDIR)/$$*.out $(WORKDIR)/$$*.ref
80 $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option))))
83 @$(call RMDIR,$(WORKDIR))
84 @$(call DEL,$(SOURCES:.c=.o))