]> git.sur5r.net Git - cc65/blob - test/asm/Makefile
Merge pull request #402 from IrgendwerA8/runtime_improvements
[cc65] / test / asm / Makefile
1 # Makefile for the assembler regression tests
2
3 ifneq ($(shell echo),)
4   CMD_EXE = 1
5 endif
6
7 ifdef CMD_EXE
8   EXE = .exe
9   MKDIR = mkdir $(subst /,\,$1)
10   RMDIR = -rmdir /s /q $(subst /,\,$1)
11   DEL = del /f $(subst /,\,$1)
12 else
13   EXE =
14   MKDIR = mkdir -p $1
15   RMDIR = $(RM) -r $1
16   DEL = $(RM) $1
17 endif
18
19 ifdef QUIET
20   .SILENT:
21 endif
22
23 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
24
25 WORKDIR = ../../testwrk/asm
26
27 DIFF = $(WORKDIR)/bdiff$(EXE)
28
29 CC = gcc
30 CFLAGS = -O2
31
32 .PHONY: all clean
33
34 OPCODE_REFS := $(wildcard *-opcodes.ref)
35 OPCODE_CPUS = $(foreach ref,$(OPCODE_REFS),$(ref:%-opcodes.ref=%))
36 OPCODE_BINS = $(foreach cpu,$(OPCODE_CPUS),$(WORKDIR)/$(cpu)-opcodes.bin)
37
38 CPUDETECT_REFS := $(wildcard *-cpudetect.ref)
39 CPUDETECT_CPUS = $(foreach ref,$(CPUDETECT_REFS),$(ref:%-cpudetect.ref=%))
40 CPUDETECT_BINS = $(foreach cpu,$(CPUDETECT_CPUS),$(WORKDIR)/$(cpu)-cpudetect.bin)
41
42 all: $(OPCODE_BINS) $(CPUDETECT_BINS)
43
44 $(WORKDIR):
45         $(call MKDIR,$(WORKDIR))
46
47 $(DIFF): ../bdiff.c | $(WORKDIR)
48         $(CC) $(CFLAGS) -o $@ $<
49
50 define OPCODE_template
51
52 $(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF)
53         $(if $(QUIET),echo asm/$1-opcodes.bin)
54         $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$<
55         $(DIFF) $$@ $1-opcodes.ref
56
57 endef # OPCODE_template
58
59 $(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu))))
60
61 define CPUDETECT_template
62
63 $(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF)
64         $(if $(QUIET),echo asm/$1-cpudetect.bin)
65         $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$<
66         $(DIFF) $$@ $1-cpudetect.ref
67
68 endef # CPUDETECT_template
69
70 $(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu))))
71
72 clean:
73         @$(call RMDIR,$(WORKDIR))
74         @$(call DEL,$(OPCODE_REFS:.ref=.o) cpudetect.o)