2022-02-19 11:44:20 +00:00
|
|
|
# Makefile for the assembler regression tests
|
|
|
|
|
|
|
|
ifneq ($(shell echo),)
|
|
|
|
CMD_EXE = 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef CMD_EXE
|
2022-11-05 18:41:02 +00:00
|
|
|
S = $(subst /,\,/)
|
2022-02-19 11:44:20 +00:00
|
|
|
EXE = .exe
|
|
|
|
MKDIR = mkdir $(subst /,\,$1)
|
|
|
|
RMDIR = -rmdir /q /s $(subst /,\,$1)
|
2022-11-05 18:41:02 +00:00
|
|
|
TRUE = exit 0
|
|
|
|
CAT = type $(subst /,\,$1)
|
2022-02-19 11:44:20 +00:00
|
|
|
else
|
2022-11-05 18:41:02 +00:00
|
|
|
S = /
|
2022-02-19 11:44:20 +00:00
|
|
|
EXE =
|
|
|
|
MKDIR = mkdir -p $1
|
|
|
|
RMDIR = $(RM) -r $1
|
2022-11-05 18:41:02 +00:00
|
|
|
TRUE = true
|
2022-11-09 00:07:36 +00:00
|
|
|
CAT = cat $1
|
2022-02-19 11:44:20 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef QUIET
|
2022-06-20 21:07:36 +00:00
|
|
|
# .SILENT:
|
2022-02-19 11:44:20 +00:00
|
|
|
endif
|
|
|
|
|
2022-11-05 18:41:02 +00:00
|
|
|
CA65 := $(if $(wildcard ../../../bin/ca65*),..$S..$S..$Sbin$Sca65,ca65)
|
|
|
|
LD65 := $(if $(wildcard ../../../bin/ld65*),..$S..$S..$Sbin$Sld65,ld65)
|
2022-02-19 11:44:20 +00:00
|
|
|
|
|
|
|
WORKDIR = ../../../testwrk/asm/listing
|
|
|
|
|
2022-11-05 18:41:02 +00:00
|
|
|
ISEQUAL = ..$S..$S..$Stestwrk$Sisequal$(EXE)
|
2022-02-19 11:44:20 +00:00
|
|
|
|
|
|
|
CC = gcc
|
|
|
|
CFLAGS = -O2
|
|
|
|
|
|
|
|
.PHONY: all clean
|
|
|
|
|
|
|
|
LISTING_SRC := $(wildcard *.s)
|
|
|
|
LISTING_TESTS = $(LISTING_SRC:%.s=%)
|
|
|
|
LISTING_BINS = $(LISTING_SRC:%.s=$(WORKDIR)/%.bin)
|
|
|
|
|
|
|
|
all: $(LISTING_BINS)
|
|
|
|
|
|
|
|
$(WORKDIR):
|
|
|
|
$(call MKDIR,$(WORKDIR))
|
|
|
|
|
|
|
|
$(ISEQUAL): ../../isequal.c | $(WORKDIR)
|
|
|
|
$(CC) $(CFLAGS) -o $@ $<
|
|
|
|
|
|
|
|
|
|
|
|
define LISTING_template
|
|
|
|
|
2022-06-18 21:38:18 +00:00
|
|
|
$(WORKDIR)/$1.bin: $1.s $(ISEQUAL)
|
2022-02-19 11:44:20 +00:00
|
|
|
$(if $(QUIET),echo asm/$1.bin)
|
|
|
|
|
2022-03-03 06:03:01 +00:00
|
|
|
# compile without generating listing
|
2022-06-20 14:30:51 +00:00
|
|
|
ifeq ($(wildcard control/$1.err),)
|
2022-11-12 22:12:25 +00:00
|
|
|
$(CA65) -t none -o $$(@:.bin=.o) $$< > $$(@:.bin=.err) 2> $$(@:.bin=.err2)
|
2022-06-20 14:30:51 +00:00
|
|
|
ifeq ($(wildcard control/$1.no-ld65),)
|
2022-11-12 22:12:25 +00:00
|
|
|
$(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib > $$(@:.bin=.ld65-err) 2> $$(@:.bin=.ld65-err2)
|
2022-06-18 20:22:27 +00:00
|
|
|
endif
|
|
|
|
else
|
2022-11-12 22:12:25 +00:00
|
|
|
$(CA65) -t none -o $$(@:.bin=.o) $$< > $$(@:.bin=.err) 2> $$(@:.bin=.err2) || $(TRUE)
|
2022-06-20 14:30:51 +00:00
|
|
|
ifeq ($(wildcard control/$1.no-ld65),)
|
2022-11-12 22:12:25 +00:00
|
|
|
$(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib > $$(@:.bin=.ld65-err) 2> $$(@:.bin=.ld65-err2) || $(TRUE)
|
2022-06-18 20:22:27 +00:00
|
|
|
endif
|
|
|
|
endif
|
2022-02-19 11:44:20 +00:00
|
|
|
|
2022-06-20 14:30:51 +00:00
|
|
|
ifneq ($(wildcard ref/$1.err-ref),)
|
|
|
|
$(ISEQUAL) ref/$1.err-ref $$(@:.bin=.err)
|
2022-06-18 19:04:36 +00:00
|
|
|
else
|
2022-06-18 21:38:18 +00:00
|
|
|
$(ISEQUAL) --empty $$(@:.bin=.err)
|
2022-06-16 18:57:53 +00:00
|
|
|
endif
|
|
|
|
|
2022-11-12 22:12:25 +00:00
|
|
|
ifneq ($(wildcard ref/$1.err2-ref),)
|
|
|
|
$(ISEQUAL) ref/$1.err2-ref $$(@:.bin=.err2)
|
|
|
|
else
|
|
|
|
$(ISEQUAL) --empty $$(@:.bin=.err2)
|
|
|
|
endif
|
|
|
|
|
2022-06-20 14:30:51 +00:00
|
|
|
ifneq ($(wildcard ref/$1.bin-ref),)
|
|
|
|
$(ISEQUAL) --binary ref/$1.bin-ref $$@
|
2022-02-19 11:44:20 +00:00
|
|
|
endif
|
|
|
|
|
2022-11-05 18:41:02 +00:00
|
|
|
# rem $(indfo $(CAT) $(subst /,$$S,$$$(@:.bin=.ld65-err)))
|
|
|
|
|
2022-06-20 20:19:22 +00:00
|
|
|
ifneq ($(wildcard ref/$1.ld65err-ref),)
|
2022-11-05 18:41:02 +00:00
|
|
|
@echo $(CAT) $$(@:.bin=.ld65-err)
|
|
|
|
# FIXME: somehow this refuses to work in cmd.exe
|
|
|
|
ifndef CMD_EXE
|
|
|
|
$(call CAT,$$(@:.bin=.ld65-err))
|
2022-06-20 21:13:49 +00:00
|
|
|
-diff -u ref/$1.ld65err-ref $$(@:.bin=.ld65-err)
|
2022-11-05 18:41:02 +00:00
|
|
|
endif
|
2022-06-21 20:23:10 +00:00
|
|
|
$(ISEQUAL) --wildcards ref/$1.ld65err-ref $$(@:.bin=.ld65-err)
|
2022-06-20 20:19:22 +00:00
|
|
|
else
|
|
|
|
ifneq ($(wildcard $(WORKDIR)/$1.ld65-err),)
|
|
|
|
$(ISEQUAL) --empty $$(@:.bin=.ld65-err)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2022-11-12 22:12:25 +00:00
|
|
|
ifneq ($(wildcard ref/$1.ld65err2-ref),)
|
|
|
|
@echo $(CAT) $$(@:.bin=.ld65-err2)
|
|
|
|
# FIXME: somehow this refuses to work in cmd.exe
|
|
|
|
ifndef CMD_EXE
|
|
|
|
$(call CAT,$$(@:.bin=.ld65-err2))
|
|
|
|
-diff -u ref/$1.ld65err2-ref $$(@:.bin=.ld65-err2)
|
|
|
|
endif
|
|
|
|
$(ISEQUAL) --wildcards ref/$1.ld65err2-ref $$(@:.bin=.ld65-err2)
|
|
|
|
else
|
|
|
|
ifneq ($(wildcard $(WORKDIR)/$1.ld65-err2),)
|
|
|
|
$(ISEQUAL) --empty $$(@:.bin=.ld65-err2)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2022-06-20 20:19:22 +00:00
|
|
|
# compile with listing file
|
2022-06-20 14:30:51 +00:00
|
|
|
ifeq ($(wildcard control/$1.err),)
|
2022-11-12 22:12:25 +00:00
|
|
|
$(CA65) -t none -l $$(@:.bin=.list-lst) -o $$(@:.bin=.list-o) $$< > $$(@:.bin=.list-err) 2> $$(@:.bin=.list-err2)
|
2022-06-20 14:30:51 +00:00
|
|
|
ifeq ($(wildcard control/$1.no-ld65),)
|
2022-11-12 22:12:25 +00:00
|
|
|
$(LD65) -t none -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.list-ld65-err) 2> $$(@:.bin=.list-ld65-err2)
|
2022-06-18 20:22:27 +00:00
|
|
|
endif
|
|
|
|
else
|
2022-11-12 22:12:25 +00:00
|
|
|
$(CA65) -t none -l $$(@:.bin=.list-lst) -o $$(@:.bin=.list-o) $$< > $$(@:.bin=.list-err) 2> $$(@:.bin=.list-err2) || $(TRUE)
|
2022-06-20 14:30:51 +00:00
|
|
|
ifeq ($(wildcard control/$1.no-ld65),)
|
2022-11-12 22:12:25 +00:00
|
|
|
$(LD65) -t none -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.list-ld65-err) 2> $$(@:.bin=.list-ld65-err2) || $(TRUE)
|
2022-06-18 20:22:27 +00:00
|
|
|
endif
|
|
|
|
endif
|
2022-02-19 11:44:20 +00:00
|
|
|
|
2022-06-20 14:30:51 +00:00
|
|
|
ifneq ($(wildcard ref/$1.err-ref),)
|
|
|
|
$(ISEQUAL) ref/$1.err-ref $$(@:.bin=.list-err)
|
2022-06-18 19:04:36 +00:00
|
|
|
else
|
2022-06-18 21:38:18 +00:00
|
|
|
$(ISEQUAL) --empty $$(@:.bin=.list-err)
|
2022-06-18 19:04:36 +00:00
|
|
|
endif
|
|
|
|
|
2022-06-20 14:30:51 +00:00
|
|
|
ifneq ($(wildcard ref/$1.ld65err-ref),)
|
2022-06-21 20:23:10 +00:00
|
|
|
$(ISEQUAL) --wildcards ref/$1.ld65err-ref $$(@:.bin=.list-ld65-err)
|
2022-06-18 19:04:36 +00:00
|
|
|
else
|
2022-06-20 20:19:22 +00:00
|
|
|
ifneq ($(wildcard $(WORKDIR)/$1.list-ld65-err),)
|
|
|
|
$(ISEQUAL) --empty $$(@:.bin=.list-ld65-err)
|
2022-06-16 18:57:53 +00:00
|
|
|
endif
|
2022-06-18 20:22:27 +00:00
|
|
|
endif
|
2022-06-16 18:57:53 +00:00
|
|
|
|
2022-11-12 22:12:25 +00:00
|
|
|
ifneq ($(wildcard ref/$1.err2-ref),)
|
|
|
|
$(ISEQUAL) ref/$1.err2-ref $$(@:.bin=.list-err2)
|
|
|
|
else
|
|
|
|
$(ISEQUAL) --empty $$(@:.bin=.list-err2)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(wildcard ref/$1.ld65err2-ref),)
|
|
|
|
$(ISEQUAL) --wildcards ref/$1.ld65err2-ref $$(@:.bin=.list-ld65-err2)
|
|
|
|
else
|
|
|
|
ifneq ($(wildcard $(WORKDIR)/$1.list-ld65-err2),)
|
|
|
|
$(ISEQUAL) --empty $$(@:.bin=.list-ld65-err2)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2022-03-03 06:03:01 +00:00
|
|
|
# check if the result bin is the same as without listing file
|
2022-06-20 14:30:51 +00:00
|
|
|
ifeq ($(wildcard control/$1.err),)
|
2022-11-12 22:12:25 +00:00
|
|
|
ifeq ($(wildcard control/$1.err2),)
|
2022-02-19 11:44:20 +00:00
|
|
|
$(ISEQUAL) $$@ $$(@:.bin=.list-bin)
|
2022-06-18 20:22:27 +00:00
|
|
|
endif
|
2022-11-12 22:12:25 +00:00
|
|
|
endif
|
2022-02-19 11:44:20 +00:00
|
|
|
|
2022-06-20 14:30:51 +00:00
|
|
|
ifneq ($(wildcard ref/$1.list-ref),)
|
2022-03-03 06:03:01 +00:00
|
|
|
# we have a reference file, compare that, too
|
2022-02-19 11:44:20 +00:00
|
|
|
|
2022-03-03 06:03:01 +00:00
|
|
|
# remove first line which contains a version number
|
2022-06-20 20:19:22 +00:00
|
|
|
$(ISEQUAL) --skip=1 ref/$1.list-ref $$(@:.bin=.list-lst)
|
2022-02-19 11:44:20 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
endef # LISTING_template
|
|
|
|
|
|
|
|
|
|
|
|
$(foreach listing,$(LISTING_TESTS),$(eval $(call LISTING_template,$(listing))))
|
|
|
|
|
|
|
|
|
|
|
|
$(WORKDIR)/%.o: %.s | $(WORKDIR)
|
|
|
|
$(CA65) -l $(@:.o=.lst) -o $@ $<
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@$(call RMDIR,$(WORKDIR))
|