From fd208fdf0b6f968ba7491dcec1f53be71af08abd Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Sat, 3 Oct 2020 19:35:23 +0200
Subject: [PATCH] - Added support for calling subdir Makefiles for the make
targets 'samples' and 'clean'. - Adjusted the 'tutorial' Makefile to actually
work as expected.
Note: The 'disasm' and 'geos' Makefiles don't seem to work so they are not called as of now.
---
samples/Makefile | 13 +++++++++++++
samples/tutorial/Makefile | 14 +++++++-------
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/samples/Makefile b/samples/Makefile
index 267dc5235..2d1e25475 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -150,6 +150,11 @@ else
$(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -t $(SYS) -m $@.map $^ $(SYS).lib
endif
+# --------------------------------------------------------------------------
+# Lists of subdirectories
+
+DIRLIST = tutorial
+
# --------------------------------------------------------------------------
# Lists of executables
@@ -209,10 +214,17 @@ ifndef EXELIST_$(SYS)
EXELIST_$(SYS) := ${patsubst %.c,%,$(wildcard *.c)}
endif
+define SUBDIR_recipe
+
+@$(MAKE) -C $(dir) --no-print-directory $@
+
+endef # SUBDIR_recipe
+
# --------------------------------------------------------------------------
# Rules to make the binaries and the disk
samples: $(EXELIST_$(SYS))
+ $(foreach dir,$(DIRLIST),$(SUBDIR_recipe))
disk: $(DISK_$(SYS))
@@ -338,3 +350,4 @@ mostlyclean:
clean: mostlyclean
@$(DEL) $(EXELIST_$(SYS)) $(DISK_$(SYS)) 2>$(NULLDEV)
@$(DEL) multdemo.? ovrldemo.? 2>$(NULLDEV)
+ $(foreach dir,$(DIRLIST),$(SUBDIR_recipe))
diff --git a/samples/tutorial/Makefile b/samples/tutorial/Makefile
index 8ed91697f..2c4bcb988 100644
--- a/samples/tutorial/Makefile
+++ b/samples/tutorial/Makefile
@@ -25,16 +25,16 @@ ifdef CC65_HOME
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
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)
+ 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)
endif
-all: hello
+samples: hello
hello: hello.c text.s
$(CL) -t $(SYS) -o hello hello.c text.s
-
+
clean:
- $(RM) hello
+ @$(DEL) hello 2>$(NULLDEV)