home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Makefiles / pb_makefiles / recursion.make < prev    next >
Text File  |  1997-03-20  |  5KB  |  130 lines

  1. #
  2. # recursion.make
  3. #
  4. # Rules for recursively invoking make to build a target in a subproject.
  5. # The format for a recursive target is target@subproject, where "target" is
  6. # one of the standard targets and "subproject" is a subproject directory of the
  7. # current project.  If you want to specify subrojects of subprojects, you
  8. # must reverse-stack them.  For example, the command-line invocation "make 
  9. # prebuild@Grandchild@Child.bproj" will run the prebuild target in the 
  10. # Grandchild subproject of the Child bundle project of the current project.
  11. #
  12. # STANDARD TARGETS
  13. #    clean, mostlyclean, all: see common.make
  14. #    prebuild: see prebuild.make
  15. #    build: see build.make
  16. #    install: see install.make
  17. #    installhdrs: see installhdrs.make
  18. #
  19. # IMPORTED VARIABLES
  20. #    OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be
  21. #      passed on the command line to recursive invocations of make.  Note that
  22. #    the values in OTHER_*FLAGS are inherited by subprojects automatically --
  23. #    you do not have to (and shouldn't) add OTHER_*FLAGS to 
  24. #    OTHER_RECURSIVE_VARIABLES. 
  25. #    T: a non-standard target that you wish to apply recursively.  For example,
  26. #    to build bar.o in the bar subproject, you would execute the command "make
  27. #    foo.o@bar T=foo.o"
  28. #
  29.  
  30. RECURSABLE_DIRS = $(ALL_SUBPROJECTS) 
  31. RECURSABLE_RULES += clean mostlyclean all prebuild build install installhdrs postinstall installsrc depend
  32. OPTIMIZABLE_RULES += prebuild build
  33.  
  34. #
  35. # Decide whether to build this particular project
  36. #
  37.  
  38. ifneq "" "$(INCLUDED_OSS)"
  39. ifeq "" "$(findstring $(OS), $(INCLUDED_OSS))"
  40. SUPPRESS_BUILD = YES
  41. endif
  42. endif
  43.  
  44. ifneq "" "$(EXCLUDED_OSS)"
  45. ifneq "" "$(findstring $(OS), $(EXCLUDED_OSS))"
  46. SUPPRESS_BUILD = YES
  47. endif
  48. endif
  49.  
  50. ifneq "" "$(INCLUDED_ARCHS)"
  51. ifeq "" "$(findstring $(ARCH), $(INCLUDED_ARCHS))"
  52. SUPPRESS_BUILD = YES
  53. endif
  54. endif
  55.  
  56. ifneq "" "$(EXCLUDED_ARCHS)"
  57. ifneq "" "$(findstring $(ARCH), $(EXCLUDED_ARCHS))"
  58. SUPPRESS_BUILD = YES
  59. endif
  60. endif
  61.  
  62. #
  63. #
  64. #
  65.  
  66. ifeq "" "$(GLOBAL_RESOURCE_DIR)"
  67. RECURSIVE_PRODUCT_DIR = $(PRODUCT_DIR)
  68. RECURSIVE_INSTALLDIR = $(INSTALLDIR)
  69. else
  70. RECURSIVE_PRODUCT_DIR = $(GLOBAL_RESOURCE_DIR)
  71. RECURSIVE_INSTALLDIR = $(subst $(PRODUCT_DIR),$(INSTALLDIR),$(GLOBAL_RESOURCE_DIR))
  72. endif
  73.  
  74. export RECURSIVE_VARIABLES += $(OTHER_RECURSIVE_VARIABLES)
  75. RECURSIVE_VARIABLE_ASSIGNMENTS = $(foreach X,$(RECURSIVE_VARIABLES), "$(X)=$($(X))")
  76.  
  77. RECURSIVE_FLAGS = "MAKEFILEDIR=$(MAKEFILEDIR)"
  78. ifeq "AGGREGATE" "$(PROJTYPE)"
  79. RECURSIVE_FLAGS += "RECURSING="
  80. else
  81. RECURSIVE_FLAGS += "RECURSING=YES"
  82. endif
  83. RECURSIVE_FLAGS += "RECURSING_ON_TARGET=$(RECURSIVE_TARGET)"
  84. RECURSIVE_FLAGS    += "RECURSIVE_ELLIPSIS=$(RECURSIVE_ELLIPSIS)..."
  85. RECURSIVE_FLAGS += "SRCROOT=`$(DOTDOTIFY) $(SRCROOT)`"
  86. RECURSIVE_FLAGS += "SYMROOT=`$(DOTDOTIFY) $(SYMROOT)`"
  87. RECURSIVE_FLAGS += "OBJROOT=`$(DOTDOTIFY) $(OBJROOT)`"
  88. RECURSIVE_FLAGS += "PRODUCT_DIR=`$(DOTDOTIFY) $(RECURSIVE_PRODUCT_DIR)`"
  89. ifneq "" "$(INSTALLDIR)"
  90. RECURSIVE_FLAGS += "INSTALLDIR=`$(DOTDOTIFY) $(RECURSIVE_INSTALLDIR)`"
  91. endif
  92. RECURSIVE_FLAGS += "OFILE_DIR=$(OFILE_DIR)/$(RECURSIVE_DIRECTORY)"
  93. RECURSIVE_FLAGS += "SFILE_DIR=$(SFILE_DIR)/$(RECURSIVE_DIRECTORY)"
  94. RECURSIVE_FLAGS += "SRCPATH=$(SRCPATH)/$(RECURSIVE_DIRECTORY)"
  95. RECURSIVE_FLAGS += $(RECURSIVE_VARIABLE_ASSIGNMENTS)
  96.  
  97. # recursive target of "clean@grandchild@child" is "clean@grandchild"
  98. RECURSIVE_TARGET = $(subst @$(RECURSIVE_DIRECTORY),,$@)
  99. RECURSIVE_DIRECTORY = $(notdir $(subst @,/,$@))
  100. RECURSIVE_TAGFILE = $(OFILE_DIR)/$(RECURSIVE_DIRECTORY).lastbuildtime.$(RECURSIVE_TARGET)
  101.  
  102. RECURSIVE_FLAGS += "IGNORE_RECURSIVE_FLAGS = NO"
  103. RECURSIVE_FLAGS += "SUBDIRECTORY_NAME=$(RECURSIVE_DIRECTORY)"
  104.  
  105. remove-timestamps:
  106.     $(FIND) $(SFILE_DIR) -name '*.lastbuildtime.*' -exec rm '{}' ';'
  107.  
  108. # The foreach statement provides exact matches for all recursable directories.
  109. # The wildcard rule matches anything else.  We cannot just use the wildcard rule
  110. # because when one target matching the wildcard is built, all other targets
  111. # matching the wildcard are declared up-to-date (a gnumake 'feature').
  112.  
  113. $(foreach RULE, $(RECURSABLE_RULES), $(addprefix $(RULE)@, $(RECURSABLE_DIRS))):
  114. ifeq "FULL" "$(RECURSION)"
  115.     $(SILENT) $(CD) $(RECURSIVE_DIRECTORY) && $(MAKE) $(RECURSIVE_TARGET) $(RECURSIVE_FLAGS)
  116. else
  117.     $(SILENT) (\
  118.     if [ -n "$(findstring $(RECURSIVE_TARGET), $(OPTIMIZABLE_RULES))" ] && $(NEWER) -s $(RECURSIVE_TAGFILE) $(RECURSIVE_DIRECTORY) ; \
  119.      then \
  120.           $(ECHO) $(RECURSIVE_ELLIPSIS)...skipping $(RECURSIVE_DIRECTORY) ; \
  121.         else \
  122.       $(CD) $(RECURSIVE_DIRECTORY) && $(MAKE) $(RECURSIVE_TARGET) $(RECURSIVE_FLAGS) ; \
  123.       $(MKDIRS) $(dir $(RECURSIVE_TAGFILE)) ; \
  124.           $(TOUCH) $(RECURSIVE_TAGFILE) ; \
  125.         fi )
  126. endif
  127.  
  128. $(addsuffix @%, $(RECURSABLE_RULES) sv show-variable se show-expression $(T)):
  129.     $(SILENT) $(CD) $(RECURSIVE_DIRECTORY) && $(MAKE) $(RECURSIVE_TARGET) $(RECURSIVE_FLAGS)
  130.