home *** CD-ROM | disk | FTP | other *** search
- #
- # recursion.make
- #
- # Rules for recursively invoking make to build a target in a subproject.
- # The format for a recursive target is target@subproject, where "target" is
- # one of the standard targets and "subproject" is a subproject directory of the
- # current project. If you want to specify subrojects of subprojects, you
- # must reverse-stack them. For example, the command-line invocation "make
- # prebuild@Grandchild@Child.bproj" will run the prebuild target in the
- # Grandchild subproject of the Child bundle project of the current project.
- #
- # STANDARD TARGETS
- # clean, mostlyclean, all: see common.make
- # prebuild: see prebuild.make
- # build: see build.make
- # install: see install.make
- # installhdrs: see installhdrs.make
- #
- # IMPORTED VARIABLES
- # OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be
- # passed on the command line to recursive invocations of make. Note that
- # the values in OTHER_*FLAGS are inherited by subprojects automatically --
- # you do not have to (and shouldn't) add OTHER_*FLAGS to
- # OTHER_RECURSIVE_VARIABLES.
- # T: a non-standard target that you wish to apply recursively. For example,
- # to build bar.o in the bar subproject, you would execute the command "make
- # foo.o@bar T=foo.o"
- #
-
- RECURSABLE_DIRS = $(ALL_SUBPROJECTS)
- RECURSABLE_RULES += clean mostlyclean all prebuild build install installhdrs postinstall installsrc
- OPTIMIZABLE_RULES += prebuild build
-
- #
- # Decide whether to build this particular project
- #
-
- ifneq "" "$(INCLUDED_OSS)"
- ifeq "" "$(findstring $(OS), $(INCLUDED_OSS))"
- SUPPRESS_BUILD = YES
- endif
- endif
-
- ifneq "" "$(EXCLUDED_OSS)"
- ifneq "" "$(findstring $(OS), $(EXCLUDED_OSS))"
- SUPPRESS_BUILD = YES
- endif
- endif
-
- ifneq "" "$(INCLUDED_ARCHS)"
- ifeq "" "$(findstring $(ARCH), $(INCLUDED_ARCHS))"
- SUPPRESS_BUILD = YES
- endif
- endif
-
- ifneq "" "$(EXCLUDED_ARCHS)"
- ifneq "" "$(findstring $(ARCH), $(EXCLUDED_ARCHS))"
- SUPPRESS_BUILD = YES
- endif
- endif
-
- #
- #
- #
-
- ifeq "" "$(GLOBAL_RESOURCE_DIR)"
- RECURSIVE_PRODUCT_DIR = $(PRODUCT_DIR)
- RECURSIVE_INSTALLDIR = $(INSTALLDIR)
- else
- RECURSIVE_PRODUCT_DIR = $(GLOBAL_RESOURCE_DIR)
- RECURSIVE_INSTALLDIR = $(subst $(PRODUCT_DIR),$(INSTALLDIR),$(GLOBAL_RESOURCE_DIR))
- endif
-
- export RECURSIVE_VARIABLES += $(OTHER_RECURSIVE_VARIABLES)
- RECURSIVE_VARIABLE_ASSIGNMENTS = $(foreach X,$(RECURSIVE_VARIABLES), "$(X)=$($(X))")
-
- RECURSIVE_FLAGS = "MAKEFILEDIR=$(MAKEFILEDIR)"
- ifeq "AGGREGATE" "$(PROJTYPE)"
- RECURSIVE_FLAGS += "RECURSING="
- else
- RECURSIVE_FLAGS += "RECURSING=YES"
- endif
- RECURSIVE_FLAGS += "RECURSING_ON_TARGET=$(RECURSIVE_TARGET)"
- RECURSIVE_FLAGS += "RECURSIVE_ELLIPSIS=$(RECURSIVE_ELLIPSIS)..."
- RECURSIVE_FLAGS += "SRCROOT=`$(DOTDOTIFY) $(SRCROOT)`"
- RECURSIVE_FLAGS += "SYMROOT=`$(DOTDOTIFY) $(SYMROOT)`"
- RECURSIVE_FLAGS += "OBJROOT=`$(DOTDOTIFY) $(OBJROOT)`"
- RECURSIVE_FLAGS += "PRODUCT_DIR=`$(DOTDOTIFY) $(RECURSIVE_PRODUCT_DIR)`"
- ifneq "" "$(INSTALLDIR)"
- RECURSIVE_FLAGS += "INSTALLDIR=`$(DOTDOTIFY) $(RECURSIVE_INSTALLDIR)`"
- endif
- RECURSIVE_FLAGS += "OFILE_DIR=$(OFILE_DIR)/$(RECURSIVE_DIRECTORY)"
- RECURSIVE_FLAGS += "SFILE_DIR=$(SFILE_DIR)/$(RECURSIVE_DIRECTORY)"
- RECURSIVE_FLAGS += "SRCPATH=$(SRCPATH)/$(RECURSIVE_DIRECTORY)"
- RECURSIVE_FLAGS += $(RECURSIVE_VARIABLE_ASSIGNMENTS)
-
- # recursive target of "clean@grandchild@child" is "clean@grandchild"
- RECURSIVE_TARGET = $(subst @$(RECURSIVE_DIRECTORY),,$@)
- RECURSIVE_DIRECTORY = $(notdir $(subst @,/,$@))
- RECURSIVE_TAGFILE = $(OFILE_DIR)/$(RECURSIVE_DIRECTORY).lastbuildtime.$(RECURSIVE_TARGET)
-
- RECURSIVE_FLAGS += "SUBDIRECTORY_NAME=$(RECURSIVE_DIRECTORY)"
-
- remove-timestamps:
- $(FIND) $(SFILE_DIR) -name '*.lastbuildtime.*' -exec rm '{}' ';'
-
- # The foreach statement provides exact matches for all recursable directories.
- # The wildcard rule matches anything else. We cannot just use the wildcard rule
- # because when one target matching the wildcard is built, all other targets
- # matching the wildcard are declared up-to-date (a gnumake 'feature').
-
- $(foreach RULE, $(RECURSABLE_RULES), $(addprefix $(RULE)@, $(RECURSABLE_DIRS))):
- ifeq "FULL" "$(RECURSION)"
- $(SILENT) $(CD) $(RECURSIVE_DIRECTORY) && $(MAKE) $(RECURSIVE_TARGET) $(RECURSIVE_FLAGS)
- else
- $(SILENT) (\
- if [ -n "$(findstring $(RECURSIVE_TARGET), $(OPTIMIZABLE_RULES))" ] && $(NEWER) -s $(RECURSIVE_TAGFILE) $(RECURSIVE_DIRECTORY) ; \
- then \
- $(ECHO) $(RECURSIVE_ELLIPSIS)...skipping $(RECURSIVE_DIRECTORY) ; \
- else \
- $(CD) $(RECURSIVE_DIRECTORY) && $(MAKE) $(RECURSIVE_TARGET) $(RECURSIVE_FLAGS) ; \
- $(MKDIRS) $(dir $(RECURSIVE_TAGFILE)) ; \
- $(TOUCH) $(RECURSIVE_TAGFILE) ; \
- fi )
- endif
-
- $(addsuffix @%, $(RECURSABLE_RULES) sv show-variable se show-expression $(T)):
- $(SILENT) $(CD) $(RECURSIVE_DIRECTORY) && $(MAKE) $(RECURSIVE_TARGET) $(RECURSIVE_FLAGS)
-