Streamlined some makefiles.

foreach isn't needed because make automatically iterates through lists of words when substituting patterns.
This commit is contained in:
Greg King 2020-11-17 13:34:22 -05:00
parent 2ffb6af5d9
commit 47bceb0eab
2 changed files with 18 additions and 19 deletions

View File

@ -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))

View File

@ -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