components/Makefile
branchs11-update
changeset 3996 20c0f21bbe1e
parent 3988 46ba69f31aed
child 4563 5d3e1ffc1ae1
--- a/components/Makefile	Thu Mar 19 14:35:58 2015 -0700
+++ b/components/Makefile	Thu Mar 19 20:44:31 2015 -0700
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
 #
 
 include ../make-rules/shared-macros.mk
@@ -31,23 +31,43 @@
 # components.mk is auto-generated by the build tools.  It populates the
 # COMPONENT_DIRS macro with a list of all directories in the workspace that
 # contain a component.
-components.mk:	# Makefile # $(WS_TOP)/components
+$(WS_MACH)/components.mk:	$(WS_MACH) # Makefile # $(WS_TOP)/components
 	@echo "Generating component list..."
 	@$(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
 		| sed -e 's;^$(shell pwd)/;COMPONENT_DIRS += ;g' >$@
 
--include components.mk
+-include $(WS_MACH)/components.mk
 
 # depends.mk is auto-generated by concatenating 'depend.mk' files in each
 # component directory.
-depends.mk:     components.mk
+$(WS_MACH)/depends.mk:     $(WS_MACH)/components.mk
 	@echo "Generating component dependencies..."
 	@cat $(shell $(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
 		| sed -e 's;^$(shell pwd)/;;g' -e 's;$$;/depend.mk;g') >$@ \
 		2>/dev/null
  
--include depends.mk
+-include $(WS_MACH)/depends.mk
 
+#
+# Walk through all of the components echoing the REQUIRED_PACKAGES for each one.
+# Pass all output through sed to drop lines with whitespace between words,
+# remove whitespace from lines, drop empty lines, and REQUIRED_PACKAGES +=
+# to the lines.  Pass that through sort -u
+#
+$(WS_MACH)/requires.mk:	$(WS_MACH)
+	@echo "Generating list of required packages to build consolidation..."
+	@$(GMAKE) component-hook \
+		COMPONENT_HOOK='@echo $$(REQUIRED_PACKAGES:%="%\\n")' | \
+		$(GSED) -e '/\S\s\S/d' -e 's/^ //g' -e '/^\s*$$/d' \
+			-e 's/^/REQUIRED_PACKAGES += /' | \
+		sort -u >$(@)
+
+system-check::	$(WS_MACH)/requires.mk
+	@$(GMAKE) -f $(WS_MAKE_RULES)/environment.mk -f $< component-environment-check
+
+system-prep::	$(WS_MACH)/requires.mk
+	@echo "Installing any missing packages..."
+	@$(GMAKE) -f $(WS_MAKE_RULES)/environment.mk -f $< component-environment-prep
 
 download:		TARGET = download
 prep:			TARGET = prep
@@ -57,9 +77,9 @@
 clean:			TARGET = clean
 clobber:		TARGET = clobber
 test:			TARGET = test
+zone-build:		TARGET = component-zone-build
 component-hook:		TARGET = component-hook
-prep build install publish test:	TEMPLATE_ZONE=$(ZONE)
-prep build install publish test:	LOG = >$(WS_LOGS)/$(@F).$(TARGET).log 2>&1
+zone-build prep build install publish test:	LOG = >$(WS_LOGS)/$(@F).$(TARGET).log 2>&1
 
 # turn off pkglint for the individual component builds.
 ifeq   ($(strip $(PKGLINT_COMPONENT)),)
@@ -75,16 +95,18 @@
 
 .DEFAULT:	publish
 
-build install publish test: $(COMPONENT_DIRS)
+zone-build build install publish test: $(COMPONENT_DIRS)
 
 COMPONENT_DIRS.nosetup =	$(COMPONENT_DIRS:%=%.nosetup)
 
-download prep:	$(COMPONENT_DIRS.nosetup)
-
+download::	$(COMPONENT_DIRS.nosetup)
+prep:		$(COMPONENT_DIRS.nosetup)
+component-environment-check::	$(COMPONENT_DIRS.nosetup)
 component-hook:	$(COMPONENT_DIRS.nosetup)
 
 clean:		$(COMPONENT_DIRS.nosetup)
-	$(RM) components.mk depends.mk .profile
+	$(RM) $(WS_MACH)/components.mk $(WS_MACH)/depends.mk \
+	      $(WS_MACH)/requires.mk $(WS_MACH)/*.p5m
 
 clobber:	$(COMPONENT_DIRS.nosetup) clean
 	@cd ../tools ; echo "clobbering tools..." ; $(GMAKE) clobber
@@ -92,9 +114,9 @@
 	    $(shell find . -name 'manifest-*.published')
 
 
-setup:	$(WS_LOGS) $(WS_REPO) tools $(WS_LINT_CACHE)
+setup:	$(WS_MACH) $(WS_LOGS) $(WS_REPO) tools $(WS_LINT_CACHE)
 
-$(WS_LOGS):
+$(WS_MACH) $(WS_LOGS):
 	$(MKDIR) $@
 
 $(WS_REPO):
@@ -123,17 +145,9 @@
 tools:
 	@cd ../tools ; echo "building tools..." ; $(GMAKE) clean setup
 
-# $(WS_COMPONENTS) is the home directory for the zone user, so create a profile
-# to pass a few things on to zone based builds
-.profile:
-	echo "PATH=$(PATH)" >>$@
-	echo "WS_TOP=$(WS_TOP)" >>$@
-	echo "export PATH WS_TOP" >>$@
-
 $(COMPONENT_DIRS):	$(WS_LOGS) setup FORCE
 	@cd $@ && echo "$(TARGET) $@" && \
-	 $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
-			 $(@:%=--component %) --make $(TARGET) $(LOG)
+	 $(BASS_O_MATIC) $(@:%=--component %) --make $(TARGET) $(LOG)
 
 # Turn userland-incorporator warnings into build failures
 INCORPORATE_WERROR ?= --Werror
@@ -142,8 +156,8 @@
 	$(PKGREPO) refresh -s $(PKG_REPO)
 	$(WS_TOOLS)/userland-incorporator --repository $(PKG_REPO) \
           --version=0.$(OS_VERSION),$(BUILD_VERSION) -p $(PUBLISHER) \
-	  -c $(CONSOLIDATION) --destdir=$(WS_LOGS) $(INCORPORATE_WERROR)
-	for incorporation in $(WS_LOGS)/*.p5m ; do \
+	  -c $(CONSOLIDATION) --destdir=$(WS_MACH) $(INCORPORATE_WERROR)
+	for incorporation in $(WS_MACH)/*.p5m ; do \
 	    $(PKGSEND) -s $(PKG_REPO) publish --fmri-in-manifest \
 	               $${incorporation} ; \
 	done
@@ -162,7 +176,6 @@
 
 $(COMPONENT_DIRS.nosetup):	$(WS_LOGS) FORCE
 	@cd $(@:%.nosetup=%) && echo "$(TARGET) $(@:%.nosetup=%)" && \
-	 $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
-			 $(@:%.nosetup=--component %) --make $(TARGET) $(LOG)
+	 $(BASS_O_MATIC) $(@:%.nosetup=--component %) --make $(TARGET) $(LOG)
 
 FORCE: