1#! make -f
2#============================================================================
3# Project:  RevolutionSDK Extentions - buildtools
4# File:     submakerules
5#
6# Copyright 2006 Nintendo.  All rights reserved.
7#
8# These coded instructions, statements, and computer programs contain
9# proprietary information of Nintendo of America Inc. and/or Nintendo
10# Company Ltd., and are protected by Federal copyright law.  They may
11# not be disclosed to third parties or copied or duplicated in any form,
12# in whole or in part, without the prior written consent of Nintendo.
13#============================================================================
14include $(REVOLUTION_EXT_ROOT)/build/buildtools/commondefs.rex
15
16#
17SUBDIR_FLAGS +=
18
19define MAKE_SUBDIR
20    +$(foreach DIR,$(SUBDIRS),$(MAKE) $(SUBDIR_FLAGS) -C $(DIR) $(MAKECMDGOALS) $(AND)) true
21    +$(foreach FILE,$(SUBMAKES),$(MAKE) $(SUBDIR_FLAGS) -C $(dir $(FILE)) -f $(notdir $(FILE)) $(MAKECMDGOALS) $(AND)) true
22endef
23
24define MAKE_SUBDIR_IF_EXIST
25    +$(foreach DIR,$(SUBDIRS),\
26	if [ -f $(DIR)/Makefile -o -f $(DIR)/makefile -o -f $(DIR)/GNUmakefile ]; then	\
27		$(MAKE) $(SUBDIR_FLAGS) -C $(DIR) $(MAKECMDGOALS) ;			\
28	fi $(AND)) true
29    +$(foreach FILE,$(SUBMAKES),\
30	if [ -f $(FILE) ]; then \
31		$(MAKE) $(SUBDIR_FLAGS) -C $(dir $(FILE)) -f $(notdir $(FILE)) $(MAKECMDGOALS) ; \
32	fi $(AND)) true
33endef
34
35
36PHONY_TARGETS	= build clean clobber install
37
38.PHONY: $(PHONY_TARGETS)
39
40build install:
41	@$(MAKE_SUBDIR_IF_EXIST)
42	@$(ECHO_CURDIR)
43
44clean:
45	@$(MAKE_SUBDIR_IF_EXIST)
46	@$(ECHO_CURDIR)
47ifneq	($(REX_CLEAN),)
48	@rm -rf $(REX_CLEAN)
49endif
50
51distclean clobber:
52	@$(MAKE_SUBDIR_IF_EXIST)
53	@$(ECHO_CURDIR)
54ifneq	($(REX_CLOBBER)$(REX_DISTCLEAN),)
55	@rm -rf $(REX_CLOBBER) $(REX_DISTCLEAN)
56endif
57
58#======== End of submakerules ========#
59