components/Makefile
branchs11-update
changeset 3996 20c0f21bbe1e
parent 3988 46ba69f31aed
child 4563 5d3e1ffc1ae1
equal deleted inserted replaced
3994:3781477accf3 3996:20c0f21bbe1e
    16 # fields enclosed by brackets "[]" replaced with your own identifying
    16 # fields enclosed by brackets "[]" replaced with your own identifying
    17 # information: Portions Copyright [yyyy] [name of copyright owner]
    17 # information: Portions Copyright [yyyy] [name of copyright owner]
    18 #
    18 #
    19 # CDDL HEADER END
    19 # CDDL HEADER END
    20 #
    20 #
    21 # Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
    21 # Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
    22 #
    22 #
    23 
    23 
    24 include ../make-rules/shared-macros.mk
    24 include ../make-rules/shared-macros.mk
    25 
    25 
    26 # for now, the assumption is we build any directory with a Makefile.  This may
    26 # for now, the assumption is we build any directory with a Makefile.  This may
    29 # appropriate dependency information.
    29 # appropriate dependency information.
    30 
    30 
    31 # components.mk is auto-generated by the build tools.  It populates the
    31 # components.mk is auto-generated by the build tools.  It populates the
    32 # COMPONENT_DIRS macro with a list of all directories in the workspace that
    32 # COMPONENT_DIRS macro with a list of all directories in the workspace that
    33 # contain a component.
    33 # contain a component.
    34 components.mk:	# Makefile # $(WS_TOP)/components
    34 $(WS_MACH)/components.mk:	$(WS_MACH) # Makefile # $(WS_TOP)/components
    35 	@echo "Generating component list..."
    35 	@echo "Generating component list..."
    36 	@$(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
    36 	@$(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
    37 		| sed -e 's;^$(shell pwd)/;COMPONENT_DIRS += ;g' >$@
    37 		| sed -e 's;^$(shell pwd)/;COMPONENT_DIRS += ;g' >$@
    38 
    38 
    39 -include components.mk
    39 -include $(WS_MACH)/components.mk
    40 
    40 
    41 # depends.mk is auto-generated by concatenating 'depend.mk' files in each
    41 # depends.mk is auto-generated by concatenating 'depend.mk' files in each
    42 # component directory.
    42 # component directory.
    43 depends.mk:     components.mk
    43 $(WS_MACH)/depends.mk:     $(WS_MACH)/components.mk
    44 	@echo "Generating component dependencies..."
    44 	@echo "Generating component dependencies..."
    45 	@cat $(shell $(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
    45 	@cat $(shell $(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
    46 		| sed -e 's;^$(shell pwd)/;;g' -e 's;$$;/depend.mk;g') >$@ \
    46 		| sed -e 's;^$(shell pwd)/;;g' -e 's;$$;/depend.mk;g') >$@ \
    47 		2>/dev/null
    47 		2>/dev/null
    48  
    48  
    49 -include depends.mk
    49 -include $(WS_MACH)/depends.mk
    50 
    50 
       
    51 #
       
    52 # Walk through all of the components echoing the REQUIRED_PACKAGES for each one.
       
    53 # Pass all output through sed to drop lines with whitespace between words,
       
    54 # remove whitespace from lines, drop empty lines, and REQUIRED_PACKAGES +=
       
    55 # to the lines.  Pass that through sort -u
       
    56 #
       
    57 $(WS_MACH)/requires.mk:	$(WS_MACH)
       
    58 	@echo "Generating list of required packages to build consolidation..."
       
    59 	@$(GMAKE) component-hook \
       
    60 		COMPONENT_HOOK='@echo $$(REQUIRED_PACKAGES:%="%\\n")' | \
       
    61 		$(GSED) -e '/\S\s\S/d' -e 's/^ //g' -e '/^\s*$$/d' \
       
    62 			-e 's/^/REQUIRED_PACKAGES += /' | \
       
    63 		sort -u >$(@)
       
    64 
       
    65 system-check::	$(WS_MACH)/requires.mk
       
    66 	@$(GMAKE) -f $(WS_MAKE_RULES)/environment.mk -f $< component-environment-check
       
    67 
       
    68 system-prep::	$(WS_MACH)/requires.mk
       
    69 	@echo "Installing any missing packages..."
       
    70 	@$(GMAKE) -f $(WS_MAKE_RULES)/environment.mk -f $< component-environment-prep
    51 
    71 
    52 download:		TARGET = download
    72 download:		TARGET = download
    53 prep:			TARGET = prep
    73 prep:			TARGET = prep
    54 build:			TARGET = build
    74 build:			TARGET = build
    55 install:		TARGET = install
    75 install:		TARGET = install
    56 publish:		TARGET = publish
    76 publish:		TARGET = publish
    57 clean:			TARGET = clean
    77 clean:			TARGET = clean
    58 clobber:		TARGET = clobber
    78 clobber:		TARGET = clobber
    59 test:			TARGET = test
    79 test:			TARGET = test
       
    80 zone-build:		TARGET = component-zone-build
    60 component-hook:		TARGET = component-hook
    81 component-hook:		TARGET = component-hook
    61 prep build install publish test:	TEMPLATE_ZONE=$(ZONE)
    82 zone-build prep build install publish test:	LOG = >$(WS_LOGS)/$(@F).$(TARGET).log 2>&1
    62 prep build install publish test:	LOG = >$(WS_LOGS)/$(@F).$(TARGET).log 2>&1
       
    63 
    83 
    64 # turn off pkglint for the individual component builds.
    84 # turn off pkglint for the individual component builds.
    65 ifeq   ($(strip $(PKGLINT_COMPONENT)),)
    85 ifeq   ($(strip $(PKGLINT_COMPONENT)),)
    66 publish:		MAKEFLAGS += PKGLINT=/bin/true
    86 publish:		MAKEFLAGS += PKGLINT=/bin/true
    67 endif
    87 endif
    73 publish:		MAKEFLAGS += DISABLE_IPS_CATALOG_AND_INDEX_UPDATES=yes
    93 publish:		MAKEFLAGS += DISABLE_IPS_CATALOG_AND_INDEX_UPDATES=yes
    74 
    94 
    75 
    95 
    76 .DEFAULT:	publish
    96 .DEFAULT:	publish
    77 
    97 
    78 build install publish test: $(COMPONENT_DIRS)
    98 zone-build build install publish test: $(COMPONENT_DIRS)
    79 
    99 
    80 COMPONENT_DIRS.nosetup =	$(COMPONENT_DIRS:%=%.nosetup)
   100 COMPONENT_DIRS.nosetup =	$(COMPONENT_DIRS:%=%.nosetup)
    81 
   101 
    82 download prep:	$(COMPONENT_DIRS.nosetup)
   102 download::	$(COMPONENT_DIRS.nosetup)
    83 
   103 prep:		$(COMPONENT_DIRS.nosetup)
       
   104 component-environment-check::	$(COMPONENT_DIRS.nosetup)
    84 component-hook:	$(COMPONENT_DIRS.nosetup)
   105 component-hook:	$(COMPONENT_DIRS.nosetup)
    85 
   106 
    86 clean:		$(COMPONENT_DIRS.nosetup)
   107 clean:		$(COMPONENT_DIRS.nosetup)
    87 	$(RM) components.mk depends.mk .profile
   108 	$(RM) $(WS_MACH)/components.mk $(WS_MACH)/depends.mk \
       
   109 	      $(WS_MACH)/requires.mk $(WS_MACH)/*.p5m
    88 
   110 
    89 clobber:	$(COMPONENT_DIRS.nosetup) clean
   111 clobber:	$(COMPONENT_DIRS.nosetup) clean
    90 	@cd ../tools ; echo "clobbering tools..." ; $(GMAKE) clobber
   112 	@cd ../tools ; echo "clobbering tools..." ; $(GMAKE) clobber
    91 	$(RM) -r $(WS_REPO) $(WS_LOGS) $(WS_LINT_CACHE) \
   113 	$(RM) -r $(WS_REPO) $(WS_LOGS) $(WS_LINT_CACHE) \
    92 	    $(shell find . -name 'manifest-*.published')
   114 	    $(shell find . -name 'manifest-*.published')
    93 
   115 
    94 
   116 
    95 setup:	$(WS_LOGS) $(WS_REPO) tools $(WS_LINT_CACHE)
   117 setup:	$(WS_MACH) $(WS_LOGS) $(WS_REPO) tools $(WS_LINT_CACHE)
    96 
   118 
    97 $(WS_LOGS):
   119 $(WS_MACH) $(WS_LOGS):
    98 	$(MKDIR) $@
   120 	$(MKDIR) $@
    99 
   121 
   100 $(WS_REPO):
   122 $(WS_REPO):
   101 	$(PKGREPO) create $(PKG_REPO)
   123 	$(PKGREPO) create $(PKG_REPO)
   102 	$(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER)
   124 	$(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER)
   121 endif
   143 endif
   122 
   144 
   123 tools:
   145 tools:
   124 	@cd ../tools ; echo "building tools..." ; $(GMAKE) clean setup
   146 	@cd ../tools ; echo "building tools..." ; $(GMAKE) clean setup
   125 
   147 
   126 # $(WS_COMPONENTS) is the home directory for the zone user, so create a profile
       
   127 # to pass a few things on to zone based builds
       
   128 .profile:
       
   129 	echo "PATH=$(PATH)" >>$@
       
   130 	echo "WS_TOP=$(WS_TOP)" >>$@
       
   131 	echo "export PATH WS_TOP" >>$@
       
   132 
       
   133 $(COMPONENT_DIRS):	$(WS_LOGS) setup FORCE
   148 $(COMPONENT_DIRS):	$(WS_LOGS) setup FORCE
   134 	@cd $@ && echo "$(TARGET) $@" && \
   149 	@cd $@ && echo "$(TARGET) $@" && \
   135 	 $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
   150 	 $(BASS_O_MATIC) $(@:%=--component %) --make $(TARGET) $(LOG)
   136 			 $(@:%=--component %) --make $(TARGET) $(LOG)
       
   137 
   151 
   138 # Turn userland-incorporator warnings into build failures
   152 # Turn userland-incorporator warnings into build failures
   139 INCORPORATE_WERROR ?= --Werror
   153 INCORPORATE_WERROR ?= --Werror
   140 
   154 
   141 incorporation:
   155 incorporation:
   142 	$(PKGREPO) refresh -s $(PKG_REPO)
   156 	$(PKGREPO) refresh -s $(PKG_REPO)
   143 	$(WS_TOOLS)/userland-incorporator --repository $(PKG_REPO) \
   157 	$(WS_TOOLS)/userland-incorporator --repository $(PKG_REPO) \
   144           --version=0.$(OS_VERSION),$(BUILD_VERSION) -p $(PUBLISHER) \
   158           --version=0.$(OS_VERSION),$(BUILD_VERSION) -p $(PUBLISHER) \
   145 	  -c $(CONSOLIDATION) --destdir=$(WS_LOGS) $(INCORPORATE_WERROR)
   159 	  -c $(CONSOLIDATION) --destdir=$(WS_MACH) $(INCORPORATE_WERROR)
   146 	for incorporation in $(WS_LOGS)/*.p5m ; do \
   160 	for incorporation in $(WS_MACH)/*.p5m ; do \
   147 	    $(PKGSEND) -s $(PKG_REPO) publish --fmri-in-manifest \
   161 	    $(PKGSEND) -s $(PKG_REPO) publish --fmri-in-manifest \
   148 	               $${incorporation} ; \
   162 	               $${incorporation} ; \
   149 	done
   163 	done
   150 
   164 
   151 publish:
   165 publish:
   160 			$(shell find . -name 'manifest-*.published')
   174 			$(shell find . -name 'manifest-*.published')
   161 endif
   175 endif
   162 
   176 
   163 $(COMPONENT_DIRS.nosetup):	$(WS_LOGS) FORCE
   177 $(COMPONENT_DIRS.nosetup):	$(WS_LOGS) FORCE
   164 	@cd $(@:%.nosetup=%) && echo "$(TARGET) $(@:%.nosetup=%)" && \
   178 	@cd $(@:%.nosetup=%) && echo "$(TARGET) $(@:%.nosetup=%)" && \
   165 	 $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
   179 	 $(BASS_O_MATIC) $(@:%.nosetup=--component %) --make $(TARGET) $(LOG)
   166 			 $(@:%.nosetup=--component %) --make $(TARGET) $(LOG)
       
   167 
   180 
   168 FORCE:
   181 FORCE: