components/Makefile
changeset 3817 30b42c38bbc4
parent 3701 2c4a1656e035
child 3953 7a1f9588575b
equal deleted inserted replaced
3814:60344306d223 3817:30b42c38bbc4
    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
    75 # For cases in which a component test should be skipped at at the top level
    95 # For cases in which a component test should be skipped at at the top level
    76 test:			MAKEFLAGS += TOP_LEVEL_TEST=yes
    96 test:			MAKEFLAGS += TOP_LEVEL_TEST=yes
    77 
    97 
    78 .DEFAULT:	publish
    98 .DEFAULT:	publish
    79 
    99 
    80 build install publish test: $(COMPONENT_DIRS)
   100 zone-build build install publish test: $(COMPONENT_DIRS)
    81 
   101 
    82 COMPONENT_DIRS.nosetup =	$(COMPONENT_DIRS:%=%.nosetup)
   102 COMPONENT_DIRS.nosetup =	$(COMPONENT_DIRS:%=%.nosetup)
    83 
   103 
    84 download prep:	$(COMPONENT_DIRS.nosetup)
   104 download::	$(COMPONENT_DIRS.nosetup)
    85 
   105 prep:		$(COMPONENT_DIRS.nosetup)
       
   106 component-environment-check::	$(COMPONENT_DIRS.nosetup)
    86 component-hook:	$(COMPONENT_DIRS.nosetup)
   107 component-hook:	$(COMPONENT_DIRS.nosetup)
    87 
   108 
    88 clean:		$(COMPONENT_DIRS.nosetup)
   109 clean:		$(COMPONENT_DIRS.nosetup)
    89 	$(RM) components.mk depends.mk .profile
   110 	$(RM) $(WS_MACH)/components.mk $(WS_MACH)/depends.mk \
       
   111 	      $(WS_MACH)/requires.mk $(WS_MACH)/*.p5m
    90 
   112 
    91 clobber:	$(COMPONENT_DIRS.nosetup) clean
   113 clobber:	$(COMPONENT_DIRS.nosetup) clean
    92 	@cd ../tools ; echo "clobbering tools..." ; $(GMAKE) clobber
   114 	@cd ../tools ; echo "clobbering tools..." ; $(GMAKE) clobber
    93 	$(RM) -r $(WS_REPO) $(WS_LOGS) $(WS_LINT_CACHE)
   115 	$(RM) -r $(WS_REPO) $(WS_LOGS) $(WS_LINT_CACHE)
    94 
   116 
    95 
   117 
    96 setup:	$(WS_LOGS) $(WS_REPO) tools $(WS_LINT_CACHE)
   118 setup:	$(WS_MACH) $(WS_LOGS) $(WS_REPO) tools $(WS_LINT_CACHE)
    97 
   119 
    98 $(WS_LOGS):
   120 $(WS_MACH) $(WS_LOGS):
    99 	$(MKDIR) $@
   121 	$(MKDIR) $@
   100 
   122 
   101 $(WS_REPO):
   123 $(WS_REPO):
   102 	$(PKGREPO) create $(PKG_REPO)
   124 	$(PKGREPO) create $(PKG_REPO)
   103 	$(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER)
   125 	$(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER)
   122 endif
   144 endif
   123 
   145 
   124 tools:
   146 tools:
   125 	@cd ../tools ; echo "building tools..." ; $(GMAKE) clean setup
   147 	@cd ../tools ; echo "building tools..." ; $(GMAKE) clean setup
   126 
   148 
   127 # $(WS_COMPONENTS) is the home directory for the zone user, so create a profile
       
   128 # to pass a few things on to zone based builds
       
   129 .profile:
       
   130 	echo "PATH=$(PATH)" >>$@
       
   131 	echo "WS_TOP=$(WS_TOP)" >>$@
       
   132 	echo "export PATH WS_TOP" >>$@
       
   133 
       
   134 $(COMPONENT_DIRS):	$(WS_LOGS) setup FORCE
   149 $(COMPONENT_DIRS):	$(WS_LOGS) setup FORCE
   135 	@cd $@ && echo "$(TARGET) $@" && \
   150 	@cd $@ && echo "$(TARGET) $@" && \
   136 	 $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
   151 	 $(BASS_O_MATIC) $(@:%=--component %) --make $(TARGET) $(LOG)
   137 			 $(@:%=--component %) --make $(TARGET) $(LOG)
       
   138 
   152 
   139 # Turn userland-incorporator warnings into build failures
   153 # Turn userland-incorporator warnings into build failures
   140 INCORPORATE_WERROR ?= --Werror
   154 INCORPORATE_WERROR ?= --Werror
   141 
   155 
   142 incorporation:
   156 incorporation:
   143 	$(PKGREPO) refresh -s $(PKG_REPO)
   157 	$(PKGREPO) refresh -s $(PKG_REPO)
   144 	$(WS_TOOLS)/userland-incorporator --repository $(PKG_REPO) \
   158 	$(WS_TOOLS)/userland-incorporator --repository $(PKG_REPO) \
   145           --version=0.$(OS_VERSION),$(BUILD_VERSION) -p $(PUBLISHER) \
   159           --version=0.$(OS_VERSION),$(BUILD_VERSION) -p $(PUBLISHER) \
   146 	  -c $(CONSOLIDATION) --destdir=$(WS_LOGS) $(INCORPORATE_WERROR)
   160 	  -c $(CONSOLIDATION) --destdir=$(WS_MACH) $(INCORPORATE_WERROR)
   147 	for incorporation in $(WS_LOGS)/*.p5m ; do \
   161 	for incorporation in $(WS_MACH)/*.p5m ; do \
   148 	    $(PKGSEND) -s $(PKG_REPO) publish --fmri-in-manifest \
   162 	    $(PKGSEND) -s $(PKG_REPO) publish --fmri-in-manifest \
   149 	               $${incorporation} ; \
   163 	               $${incorporation} ; \
   150 	done
   164 	done
   151 
   165 
   152 publish:
   166 publish:
   161 			$(shell find . -name 'manifest-*.published')
   175 			$(shell find . -name 'manifest-*.published')
   162 endif
   176 endif
   163 
   177 
   164 $(COMPONENT_DIRS.nosetup):	$(WS_LOGS) FORCE
   178 $(COMPONENT_DIRS.nosetup):	$(WS_LOGS) FORCE
   165 	@cd $(@:%.nosetup=%) && echo "$(TARGET) $(@:%.nosetup=%)" && \
   179 	@cd $(@:%.nosetup=%) && echo "$(TARGET) $(@:%.nosetup=%)" && \
   166 	 $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
   180 	 $(BASS_O_MATIC) $(@:%.nosetup=--component %) --make $(TARGET) $(LOG)
   167 			 $(@:%.nosetup=--component %) --make $(TARGET) $(LOG)
       
   168 
   181 
   169 FORCE:
   182 FORCE: