From f60af0301afed94a61036c5500934a2f5b977152 Mon Sep 17 00:00:00 2001
From: mrdudz <mrdudz@users.noreply.github.com>
Date: Thu, 15 Oct 2020 18:35:54 +0200
Subject: [PATCH] fix non working Makefiles

---
 samples/Makefile          |  3 ++-
 samples/disasm/Makefile   | 12 ++++++------
 samples/geos/Makefile     | 12 ++++++------
 samples/geos/grc/Makefile | 12 +++++++++++-
 4 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/samples/Makefile b/samples/Makefile
index e66850d35..6e89cb802 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -153,7 +153,8 @@ endif
 # --------------------------------------------------------------------------
 # Lists of subdirectories
 
-DIRLIST = tutorial
+# disasm depends on cpp
+DIRLIST = tutorial geos
 
 # --------------------------------------------------------------------------
 # Lists of executables
diff --git a/samples/disasm/Makefile b/samples/disasm/Makefile
index 61b37e314..5f19e943d 100644
--- a/samples/disasm/Makefile
+++ b/samples/disasm/Makefile
@@ -24,11 +24,11 @@ ifdef CC65_HOME
   LD = $(CC65_HOME)/bin/ld65
   DA = $(CC65_HOME)/bin/da65
 else
-  AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
-  CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
-  CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
-  LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
-  DA := $(if $(wildcard ../../../bin/da65*),../../../bin/da65,da65)
+  AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
+  CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
+  CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+  LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
+  DA := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65)
 endif
 
 CPP = cpp
@@ -39,7 +39,7 @@ DAIS = fixed.dai bank0.dai bank1.dai
 
 .SUFFIXES: .da .dai .s
 
-all: image.bin $(ASMS)
+samples: image.bin $(ASMS)
 
 $(DAIS): fixed.da
 
diff --git a/samples/geos/Makefile b/samples/geos/Makefile
index 32a28e118..cc0d52a4e 100644
--- a/samples/geos/Makefile
+++ b/samples/geos/Makefile
@@ -26,17 +26,17 @@ ifdef CC65_HOME
   LD = $(CC65_HOME)/bin/ld65
   SP = $(CC65_HOME)/bin/sp65
 else
-  AS := $(if $(wildcard ../bin/ca65*),../bin/ca65,ca65)
-  CC := $(if $(wildcard ../bin/cc65*),../bin/cc65,cc65)
-  CL := $(if $(wildcard ../bin/cl65*),../bin/cl65,cl65)
-  LD := $(if $(wildcard ../bin/ld65*),../bin/ld65,ld65)
-  SP := $(if $(wildcard ../bin/sp65*),../bin/sp65,sp65)
+  AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
+  CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
+  CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+  LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
+  SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65)
 endif 
 
 # omitted: dialog.c grphstr.c inittab.c menu.c
 
 # TODO: geosconio.cvt rmvprot.cvt
-all: bitmap-demo.cvt filesel.cvt geosver.cvt getid.cvt hello1.cvt hello2.cvt \
+samples: bitmap-demo.cvt filesel.cvt geosver.cvt getid.cvt hello1.cvt hello2.cvt \
 	overlay-demo.cvt vector-demo.cvt yesno.cvt
 
 bitmap.c: logo.pcx
diff --git a/samples/geos/grc/Makefile b/samples/geos/grc/Makefile
index 793506890..0e5eabd81 100644
--- a/samples/geos/grc/Makefile
+++ b/samples/geos/grc/Makefile
@@ -29,7 +29,16 @@ else
   GRC := $(if $(wildcard ../../../bin/grc65*),../../../bin/grc65,grc65)
 endif
 
-all: test.s vlir.cvt
+DIRLIST = grc
+
+define SUBDIR_recipe
+
+@$(MAKE) -C $(dir) --no-print-directory $@
+
+endef # SUBDIR_recipe
+
+samples: test.s vlir.cvt
+	$(foreach dir,$(DIRLIST),$(SUBDIR_recipe))
 
 test.s: test.grc
 	$(GRC) -s test.s test.grc
@@ -50,3 +59,4 @@ clean:
 	$(RM) test.s test.h
 	$(RM) vlir.s vlir.cvt vlir.c vlir.h
 	$(RM) *.o
+	$(foreach dir,$(DIRLIST),$(SUBDIR_recipe))