isequal: Add options for better handling

--binary: handled binary files
--empty:  check if file is empty

--skipleft=<n>: Skip <n> lines at the start of the left (first) file
--skipright=<n>: Skip <n> lines at the start of the right (second) file

Note that --binary, --empty and one or both of --skipXXX are mutual
exclusive; that is, you cannot specify more than one of them at the same
time, or the behaviour will be unpredictable.
This commit is contained in:
Spiro Trikaliotis
2022-06-18 23:38:18 +02:00
parent 297a11fcec
commit 1446b7dcc3
2 changed files with 149 additions and 22 deletions

View File

@@ -43,12 +43,9 @@ $(ISEQUAL): ../../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $<
$(WORKDIR)/_empty:
touch $@
define LISTING_template
$(WORKDIR)/$1.bin: $1.s $(ISEQUAL) $(WORKDIR)/_empty
$(WORKDIR)/$1.bin: $1.s $(ISEQUAL)
$(if $(QUIET),echo asm/$1.bin)
# compile without generating listing
@@ -67,20 +64,20 @@ endif
ifneq ($(wildcard $1.err-ref),)
$(ISEQUAL) $1.err-ref $$(@:.bin=.err)
else
$(ISEQUAL) $(WORKDIR)/_empty $$(@:.bin=.err)
$(ISEQUAL) --empty $$(@:.bin=.err)
endif
ifneq ($(wildcard $1.bin-ref),)
$(ISEQUAL) $1.bin-ref $$@
$(ISEQUAL) --binary $1.bin-ref $$@
endif
ifeq ($(wildcard $1.err),)
$(CA65) -t none -l $$(@:.bin=.list.orig) -o $$(@:.bin=.list-o) $$< > $$(@:.bin=.list-err) 2>&1
$(CA65) -t none -l $$(@:.bin=.lst) -o $$(@:.bin=.list-o) $$< > $$(@:.bin=.list-err) 2>&1
ifeq ($(wildcard $1.no-ld65),)
$(LD65) -t none -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.ld65-err) 2>&1
endif
else
$(CA65) -t none -l $$(@:.bin=.list.orig) -o $$(@:.bin=.list-o) $$< > $$(@:.bin=.list-err) 2>&1 || true
$(CA65) -t none -l $$(@:.bin=.lst) -o $$(@:.bin=.list-o) $$< > $$(@:.bin=.list-err) 2>&1 || true
ifeq ($(wildcard $1.no-ld65),)
$(LD65) -t none -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.ld65-err) 2>&1 || true
endif
@@ -89,14 +86,14 @@ endif
ifneq ($(wildcard $1.err-ref),)
$(ISEQUAL) $1.err-ref $$(@:.bin=.list-err)
else
$(ISEQUAL) $(WORKDIR)/_empty $$(@:.bin=.list-err)
$(ISEQUAL) --empty $$(@:.bin=.list-err)
endif
ifneq ($(wildcard $(WORKDIR)/$1.ld65-err),)
ifneq ($(wildcard $1.ld65err-ref),)
$(ISEQUAL) $1.ld65err-ref $$(@:.bin=.ld65-err)
else
$(ISEQUAL) $(WORKDIR)/_empty $$(@:.bin=.ld65-err)
$(ISEQUAL) --empty $$(@:.bin=.ld65-err)
endif
endif
@@ -109,8 +106,7 @@ ifneq ($(wildcard $1.list-ref),)
# we have a reference file, compare that, too
# remove first line which contains a version number
tail -n +2 $$(@:.bin=.list.orig) > $$(@:.bin=.lst)
$(ISEQUAL) $1.list-ref $$(@:.bin=.lst)
$(ISEQUAL) --skipright=1 $1.list-ref $$(@:.bin=.lst)
endif
endef # LISTING_template