Browse Source

First shot at recursive Makefile in top dir and in examples dir.

Göran Krampe 12 years ago
parent
commit
abc0ae8c8e
5 changed files with 80 additions and 5 deletions
  1. 52 0
      Makefile
  2. 23 0
      examples/Makefile
  3. 1 1
      examples/webos/eris/Makefile
  4. 2 2
      examples/webos/helloamber/Makefile
  5. 2 2
      server/Makefile

+ 52 - 0
Makefile

@@ -0,0 +1,52 @@
+# Makefile for sub directories
+AMBER = st
+SERVER = server
+EXAMPLES = examples
+
+# REST is all except AMBER
+REST = $(SERVER) $(EXAMPLES)
+
+# And these are all
+DIRS = $(AMBER) $(REST)
+
+# The sets of directories to do various things in
+BUILDDIRS = $(DIRS:%=build-%)
+EXAMPLESDIRS = $(EXAMPLES:%=build-%)
+INSTALLDIRS = $(AMBER:%=install-%)
+CLEANDIRS = $(REST:%=clean-%)
+CLEANALLDIRS = $(DIRS:%=clean-%)
+
+all: $(BUILDDIRS)
+$(DIRS): $(BUILDDIRS)
+$(BUILDDIRS):
+	$(MAKE) -C $(@:build-%=%)
+
+amber: build-st
+
+# Examples and server need Amber first
+build-server: build-st
+build-examples: build-st
+
+examples: $(EXAMPLESDIRS)
+$(EXAMPLESDIRS):
+	$(MAKE) -C $(@:build-%=%)
+
+install: $(INSTALLDIRS)
+$(INSTALLDIRS):
+	$(MAKE) -C $(@:install-%=%) install
+
+clean: $(CLEANDIRS)
+$(CLEANDIRS): 
+	$(MAKE) -C $(@:clean-%=%) clean
+
+cleanall: $(CLEANALLDIRS) 
+$(CLEANALLDIRS): 
+	$(MAKE) -C $(@:clean-%=%) clean
+
+
+.PHONY: subdirs $(DIRS)
+.PHONY: subdirs $(BUILDDIRS)
+.PHONY: subdirs $(INSTALLDIRS)
+.PHONY: subdirs $(CLEANDIRS)
+.PHONY: subdirs $(CLEANALLDIRS)
+.PHONY: all install clean

+ 23 - 0
examples/Makefile

@@ -0,0 +1,23 @@
+# Makefile for sub directories
+#
+# mindepth makes sure we do not include this Makeile
+MAKEFILES = $(shell find . -mindepth 2 -name 'Makefile')
+DIRS = $(patsubst %/Makefile, %, $(MAKEFILES))
+
+# The sets of directories to do various things in
+BUILDDIRS = $(DIRS:%=build-%)
+CLEANDIRS = $(DIRS:%=clean-%)
+
+all: $(BUILDDIRS)
+$(DIRS): $(BUILDDIRS)
+$(BUILDDIRS):
+	$(MAKE) -C $(@:build-%=%)
+
+clean: $(CLEANDIRS)
+$(CLEANDIRS):
+	$(MAKE) -C $(@:clean-%=%) clean
+
+.PHONY: subdirs $(DIRS)
+.PHONY: subdirs $(BUILDDIRS)
+.PHONY: subdirs $(CLEANDIRS)
+.PHONY: all clean

+ 1 - 1
examples/webos/eris/Makefile

@@ -22,7 +22,7 @@ $(IPK): $(FILEJS)
 
 clean:
 	rm -f $(FILEJS) $(OBJECTS) $(IPK)
-	palm-install -r $(PACKAGE)
+#	palm-install -r $(PACKAGE)
 
 install: $(IPK)
 	palm-install $(IPK)

+ 2 - 2
examples/webos/helloamber/Makefile

@@ -8,7 +8,7 @@ PACKAGE  := amber.helloamber
 VERSION  := 1.0.0
 
 # -O for Closure optimization of js code.
-FLAGS    := -O
+FLAGS    := 
 IPK      := $(PACKAGE)_$(VERSION)_all.ipk
 FILE     := Program
 SOURCES  := $(wildcard *.st)
@@ -23,7 +23,7 @@ $(IPK): $(FILEJS)
 
 clean:
 	rm -f $(FILEJS) $(OBJECTS) $(IPK)
-	palm-install -r $(PACKAGE)
+#	palm-install -r $(PACKAGE)
 
 install: $(IPK)
 	palm-install $(IPK)

+ 2 - 2
server/Makefile

@@ -1,7 +1,7 @@
-Program.js: FileServer.st
+server.js: FileServer.st
 	../bin/amberc -m FileServer FileServer.st server
 
-run: Program.js
+run: server.js
 	./server
 
 clean: