From 7ba4679a35a8b7c3b814ba955a6414eeee8f6412 Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Tue, 14 May 2013 17:26:33 +0200
Subject: [PATCH] Makefile cleanup

---
 Makefile            | 33 ++++++++++++++++++++++++++-------
 examples/Makefile   |  8 ++++++++
 lib/Makefile        |  3 +++
 lib/csharp/Makefile |  2 +-
 test/Makefile       |  4 +++-
 5 files changed, 41 insertions(+), 9 deletions(-)
 create mode 100644 examples/Makefile

diff --git a/Makefile b/Makefile
index 8b55332..4bb6ec7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,34 @@
+SUBDIRS=compiler lib examples test
 export LABCOMM_JAR=$(shell pwd)/compiler/labComm.jar
 export LABCOMM=java -jar $(LABCOMM_JAR) 
 
-all: compiler
-	$(MAKE) -C lib 
-	$(MAKE) -C lib/c run-test
+all: $(SUBDIRS:%=make-%)
 
-.PHONY: compiler
-compiler:
+.PHONY: make-compiler
+make-compiler:
 	cd compiler ; ant jar
 
+.PHONY: make-%
+make-%:
+	$(MAKE) -C $* -e 
 
 .PHONY: test
-test:
-	$(MAKE) -C test -e
+test: $(SUBDIRS:%=test-%)
+
+.PHONY: test-compiler
+test-compiler:
+
+.PHONY: test-%
+test-%:
+	$(MAKE) -C $* -e test
+
+.PHONY: clean
+clean: $(SUBDIRS:%=clean-%)
+
+.PHONY: clean-compiler
+clean-compiler:
+	cd compiler ; ant clean
+
+.PHONY: clean-%
+clean-%:
+	$(MAKE) -C $* -e clean
diff --git a/examples/Makefile b/examples/Makefile
new file mode 100644
index 0000000..a8a26d7
--- /dev/null
+++ b/examples/Makefile
@@ -0,0 +1,8 @@
+all:
+	echo To be done...
+
+test:
+	echo To be done...
+
+clean:
+	echo To be done...
diff --git a/lib/Makefile b/lib/Makefile
index 3fa0e1f..fd00fcf 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -3,6 +3,9 @@ all:
 	cd csharp ; make
 	cd java ; make
 
+test:
+	$(MAKE) -C c -e run-test
+
 clean:
 	cd c ; make clean
 	cd csharp ; make clean
diff --git a/lib/csharp/Makefile b/lib/csharp/Makefile
index 5ea79f9..9a7d581 100644
--- a/lib/csharp/Makefile
+++ b/lib/csharp/Makefile
@@ -16,4 +16,4 @@ labcomm.dll: $(MODULES:%=se/lth/control/labcomm/%.cs) Makefile
 	mcs -out:$@ -target:library $(filter %.cs, $^)
 
 clean:
-	rm labcomm.dll
+	rm -f labcomm.dll
diff --git a/test/Makefile b/test/Makefile
index 3ada019..cc1248f 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -2,7 +2,9 @@ TESTS=basic simple nested
 LABCOMM_JAR=../compiler/labComm.jar
 LABCOMM=java -jar $(LABCOMM_JAR) 
 
-all:	$(TESTS:%=test_%)
+all:	
+
+test: $(TESTS:%=test_%)
 #	PYTHONPATH=../lib/python \
 #		./test_encoder_decoder.py --labcomm="$(LABCOMM)" basic.lc
 
-- 
GitLab