Makefile revision 919
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington#
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# CDDL HEADER START
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster#
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# The contents of this file are subject to the terms of the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# Common Development and Distribution License (the "License").
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# You may not use this file except in compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster#
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# or http://www.opensolaris.org/os/licensing.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# See the License for the specific language governing permissions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster#
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# When distributing Covered Code, include this CDDL HEADER in each
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# If applicable, add the following below this CDDL HEADER, with the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# fields enclosed by brackets "[]" replaced with your own identifying
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# information: Portions Copyright [yyyy] [name of copyright owner]
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster#
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# CDDL HEADER END
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster#
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster#
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterinclude ../make-rules/shared-macros.mk
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# for now, the assumption is we build any directory with a Makefile. This may
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington# not always be the case. If we build a new make-like tool to drive the upper
3296aadab8464fc555488c34c7ee63644b754387Peter Major# level build, it may make different decisions and will need to include
5f4d6070f856d0de82c1d16459b89233e2e81ff2Kohei Tamura# appropriate dependency information.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington# components.mk is auto-generated by the build tools. It populates the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# COMPONENT_DIRS macro with a list of all directories in the workspace that
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# contain a component.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fostercomponents.mk: # Makefile # $(WS_TOP)/components
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @echo "Generating component list..."
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @$(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster | sed -e 's;^$(shell pwd)/;COMPONENT_DIRS += ;g' >$@
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster-include components.mk
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# depends.mk is auto-generated by concatenating 'depend.mk' files in each
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# component directory.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterdepends.mk: components.mk
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @echo "Generating component dependencies..."
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @cat $(shell $(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster | sed -e 's;^$(shell pwd)/;;g' -e 's;$$;/depend.mk;g') >$@ \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster 2>/dev/null
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster-include depends.mk
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterdownload: TARGET = download
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterprep: TARGET = prep
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterbuild: TARGET = build
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterinstall: TARGET = install
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublish: TARGET = publish
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterclean: TARGET = clean
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterclobber: TARGET = clobber
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fostertest: TARGET = test
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterprep build install publish test: TEMPLATE_ZONE=$(ZONE)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterprep build install publish test: LOG = >$(WS_LOGS)/$(@F).$(TARGET).log 2>&1
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# turn off pkglint for the individual component builds.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterifeq ($(strip $(PKGLINT_COMPONENT)),)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublish: MAKEFLAGS += PKGLINT=/bin/true
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterendif
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster.DEFAULT: publish
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterbuild install publish test: $(COMPONENT_DIRS)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterCOMPONENT_DIRS.nosetup = $(COMPONENT_DIRS:%=%.nosetup)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterdownload prep: $(COMPONENT_DIRS.nosetup)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterclean: $(COMPONENT_DIRS.nosetup)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(RM) components.mk depends.mk .profile
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterclobber: $(COMPONENT_DIRS.nosetup) clean
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @cd ../tools ; echo "clobbering tools..." ; $(GMAKE) clobber
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(RM) -r $(WS_REPO) $(WS_LOGS) $(WS_LINT_CACHE)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fostersetup: $(WS_LOGS) $(WS_REPO) tools $(WS_LINT_CACHE)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster$(WS_LOGS):
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(MKDIR) $@
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster$(WS_REPO):
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(PKGREPO) create $(PKG_REPO)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER_LOCALIZABLE)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterDUMMYPKG = "set name=fmri value=pkg:/dummy@0,$(BUILD_VERSION)\n"
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterDUMMYPKG += "set pkg.summary=dummy\n"
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterDUMMYPKG += "set org.opensolaris.consolidation=userland\n"
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterDUMMYPKG += "set info.classification=org.opensolaris.category.2008:System/Core"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster$(WS_LINT_CACHE): $(WS_LOGS)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterifdef CANONICAL_REPO
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @echo "Generating pkglint(1) cache from $(CANONICAL_REPO)..."
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @(echo $(DUMMYPKG) | $(PKGLINT) \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster -c $(WS_LINT_CACHE) -r $(CANONICAL_REPO) /dev/fd/0 \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster >$(WS_LOGS)/naughty-canonical-repo-actions 2>&1 ; exit 0)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterelse
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(MKDIR) $(WS_LINT_CACHE)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterendif
3296aadab8464fc555488c34c7ee63644b754387Peter Major
3296aadab8464fc555488c34c7ee63644b754387Peter Majortools:
3296aadab8464fc555488c34c7ee63644b754387Peter Major @cd ../tools ; echo "building tools..." ; $(GMAKE) clean setup
3296aadab8464fc555488c34c7ee63644b754387Peter Major
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# $(WS_COMPONENTS) is the home directory for the zone user, so create a profile
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# to pass a few things on to zone based builds
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster.profile:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster echo "PATH=$(PATH)" >>$@
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster echo "WS_TOP=$(WS_TOP)" >>$@
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster echo "export PATH WS_TOP" >>$@
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster$(COMPONENT_DIRS): $(WS_LOGS) setup FORCE
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @cd $@ && echo "$(TARGET) $@" && \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(@:%=--component %) --make $(TARGET) $(LOG)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublish:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(PKGREPO) rebuild -s $(PKG_REPO)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(WS_TOOLS)/userland-incorporator --repository $(PKG_REPO) \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster -p pkg:/consolidation/$(CONSOLIDATION)/$(CONSOLIDATION)-incorporation@0.$(OS_VERSION),$(BUILD_VERSION) \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster -s "$(CONSOLIDATION) consolidation incorporation" \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster -d "This incorporation constrains packages from the $(CONSOLIDATION) consolidation" \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster -c $(CONSOLIDATION) >$(WS_LOGS)/$(CONSOLIDATION)-incorporation.p5m
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(PKGSEND) -s $(PKG_REPO) publish --fmri-in-manifest \
8d3140b524c0e28c0a49dc7c7d481123ef3cfe11Chris Lee $(WS_LOGS)/$(CONSOLIDATION)-incorporation.p5m
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# pkglint all of the published manifests in one batch.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterifdef CANONICAL_REPO
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @echo 'pkglinting all package manifests...'
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @$(ENV) PYTHONPATH=$(WS_TOOLS)/python $(PKGLINT) \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster -c $(WS_LINT_CACHE) -f $(WS_TOOLS)/pkglintrc \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(shell find . -name 'manifest-*.published')
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterendif
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8d3140b524c0e28c0a49dc7c7d481123ef3cfe11Chris Lee$(COMPONENT_DIRS.nosetup): $(WS_LOGS) FORCE
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @cd $(@:%.nosetup=%) && echo "$(TARGET) $(@:%.nosetup=%)" && \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $(@:%.nosetup=--component %) --make $(TARGET) $(LOG)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterFORCE:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster