From 9bd11f161f2ebcf5e65690489a6f26ef27beb3bb Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Sat, 27 Jun 2015 00:03:45 +0200
Subject: [PATCH] Made test Makefiles work with CMD.EXE
---
test/Makefile | 20 +++++++++++---------
test/err/Makefile | 34 ++++++++++++++++++----------------
test/misc/Makefile | 29 ++++++++++++++++-------------
test/ref/Makefile | 32 +++++++++++++++++---------------
test/val/Makefile | 16 ++++++++--------
5 files changed, 70 insertions(+), 61 deletions(-)
diff --git a/test/Makefile b/test/Makefile
index 27f7ff456..ddeccc5ee 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -10,25 +10,27 @@ ifneq ($(shell echo),)
endif
ifdef CMD_EXE
- RM := del /f
EXE := .exe
- MKDIR := mkdir
- RMDIR := rmdir
+ RM = del /f $(subst /,\,$1)
+ MKDIR = mkdir $(subst /,\,$1)
+ RMDIR = rmdir /s /q $(subst /,\,$1)
else
- RM := rm -f
EXE :=
- MKDIR := mkdir -p
- RMDIR := rmdir
+ RM = $(RM) $1
+ MKDIR = mkdir $1
+ RMDIR = rmdir $1
endif
WORKDIR := ../testwrk
+CC := gcc
+
.PHONY: all dotests continue mostly-clean clean
all: dotests
$(WORKDIR):
- $(MKDIR) $(WORKDIR)
+ $(call MKDIR,$(WORKDIR))
$(WORKDIR)/bdiff$(EXE): bdiff.c | $(WORKDIR)
$(CC) -O2 -o $@ $<
@@ -50,5 +52,5 @@ mostly-clean:
@$(MAKE) -C misc clean
clean: mostly-clean
- $(RM) $(WORKDIR)/bdiff$(EXE)
- $(RMDIR) $(WORKDIR)
+ -@$(call RM,$(WORKDIR)/bdiff$(EXE))
+ -$(call RMDIR,$(WORKDIR))
diff --git a/test/err/Makefile b/test/err/Makefile
index 4e12323fd..d72978427 100644
--- a/test/err/Makefile
+++ b/test/err/Makefile
@@ -5,16 +5,18 @@ ifneq ($(shell echo),)
CMD_EXE := 1
endif
-CC65FLAGS := -t sim6502
-
-CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
-
ifdef CMD_EXE
-RM := del /f
+ NOT := - # Hack
+ RM = del /f $(subst /,\,$1)
else
-RM := rm -f
+ NOT := !
+ RM = $(RM) $1
endif
+CC65FLAGS := -t sim6502
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+
WORKDIR := ../../testwrk
.PHONY: all clean
@@ -25,22 +27,22 @@ TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=
all: $(TESTS)
$(WORKDIR)/%.prg: %.c
- ! $(CL65) $(CC65FLAGS) $< -o $@
+ $(NOT) $(CL65) $(CC65FLAGS) $< -o $@
$(WORKDIR)/%.o.prg: %.c
- ! $(CL65) -O $(CC65FLAGS) $< -o $@
+ $(NOT) $(CL65) -O $(CC65FLAGS) $< -o $@
$(WORKDIR)/%.os.prg: %.c
- ! $(CL65) -Os $(CC65FLAGS) $< -o $@
+ $(NOT) $(CL65) -Os $(CC65FLAGS) $< -o $@
$(WORKDIR)/%.osi.prg: %.c
- ! $(CL65) -Osi $(CC65FLAGS) $< -o $@
+ $(NOT) $(CL65) -Osi $(CC65FLAGS) $< -o $@
$(WORKDIR)/%.osir.prg: %.c
- ! $(CL65) -Osir $(CC65FLAGS) $< -o $@
+ $(NOT) $(CL65) -Osir $(CC65FLAGS) $< -o $@
$(WORKDIR)/%.oi.prg: %.c
- ! $(CL65) -Oi $(CC65FLAGS) $< -o $@
+ $(NOT) $(CL65) -Oi $(CC65FLAGS) $< -o $@
$(WORKDIR)/%.oir.prg: %.c
- ! $(CL65) -Oir $(CC65FLAGS) $< -o $@
+ $(NOT) $(CL65) -Oir $(CC65FLAGS) $< -o $@
$(WORKDIR)/%.or.prg: %.c
- ! $(CL65) -Or $(CC65FLAGS) $< -o $@
+ $(NOT) $(CL65) -Or $(CC65FLAGS) $< -o $@
clean:
- @$(RM) $(TESTS)
- @$(RM) $(SOURCES:.c=.o)
+ -@$(call RM,$(TESTS))
+ -@$(call RM,$(SOURCES:.c=.o))
diff --git a/test/misc/Makefile b/test/misc/Makefile
index b04321c33..a1b1d72ca 100644
--- a/test/misc/Makefile
+++ b/test/misc/Makefile
@@ -5,20 +5,23 @@ ifneq ($(shell echo),)
CMD_EXE := 1
endif
-CC65FLAGS := -t sim6502
-SIM65FLAGS := -x 200000000
-
-CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
-SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
-
ifdef CMD_EXE
-RM := del /f
+ S := $(subst /,\,/)
+ NOT := - # Hack
+ RM = del /f $(subst /,\,$1)
else
-RM := rm -f
+ S := /
+ NOT := !
+ RM = $(RM) $1
endif
-WORKDIR := ../../testwrk
+CC65FLAGS := -t sim6502
+SIM65FLAGS := -x 200000000
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
+WORKDIR := ..$S..$Stestwrk
DIFF := $(WORKDIR)/bdiff
.PHONY: all clean
@@ -31,7 +34,7 @@ all: $(TESTS)
# should compile, but then hangs in an endless loop
$(WORKDIR)/endless%prg: endless.c
$(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
- ! $(SIM65) $(SIM65FLAGS) $@
+ $(NOT) $(SIM65) $(SIM65FLAGS) $@
# these need reference data that can't be generated by a host-compiled program,
# in a useful way
@@ -51,6 +54,6 @@ $(WORKDIR)/sitest%prg: sitest.c
# -$(SIM65) $(SIM65FLAGS) $@
clean:
- @$(RM) $(TESTS)
- @$(RM) $(SOURCES:.c=.o)
- @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.out)
+ -@$(call RM,$(TESTS))
+ -@$(call RM,$(SOURCES:.c=.o))
+ -@$(call RM,$(SOURCES:%.c=$(WORKDIR)/%.out))
diff --git a/test/ref/Makefile b/test/ref/Makefile
index dbe0b0f75..4d6735099 100644
--- a/test/ref/Makefile
+++ b/test/ref/Makefile
@@ -6,22 +6,24 @@ ifneq ($(shell echo),)
CMD_EXE := 1
endif
-CC65FLAGS := -t sim6502
-SIM65FLAGS := -x 200000000
-
-CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
-SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
-
ifdef CMD_EXE
-RM := del /f
+ S := $(subst /,\,/)
+ RM = del /f $(subst /,\,$1)
else
-RM := rm -f
+ S := /
+ RM = $(RM) $1
endif
-WORKDIR := ../../testwrk
+CC65FLAGS := -t sim6502
+SIM65FLAGS := -x 200000000
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
+WORKDIR := ..$S..$Stestwrk
DIFF := $(WORKDIR)/bdiff
+CC := gcc
CFLAGS := -O2 -Wall -W -Wextra -fwrapv -fno-strict-overflow
.PHONY: all clean
@@ -34,7 +36,7 @@ all: $(REFS) $(TESTS)
$(WORKDIR)/%.ref: %.c
$(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host
- $(WORKDIR)/$*.host > $@
+ $(WORKDIR)$S$*.host > $@
# Some files have "K & R"-style syntax. Therefore, some forward
# function-declarations don't match the later function definitions.
@@ -91,8 +93,8 @@ $(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref
$(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
clean:
- @$(RM) $(TESTS)
- @$(RM) $(SOURCES:.c=.o)
- @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.out)
- @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.ref)
- @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.host)
+ -@$(call RM,$(TESTS))
+ -@$(call RM,$(SOURCES:.c=.o))
+ -@$(call RM,$(SOURCES:%.c=$(WORKDIR)/%.out))
+ -@$(call RM,$(SOURCES:%.c=$(WORKDIR)/%.ref))
+ -@$(call RM,$(SOURCES:%.c=$(WORKDIR)/%.host))
diff --git a/test/val/Makefile b/test/val/Makefile
index b2a2481b4..4392fa323 100644
--- a/test/val/Makefile
+++ b/test/val/Makefile
@@ -5,18 +5,18 @@ ifneq ($(shell echo),)
CMD_EXE := 1
endif
+ifdef CMD_EXE
+ RM = del /f $(subst /,\,$1)
+else
+ RM = $(RM) $1
+endif
+
CC65FLAGS := -t sim6502
SIM65FLAGS := -x 200000000
CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
-ifdef CMD_EXE
-RM := del /f
-else
-RM := rm -f
-endif
-
WORKDIR := ../../testwrk
.PHONY: all clean
@@ -66,5 +66,5 @@ $(WORKDIR)/%.or.prg: %.c
$(SIM65) $(SIM65FLAGS) $@
clean:
- @$(RM) $(TESTS)
- @$(RM) $(SOURCES:.c=.o)
+ -@$(call RM,$(TESTS))
+ -@$(call RM,$(SOURCES:.c=.o))
--
2.39.5