1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-06 15:06:07 +00:00
cc65/test/asm/Makefile

75 lines
1.7 KiB
Makefile
Raw Normal View History

2017-03-19 16:48:12 +00:00
# Makefile for the assembler regression tests
2017-03-19 16:48:12 +00:00
ifneq ($(shell echo),)
CMD_EXE = 1
endif
2017-03-19 16:48:12 +00:00
ifdef CMD_EXE
EXE = .exe
MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else
EXE =
MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif
ifdef QUIET
.SILENT:
endif
2017-03-19 16:48:12 +00:00
CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
2017-03-19 16:48:12 +00:00
WORKDIR = ../../testwrk/asm
2017-03-19 16:48:12 +00:00
DIFF = $(WORKDIR)/bdiff$(EXE)
2017-03-19 16:48:12 +00:00
CC = gcc
CFLAGS = -O2
2017-03-19 16:48:12 +00:00
.PHONY: all clean
2017-03-19 16:48:12 +00:00
OPCODE_REFS := $(wildcard *-opcodes.ref)
OPCODE_CPUS = $(foreach ref,$(OPCODE_REFS),$(ref:%-opcodes.ref=%))
OPCODE_BINS = $(foreach cpu,$(OPCODE_CPUS),$(WORKDIR)/$(cpu)-opcodes.bin)
2017-03-19 16:48:12 +00:00
CPUDETECT_REFS := $(wildcard *-cpudetect.ref)
CPUDETECT_CPUS = $(foreach ref,$(CPUDETECT_REFS),$(ref:%-cpudetect.ref=%))
CPUDETECT_BINS = $(foreach cpu,$(CPUDETECT_CPUS),$(WORKDIR)/$(cpu)-cpudetect.bin)
2017-03-19 16:48:12 +00:00
all: $(OPCODE_BINS) $(CPUDETECT_BINS)
2017-03-19 16:48:12 +00:00
$(WORKDIR):
$(call MKDIR,$(WORKDIR))
$(DIFF): ../bdiff.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $<
define OPCODE_template
$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF)
$(if $(QUIET),echo asm/$1-opcodes.bin)
2017-03-19 16:48:12 +00:00
$(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$<
$(DIFF) $$@ $1-opcodes.ref
endef # OPCODE_template
$(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu))))
define CPUDETECT_template
$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF)
$(if $(QUIET),echo asm/$1-cpudetect.bin)
2017-03-19 16:48:12 +00:00
$(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$<
$(DIFF) $$@ $1-cpudetect.ref
endef # CPUDETECT_template
$(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu))))
clean:
@$(call RMDIR,$(WORKDIR))
@$(call DEL,$(OPCODE_REFS:.ref=.o) cpudetect.o)