From 47bceb0eab4bd040ca9516d8c5eca8a2ca2f24d4 Mon Sep 17 00:00:00 2001 From: Greg King Date: Tue, 17 Nov 2020 13:34:22 -0500 Subject: [PATCH] Streamlined some makefiles. foreach isn't needed because make automatically iterates through lists of words when substituting patterns. --- test/asm/Makefile | 26 +++++++++++++------------- test/dasm/Makefile | 11 +++++------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/test/asm/Makefile b/test/asm/Makefile index 9b0aa582e..0cf65f9ca 100644 --- a/test/asm/Makefile +++ b/test/asm/Makefile @@ -7,7 +7,7 @@ endif ifdef CMD_EXE EXE = .exe MKDIR = mkdir $(subst /,\,$1) - RMDIR = -rmdir /s /q $(subst /,\,$1) + RMDIR = -rmdir /q /s $(subst /,\,$1) else EXE = MKDIR = mkdir -p $1 @@ -23,7 +23,7 @@ LD65 := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65) WORKDIR = ../../testwrk/asm -ISEQUAL = $(WORKDIR)/isequal$(EXE) +ISEQUAL = ../../testwrk/isequal$(EXE) CC = gcc CFLAGS = -O2 @@ -31,12 +31,12 @@ CFLAGS = -O2 .PHONY: all clean OPCODE_REFS := $(wildcard *-opcodes.ref) -OPCODE_CPUS = $(foreach ref,$(OPCODE_REFS),$(ref:%-opcodes.ref=%)) -OPCODE_BINS = $(foreach cpu,$(OPCODE_CPUS),$(WORKDIR)/$(cpu)-opcodes.bin) +OPCODE_BINS = $(OPCODE_REFS:%.ref=$(WORKDIR)/%.bin) +OPCODE_CPUS = $(OPCODE_REFS:%-opcodes.ref=%) CPUDETECT_REFS := $(wildcard *-cpudetect.ref) -CPUDETECT_CPUS = $(foreach ref,$(CPUDETECT_REFS),$(ref:%-cpudetect.ref=%)) -CPUDETECT_BINS = $(foreach cpu,$(CPUDETECT_CPUS),$(WORKDIR)/$(cpu)-cpudetect.bin) +CPUDETECT_BINS = $(CPUDETECT_REFS:%.ref=$(WORKDIR)/%.bin) +CPUDETECT_CPUS = $(CPUDETECT_REFS:%-cpudetect.ref=%) all: $(OPCODE_BINS) $(CPUDETECT_BINS) $(WORKDIR)/paramcount.o @@ -50,9 +50,9 @@ define OPCODE_template $(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(ISEQUAL) $(if $(QUIET),echo asm/$1-opcodes.bin) - $(CA65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $(WORKDIR)/$1-opcodes.o $$< - $(LD65) -t none -o $$@ $(WORKDIR)/$1-opcodes.o none.lib - $(ISEQUAL) $$@ $1-opcodes.ref + $(CA65) -t none --cpu $1 -l $$(@:.bin=.lst) -o $$(@:.bin=.o) $$< + $(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib + $(ISEQUAL) $1-opcodes.ref $$@ endef # OPCODE_template @@ -62,16 +62,16 @@ define CPUDETECT_template $(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(ISEQUAL) $(if $(QUIET),echo asm/$1-cpudetect.bin) - $(CA65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $(WORKDIR)/$1-cpudetect.o $$< - $(LD65) -t none -o $$@ $(WORKDIR)/$1-cpudetect.o none.lib - $(ISEQUAL) $$@ $1-cpudetect.ref + $(CA65) -t none --cpu $1 -l $$(@:.bin=.lst) -o $$(@:.bin=.o) $$< + $(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib + $(ISEQUAL) $1-cpudetect.ref $$@ endef # CPUDETECT_template $(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu)))) $(WORKDIR)/%.o: %.s | $(WORKDIR) - $(CA65) -l $(@:.o=.lst) -o $(WORKDIR)/$@ $< + $(CA65) -l $(@:.o=.lst) -o $@ $< clean: @$(call RMDIR,$(WORKDIR)) diff --git a/test/dasm/Makefile b/test/dasm/Makefile index dc0b57c76..542ce7d5e 100644 --- a/test/dasm/Makefile +++ b/test/dasm/Makefile @@ -7,7 +7,7 @@ endif ifdef CMD_EXE EXE = .exe MKDIR = mkdir $(subst /,\,$1) - RMDIR = -rmdir /s /q $(subst /,\,$1) + RMDIR = -rmdir /q /s $(subst /,\,$1) else EXE = MKDIR = mkdir -p $1 @@ -23,7 +23,7 @@ DA65 := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65) WORKDIR = ../../testwrk/dasm -ISEQUAL = $(WORKDIR)/isequal$(EXE) +ISEQUAL = ../../testwrk/isequal$(EXE) CC = gcc CFLAGS = -O2 @@ -33,10 +33,9 @@ START = --start-addr 0x8000 .PHONY: all clean SOURCES := $(wildcard *.s) -CPUS = $(foreach src,$(SOURCES),$(src:%-disass.s=%)) -BINS = $(foreach cpu,$(CPUS),$(WORKDIR)/$(cpu)-reass.bin) +BINS = $(SOURCES:%disass.s=$(WORKDIR)/%reass.bin) +CPUS = $(SOURCES:%-disass.s=%) -# default target defined later all: $(BINS) $(WORKDIR): @@ -56,7 +55,7 @@ $(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin $(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(ISEQUAL) $(if $(QUIET),echo dasm/$1-reass.bin) $(CL65) --cpu $1 -t none $(START) -o $$@ $$< - $(ISEQUAL) $$@ $(WORKDIR)/$1-disass.bin + $(ISEQUAL) $(WORKDIR)/$1-disass.bin $$@ endef # DISASS_template