Makefile revision 1057
970N/A###############################################################################
970N/A#
970N/A# Makefile for X Consolidation packages
970N/A#
970N/A# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
970N/A#
970N/A# Permission is hereby granted, free of charge, to any person obtaining a
970N/A# copy of this software and associated documentation files (the "Software"),
970N/A# to deal in the Software without restriction, including without limitation
970N/A# the rights to use, copy, modify, merge, publish, distribute, sublicense,
970N/A# and/or sell copies of the Software, and to permit persons to whom the
970N/A# Software is furnished to do so, subject to the following conditions:
970N/A#
970N/A# The above copyright notice and this permission notice (including the next
970N/A# paragraph) shall be included in all copies or substantial portions of the
970N/A# Software.
970N/A#
970N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
970N/A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
970N/A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
970N/A# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
970N/A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
970N/A# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
970N/A# DEALINGS IN THE SOFTWARE.
970N/A#
970N/A###############################################################################
970N/A# Heavily inspired by / borrowed from the ON usr/src/pkg/Makefile
970N/A# Please read the comments in it and the accompanying README in ON for many
970N/A# details omitted here.
970N/A# Major differences in the X implementation:
970N/A# - X only supports building one repo, not redist + extra
970N/A# - X only supports building packages on the same platform as the binaries,
970N/A# no cross-platform packaging
970N/A# - X has no bfu legacy to deal with
970N/A# - ON has all manifests in one directory, X splits into current & legacy
970N/A# - Integrates with X consolidation makefile/build system instead of ON's
970N/A
970N/APWD:sh=pwd
970N/ATOP=$(PWD)/..
970N/A
970N/A### Include common definitions
970N/Ainclude $(TOP)/open-src/common/Makefile.init
970N/A
970N/A.SUFFIXES: .mf .mog .dep .res .pub
970N/A
970N/A# We don't yet support building packages cross-architecture, but would
970N/A# need this if we ever did. (See "Cross platform packaging notes" in
970N/A# the ON usr/src/pkg/Makefile for what we'd have to do.)
970N/APKGMACH = $(MACH)
970N/A
970N/A# Map X makefile names to the ones used in the rules copied from ON
970N/A# More to be updated if we ever decide to support building cross-platform
970N/APKGROOT = $(PROTODIR)
970N/APKGDEST = $(PROTOTOP)/pkg_$(PKGMACH)
970N/A
970N/A# Map the V=1 style of enabling more verbose build messages used in the
970N/A# X.Org/automake builds to the macro used in the rules copied from ON
970N/A#
970N/A# You can enable verbose output with either V=1 or PKGDEBUG=""
970N/APKGDEBUG_V_0 = @
970N/APKGDEBUG_V_1 =
970N/APKGDEBUG_V_ = $(PKGDEBUG_V_0)
970N/APKGDEBUG = $(PKGDEBUG_V_$(V))
970N/A
970N/A# Commands used in rules copied from ON
970N/ACP= /usr/bin/cp -f
970N/ALN= /usr/bin/ln
970N/AMV= /usr/bin/mv -f
970N/ARM= /usr/bin/rm -f
970N/ATOUCH= /usr/bin/touch
970N/A
970N/A#
970N/A# To suppress package dependency generation on any system, regardless
970N/A# of how it was installed, set SUPPRESSPKGDEP=true in the build
970N/A# environment.
970N/A#
970N/ASUPPRESSPKGDEP= false
970N/A
970N/A
970N/A#
970N/A# The packages directory will contain the processed manifests as
970N/A# direct build targets and subdirectories for package metadata extracted
970N/A# incidentally during manifest processing.
970N/A#
970N/A# Nothing underneath $(PDIR) should ever be managed by SCM.
970N/A#
970N/APDIR= build-$(PKGMACH)
970N/A
970N/A$(PDIR):
970N/A mkdir -p $@
970N/A
970N/A#
970N/A# By default, PKGS will list all manifests. To build and/or publish a
970N/A# subset of packages, override this on the command line or in the
970N/A# build environment and then reference (implicitly or explicitly) the all
970N/A# or install targets.
970N/A#
970N/ACURRENT_MANIFESTS :sh= (cd manifests; print *.mf)
970N/ALEGACY_MANIFESTS :sh= (cd legacy; print *.mf)
970N/AMANIFESTS = $(CURRENT_MANIFESTS) $(LEGACY_MANIFESTS)
970N/APKGS= $(MANIFESTS:%.mf=%)
970N/A
970N/A#
970N/A# Track the synthetic manifests separately so we can properly express
970N/A# build rules and dependencies. The synthetic and real packages use
970N/A# different sets of transforms and macros for pkgmogrify.
970N/A#
977N/ASYNTH_PKGS= X-incorporation X-redistributable
970N/A
970N/A# Any given package list may be empty, but we can only determine that
970N/A# dynamically, so we always generate all lists.
970N/A#
970N/A# The meanings of each package status are as follows:
970N/A#
970N/A# PKGSTAT meaning
970N/A# ---------- ----------------------------------------------------
970N/A# noincorp Do not include in incorporation or group package
982N/A# grouponly Include in group package, but not incorporation
970N/A# obsolete Include in incorporation, but not group package
970N/A# renamed Include in incorporation, but not group package
970N/A# current Include in incorporation and group package
970N/A#
970N/A# Since the semantics of the "noincorp" package status dictate that
970N/A# such packages are not included in the incorporation or group packages,
970N/A# there is no need to build noincorp package lists.
970N/A#
970N/A# Since packages depend on their incorporation, noincorp necessarily
970N/A# implies nodepend, or it would inadvertently pull in other packages.
970N/A#
970N/APKGLISTS= \
970N/A $(PDIR)/packages.current \
982N/A $(PDIR)/packages.grouponly \
970N/A $(PDIR)/packages.renamed \
970N/A $(PDIR)/packages.obsolete
970N/A
970N/A# Manifests are in either manifests or legacy directory - merge in $(PDIR)
970N/A$(PDIR)/%.mf: manifests/%.mf
970N/A $(PKGDEBUG)$(LN) -s ../$< $@
970N/A
970N/A$(PDIR)/%.mf: legacy/%.mf
970N/A $(PKGDEBUG)$(LN) -s ../$< $@
970N/A
970N/APMANIFESTS = $(MANIFESTS:%=$(PDIR)/%)
970N/Amanifests: $(PMANIFESTS)
970N/A$(PMANIFESTS): $(PDIR)
970N/A
970N/A### Additional metadata generation
970N/A
970N/A# This should eventually move into pkg publication
970N/A
970N/AFONT_MANIFESTS :sh= (cd manifests; print system-font-*.mf)
970N/AFONT_METADATA = $(FONT_MANIFESTS:%.mf=$(PDIR)/%.font)
970N/AFONT_ATTRS = $(FONT_MANIFESTS:%.mf=$(PDIR)/%.attr)
970N/A
970N/A$(FONT_ATTRS): $(FONT_METADATA)
970N/A
970N/A$(PDIR)/%.font: $(PDIR)/%.mf
970N/A @print "## Generating font metadata in $(@F)"
970N/A $(PKGDEBUG)$(RM) $(@)
970N/A $(PKGDEBUG)$(PERL) generate_font_metadata.pl \
970N/A -p $(PROTODIR) -m $< > $@ || ( rm $@ ; exit 1 )
970N/A
970N/A### Manifest mogrification
970N/A
970N/APKGMOGRIFY = pkgmogrify
970N/A
970N/A# RELEASE = uname -r for the target release
970N/ARELEASE = 5.11
970N/A
970N/A# Generate pkgmogrify transform file with correct build version info in
970N/A# Build number is derived from last nv_XXX tag in hg log
970N/A$(PDIR)/versions: transforms/versions.tmpl $(PDIR)
970N/A @print "## Substituting build info in versions transformation template"
970N/A $(PKGDEBUG)XNV_BUILDNUM="$${XNV_BUILDNUM:-$$(hg log | \
970N/A $(PERL) -l -n -e \
1057N/A 'if ($$_ =~ m/^tag:\s+nv_([\d\.]+)/) { print $$1 ; exit}')}" ; \
970N/A PKGVERS_BUILTON="$(RELEASE)" ; \
970N/A PKGVERS_BRANCH="0.$${XNV_BUILDNUM}" ; \
970N/A PKGVERS_BUILD="$${PKGVERS_BUILTON}-$${PKGVERS_BRANCH}" ; \
970N/A HG_ID="$$(hg id)" ; \
970N/A $(PERL) -p -e "s{_PKGVERS_BUILD_}{$${PKGVERS_BUILD}};" \
970N/A -e "s{_HG_ID_}{$${HG_ID}}" transforms/versions.tmpl > $@
970N/A
970N/A# Set variables used by pkgmogrify
970N/A# Most upstream packages provide specific version numbers instead of using
970N/A# the default of $(OSPKGVERS)
970N/A# Some use $(X11PKGVERS) to refer to the X11 katamari version since they
970N/A# bundle together components from multiple upstream packages with individual
970N/A# version numbers
970N/AX11PKGVERS = 7.5
970N/AOSPKGVERS = 0.$(RELEASE)
970N/A
970N/A# Base URL for ARC cases used in opensolaris.arc_url metadata
970N/AARC_URL=http://arc.opensolaris.org/caselog/
970N/A
970N/A# These are the macros that may be used in package manifests
970N/APKGMOG_DEFINES= \
970N/A i386_ONLY=$(POUND_SIGN) \
970N/A sparc_ONLY=$(POUND_SIGN) \
970N/A $(PKGMACH)_ONLY= \
970N/A ARCH=$(PKGMACH) \
970N/A ARCH32=$(SUBDIR32_$(PKGMACH)) \
970N/A ARCH64=$(SUBDIR64_$(PKGMACH)) \
970N/A OSPKGVERS=$(OSPKGVERS) \
970N/A X11PKGVERS=$(X11PKGVERS) \
970N/A ARC_URL='$(ARC_URL)'
970N/A
970N/A# Default transformations to apply
1003N/APM_TRANSFORMS = $(PKG_BRANDING_TRANSFORMS) \
1003N/A common_actions publish restart_fmri facets \
970N/A licenses $(PDIR)/versions extract_metadata
970N/APM_INC = transforms
970N/A
970N/APKGDEP_INCORP = depend fmri=pkg:/consolidation/X/X-incorporation type=require
970N/A
970N/APROC_PKGS = $(PKGS:%=$(PDIR)/%.mog)
970N/APROC_SYNTH_PKGS = $(SYNTH_PKGS:%=$(PDIR)/%.mog)
970N/APROC_CURRENT_PKGS = $(CURRENT_MANIFESTS:%.mf=$(PDIR)/%.mog)
970N/A
970N/A# Extra transforms for non-legacy packages
970N/A$(PROC_CURRENT_PKGS):= EXTRA_TRANSFORMS = defaults
970N/A
970N/Amogrify: $(PROC_PKGS)
970N/A$(PROC_PKGS): $(PDIR)/versions
970N/A
970N/A# Combine & uniq metadata & license attributes generated during build
970N/A$(PDIR)/%.attr:
970N/A @print "## Gathering metadata from build for $(@F)"
970N/A $(PKGDEBUG)case '$(@F)' in \
970N/A system-font-*) ADDITIONAL_ATTRS="$(@:%.attr=%.font)" ;; \
970N/A esac ; \
970N/A $(PERL) merge-metadata.pl $${ADDITIONAL_ATTRS} \
970N/A ~(N)$(PROTOMETA)/$(@F:.attr=)/attributes_*.mf \
970N/A ~(N)$(PROTOMETA)/$(@F:.attr=)/license_*.mf /dev/null > $@
970N/A
970N/A$(PDIR)/%.mog: $(PDIR)/%.mf $(PDIR)/%.attr
970N/A @print "## Processing manifest $(@F:.mog=.mf)"
970N/A $(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) $(@:%.mog=%.nodepend) \
970N/A $(@:%.mog=%.metadata.*) $(@).vars
970N/A $(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \
970N/A $(PKGMOG_DEFINES:%=-D %) -P $(@).vars -O $(@) \
970N/A $(@:.mog=.mf) $(@:.mog=.attr) \
970N/A $(PM_TRANSFORMS) $(EXTRA_TRANSFORMS)
970N/A $(PKGDEBUG)if [[ -f $(@) ]]; then \
970N/A eval PKGSTAT=current NODEPEND="$(SUPPRESSPKGDEP)" \
970N/A $$(cat -s $(@).vars) ; \
970N/A if [[ "$$NODEPEND" != "false" || "$$PKGSTAT" = "noincorp" ]]; \
970N/A then \
970N/A $(TOUCH) $(@:%.mog=%.nodepend); \
970N/A fi; \
970N/A $(LN) -s $(@F) \
970N/A $(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT ; \
970N/A if [[ "$$PKGSTAT" = "current" || "$$PKGSTAT" = "renamed" ]]; \
970N/A then \
970N/A print $(PKGDEP_INCORP) >> $(@); \
970N/A fi; \
970N/A else \
970N/A $(TOUCH) $(@); \
970N/A fi
970N/A $(PKGDEBUG)$(RM) $(@).vars
970N/A
970N/A# make the package lists from the real manifests for the synthetic manifests
970N/A$(PKGLISTS): $(PROC_PKGS)
970N/A @print "## Generating $(@F:packages.%=%) package list"
970N/A $(PKGDEBUG)$(PERL) -nl -w -Mdiagnostics \
970N/A -e 'if ($$_ =~ m{name=pkg.fmri value=(\S+)}) {' \
970N/A -e ' printf "depend fmri=$$1 type=\$$(PKGDEP_TYPE)\n";' \
970N/A -e ' close ARGV; ' \
970N/A -e '}' $(PDIR)/*.metadata.$(@F:packages.%=%) > $(@).new
970N/A $(PKGDEBUG) mv -f $(@).new $(@)
970N/A
970N/Apkglists: $(PKGLISTS)
970N/A
970N/A# The package lists are generated with $(PKGDEP_TYPE) as their
970N/A# dependency types, so that they can be included by either an
970N/A# incorporation or a group package.
970N/A#
977N/A$(PDIR)/X-redistributable.mog:= PKGDEP_TYPE= require
970N/A$(PDIR)/X-incorporation.mog:= PKGDEP_TYPE= incorporate
970N/A
970N/A# rule to build the synthetic manifests
970N/A$(PROC_SYNTH_PKGS): $(PKGLISTS) $$(@F:%.mog=%.mf)
970N/A @print "## Processing synthetic manifest $(@F:%.mog=%.mf)"
970N/A $(PKGDEBUG)$(RM) $(@) $(@:%.mog=%).metadata.*
970N/A $(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) -I transforms -I $(PDIR) \
970N/A $(PKGMOG_DEFINES:%=-D %) -D PKGDEP_TYPE=$(PKGDEP_TYPE) \
970N/A -O $(@) $(@F:%.mog=%.mf) \
970N/A $(PM_TRANSFORMS) defaults synthetic
970N/A
970N/A### Dependency detection
970N/ADEP_PKGS= $(PKGS:%=$(PDIR)/%.dep)
970N/ADEP_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.dep)
970N/A
970N/APKGDEP_TOKENS_i386= \
970N/A 'PLATFORM=i86hvm' \
970N/A 'PLATFORM=i86pc' \
970N/A 'PLATFORM=i86xpv' \
970N/A 'ISALIST=amd64' \
970N/A 'ISALIST=i386'
970N/APKGDEP_TOKENS_sparc= \
970N/A 'PLATFORM=sun4u' \
970N/A 'PLATFORM=sun4v' \
970N/A 'ISALIST=sparcv9' \
970N/A 'ISALIST=sparc'
970N/APKGDEP_TOKENS= $(PKGDEP_TOKENS_$(PKGMACH))
970N/A
970N/A$(PDIR)/%.dep: $(PDIR)/%.mog
970N/A @print "## Generating dependencies for $(<F)"
970N/A $(PKGDEBUG)$(RM) $(@)
970N/A $(PKGDEBUG)if [[ ! -f $(@:%.dep=%.nodepend) ]]; then \
970N/A pkgdepend generate -m $(PKGDEP_TOKENS:%=-D %) $(<) \
970N/A $(PKGROOT) > $(@); \
970N/A else \
970N/A $(CP) $(<) $(@); \
970N/A fi
970N/A
970N/A$(DEP_SYNTH_PKGS): $$(@:%.dep=%.mog)
970N/A @print "## Skipping dependency generation for $(@F:%.dep=%)"
970N/A $(PKGDEBUG)$(CP) $(@:%.dep=%.mog) $(@)
970N/A
970N/A### Dependency resolution
970N/A
970N/A#
970N/A# This rule resolves dependencies across all published manifests.
970N/A# We should be able to do this with
970N/A#
970N/A# pkgdepend resolve -m $(PUB_PKGS:%.pub=%.dep)
970N/A#
970N/A# but until 14113 is fixed, the incorporations confuse pkgdepend, so we
970N/A# just create the .res file for DEP_SYNTH_PKGS directly.
970N/A#
970N/A
970N/APKGDEP_VERBOSE_FLAG_0 =
970N/APKGDEP_VERBOSE_FLAG_1 = -v
970N/APKGDEP_VERBOSE_FLAG = $(PKGDEP_VERBOSE_FLAG_$(V))
970N/A
1046N/A# Root of pkg image to use for dependency resolution
1046N/A# Normally / on the machine used to build the binaries
1046N/APKGDEP_RESOLVE_IMAGE = /
1046N/A
970N/A$(PDIR)/gendeps: $(DEP_SYNTH_PKGS) $(DEP_PKGS)
970N/A -$(PKGDEBUG)if [[ "$(SUPPRESSPKGDEP)" = "true" ]]; then \
970N/A print "## Suppressing dependency resolution"; \
970N/A for p in $(DEP_PKGS:%.dep=%); do \
970N/A $(CP) $$p.dep $$p.res; \
970N/A done; \
970N/A else \
970N/A print "## Resolving dependencies"; \
1046N/A pkgdepend -R $(PKGDEP_RESOLVE_IMAGE) resolve \
1046N/A $(PKGDEP_VERBOSE_FLAG) -m $(DEP_PKGS); \
970N/A for p in $(DEP_PKGS:%.dep=%); do \
970N/A $(MV) $$p.dep.res $$p.res; \
970N/A done; \
970N/A fi
970N/A $(PKGDEBUG)for p in $(DEP_SYNTH_PKGS:%.dep=%); \
970N/A do \
970N/A $(CP) $$p.dep $$p.res; \
970N/A done
970N/A $(PKGDEBUG)$(TOUCH) $(@)
970N/A
970N/Agendeps: $(PDIR)/gendeps
970N/A
970N/A### Repo setup
970N/A
970N/A# Default in developer builds is "xnv-devel"
970N/A# X RE cronjob build scripts override to "xnv-nightly" or "xnv-biweekly"
970N/APKGPUBLISHER = xnv-devel
970N/A
970N/A# Initialize the empty on-disk repositories
970N/A$(PKGDEST):
970N/A @print "## Initializing $(@F)"
970N/A $(PKGDEBUG)pkgsend -s file://$(@) create-repository \
970N/A --set-property publisher.prefix=$(PKGPUBLISHER)
970N/A
970N/Aclean-repo:
970N/A $(RM) -r $(PKGDEST)
970N/A
970N/A### Package publication to repo
970N/APUB_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.pub) $(PKGS:%=$(PDIR)/%.pub)
970N/Apublish_pkgs: $(PKGDEST) $(PDIR)/gendeps $(PUB_PKGS)
970N/A
970N/A$(PUB_PKGS): $(PKGDEST) $(PDIR)/gendeps
970N/A
970N/A$(PDIR)/%.pub: $(PKGDEST) $(PDIR)/gendeps $(PDIR)/%.res
970N/A $(PKGDEBUG) if [ -s $(@:%.pub=%.res) ]; then \
970N/A print "## Publishing $(@F:%.pub=%) to proto repository"; \
970N/A pkgsend -s file://$(PKGDEST) publish -d $(PKGROOT) \
970N/A -d license_files -d $(PROTOMETA)/$(@F:%.pub=%) \
970N/A --fmri-in-manifest --no-index --no-catalog \
970N/A $(@:%.pub=%.res) > /dev/null; \
970N/A fi; \
970N/A $(TOUCH) $(@)
970N/A
970N/A### Repo finalization
970N/A
970N/Ainstall: repository-metadata
970N/Adefault: install
970N/A
970N/Arepository-metadata: $(PUB_PKGS)
970N/A @print "## Creating repository metadata"
970N/A $(PKGDEBUG)/usr/lib/pkg.depotd -d $(PKGDEST) \
970N/A --add-content --exit-ready
970N/A $(PKGDEBUG)chmod a+r $(PKGDEST)/cfg_cache
970N/A
970N/A### Overall rules
970N/A
970N/Aall: $(PROC_PKGS) $(PROC_SYNTH_PKGS) $(DEP_PKGS) $(DEP_SYNTH_PKGS) \
970N/A $(PDIR)/gendeps
970N/A
970N/Aclean:
970N/A -$(RM) -r $(PDIR)
970N/A
970N/A.PARALLEL: $(PKGS) $(PROC_PKGS) $(DEP_PKGS) \
970N/A $(PROC_SYNTH_PKGS) $(DEP_SYNTH_PKGS) $(PUB_PKGS)
970N/A
970N/A#
970N/A# rules to validate proto area against manifests, and check for safe
970N/A# file permission modes
970N/A#
970N/A
970N/AEXCEPTIONS= $(PWD)/../exception_lists/packaging $(PDIR)/generated-exceptions
970N/A
970N/A# Automatically exclude all pkg-config uninstalled.pc files, since those
970N/A# should never be packaged
970N/A$(PDIR)/generated-exceptions:
970N/A $(PKGDEBUG)(cd $(PKGROOT) ; find . -name '*-uninstalled.pc') > $@
970N/A
970N/Aprotocmp: $(PROC_PKGS) $(EXCEPTIONS) fix_perms
970N/A $(PKGDEBUG)validate_pkg -a $(PKGMACH) -v $(EXCEPTIONS:%=-e %) \
970N/A -m $(PDIR) -p $(PKGROOT)
970N/A
970N/Apmodes: $(PROC_PKGS) fix_perms
970N/A $(PKGDEBUG)validate_pkg -a $(PKGMACH) -M -m $(PDIR)
970N/A
970N/Acheck: protocmp pmodes
970N/A
970N/A# Instead of fixing all the upstream packages to follow our permission rules
970N/A# just fix the proto area to match our rules
970N/A
970N/Afix_perms:
970N/A @print "## Fixing proto area permissions"
970N/A $(PKGDEBUG)find $(PKGROOT) -type f -exec chmod a-w \{\} \+