Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1685 fabio 1
# Copyright (c) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
2
#
3
# Helper file defining standard targets for Shark applications.  It should
4
# be included from the application makefiles in this way (preserving much
5
# of the old behavior):
6
#
7
# # Example of Shark application makefile.
8
# S?=<source tree>
9
# B?=<build tree, if different from $(S)>
10
#
11
# SUBDIRS:= <list of subdirectories>
12
# APPS:= <list of applications>
13
#
14
# include $(S)/mk/App.mk
15
#
16
# # For each <application>:
17
# <application>:
18
#	make -f $(S)/Makefile APP=<application> \
19
#		OTHEROBJS="<list of objects>" \
20
#		OTHERINCL="<list of extra include dirs>" \
21
#		SHARKOPT="<list of options>"
22
#
23
# # End of Shark application makefile example.
24
#
25
 
26
ifndef S
27
$(error Missing Shark source tree specification)
28
endif
29
 
30
define subdir-templ
31
.PHONY: $(1)-$(2)
32
$(1)-$(2):
33
	make -C $(1) $(2)
34
endef
35
 
36
define export-if-defined
37
ifdef $(1)
38
export $(1)
39
endif
40
endef
41
 
42
to-be-exported:= S B O CROSS_COMPILE AR CC LD RM INSTALL V
43
$(foreach v, $(to-be-exported),$(eval $(call export-if-defined,$(v))))
44
 
45
foreach-subdir=$(foreach d, $(SUBDIRS),$(eval $(call subdir-templ,$d,$1)))
46
 
47
# The default target: build all subdirs and all the applications in the
48
# current directory.
49
.PHONY: all
50
all: subdirs $(APPS)
51
 
52
# Build subdirs before applications.
53
$(APPS): subdirs
54
 
55
.PHONY: subdirs
56
# Build all the subdirs
57
$(call foreach-subdir,all)
58
subdirs: $(addsuffix -all,$(SUBDIRS))
59
 
60
.PHONY: clean
61
$(call foreach-subdir,clean)
62
clean: $(addsuffix -clean,$(SUBDIRS))
63
	rm -f *.o $(APPS)
64
 
65
.PHONY: distclean
66
$(call foreach-subdir,distclean)
67
distclean: clean $(addsuffix -distclean,$(SUBDIRS))
68
	rm -f .*.deps
69