1# 2# CDDL HEADER START 3# 4# The contents of this file are subject to the terms of the 5# Common Development and Distribution License (the "License"). 6# You may not use this file except in compliance with the License. 7# 8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9# or http://www.opensolaris.org/os/licensing. 10# See the License for the specific language governing permissions 11# and limitations under the License. 12# 13# When distributing Covered Code, include this CDDL HEADER in each 14# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15# If applicable, add the following below this CDDL HEADER, with the 16# fields enclosed by brackets "[]" replaced with your own identifying 17# information: Portions Copyright [yyyy] [name of copyright owner] 18# 19# CDDL HEADER END 20# 21 22# 23# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24# Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. 25# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com> 26# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. 27# 28 29include $(SRC)/Makefile.master 30include $(SRC)/Makefile.buildnum 31 32# 33# Make sure we're getting a consistent execution environment for the 34# embedded scripts. 35# 36SHELL= /usr/bin/ksh93 37 38# 39# To suppress package dependency generation on any system, regardless 40# of how it was installed, set SUPPRESSPKGDEP=true in the build 41# environment. 42# 43SUPPRESSPKGDEP= false 44 45# 46# Comment this line out or set "PKGDEBUG=" in your build environment 47# to get more verbose output from the make processes in usr/src/pkg 48# 49PKGDEBUG= @ 50 51# 52# Cross platform packaging notes 53# 54# By default, we package the proto area from the same architecture as 55# the packaging build. In other words, if you're running nightly or 56# bldenv on an x86 platform, it will take objects from the x86 proto 57# area and use them to create x86 repositories. 58# 59# If you want to create repositories for an architecture that's 60# different from $(uname -p), you do so by setting PKGMACH in your 61# build environment. 62# 63# For this to work correctly, the following must all happen: 64# 65# 1. You need the desired proto area, which you can get either by 66# doing a gatekeeper-style build with the -U option to 67# nightly(1), or by using rsync. If you don't do this, you will 68# get packaging failures building all packages, because pkgsend 69# is unable to find the required binaries. 70# 2. You need the desired tools proto area, which you can get in the 71# same ways as the normal proto area. If you don't do this, you 72# will get packaging failures building onbld, because pkgsend is 73# unable to find the tools binaries. 74# 3. The remainder of this Makefile should never refer directly to 75# $(MACH). Instead, $(PKGMACH) should be used whenever an 76# architecture-specific path or token is needed. If this is done 77# incorrectly, then packaging will fail, and you will see the 78# value of $(uname -p) instead of the value of $(PKGMACH) in the 79# commands that fail. 80# 4. Each time a rule in this Makefile invokes $(MAKE), it should 81# pass PKGMACH=$(PKGMACH) explicitly on the command line. If 82# this is done incorrectly, then packaging will fail, and you 83# will see the value of $(uname -p) instead of the value of 84# $(PKGMACH) in the commands that fail. 85# 86# Refer also to the convenience targets defined later in this 87# Makefile. 88# 89PKGMACH= $(MACH) 90 91# 92# ROOT, TOOLS_PROTO, and PKGARCHIVE should be set by nightly or 93# bldenv. These macros translate them into terms of $PKGMACH, instead 94# of $ARCH. 95# 96PKGROOT.cmd= print $(ROOT) | sed -e s:/root_$(MACH):/root_$(PKGMACH): 97PKGROOT= $(PKGROOT.cmd:sh) 98TOOLSROOT.cmd= print $(TOOLS_PROTO) | sed -e s:/root_$(MACH):/root_$(PKGMACH): 99TOOLSROOT= $(TOOLSROOT.cmd:sh) 100PKGDEST.cmd= print $(PKGARCHIVE) | sed -e s:/$(MACH)/:/$(PKGMACH)/: 101PKGDEST= $(PKGDEST.cmd:sh) 102 103EXCEPTIONS= packaging 104 105PKGMOGRIFY= pkgmogrify 106 107# 108# Always build the redistributable repository, but only build the 109# nonredistributable bits if we have access to closed source. 110# 111# Some objects that result from the closed build are still 112# redistributable, and should be packaged as part of an open-only 113# build. Access to those objects is provided via the closed-bins 114# tarball. See usr/src/tools/scripts/bindrop.sh for details. 115# 116REPOS= redist 117 118# 119# The packages directory will contain the processed manifests as 120# direct build targets and subdirectories for package metadata extracted 121# incidentally during manifest processing. 122# 123# Nothing underneath $(PDIR) should ever be managed by SCM. 124# 125PDIR= packages.$(PKGMACH) 126 127# 128# The tools proto must be specified for dependency generation. 129# Publication from the tools proto area is managed in the 130# publication rule. 131# 132$(PDIR)/developer-build-onbld.dep:= PKGROOT= $(TOOLSROOT) 133 134PKGPUBLISHER= $(PKGPUBLISHER_REDIST) 135 136# 137# To get these defaults, manifests should simply refer to $(PKGVERS). 138# 139PKGVERS_COMPONENT= 0.$(RELEASE) 140PKGVERS_BUILTON= $(RELEASE) 141PKGVERS_BRANCH= 0.$(ONNV_BUILDNUM) 142PKGVERS= $(PKGVERS_COMPONENT),$(PKGVERS_BUILTON)-$(PKGVERS_BRANCH) 143 144# 145# The ARCH32 and ARCH64 macros are used in the manifests to express 146# architecture-specific subdirectories in the installation paths 147# for isaexec'd commands. 148# 149# We can't simply use $(MACH32) and $(MACH64) here, because they're 150# only defined for the build architecture. To do cross-platform 151# packaging, we need both values. 152# 153i386_ARCH32= i86 154sparc_ARCH32= sparcv7 155i386_ARCH64= amd64 156sparc_ARCH64= sparcv9 157 158# 159# macros and transforms needed by pkgmogrify 160# 161# If you append to this list using target-specific assignments (:=), 162# be very careful that the targets are of the form $(PDIR)/pkgname. If 163# you use a higher level target, or a package list, you'll trigger a 164# complete reprocessing of all manifests because they'll fail command 165# dependency checking. 166# 167PM_TRANSFORMS= common_actions publish restart_fmri facets defaults \ 168 extract_metadata 169PM_INC= transforms manifests 170 171JAVA_8_ONLY=$(BLD_JAVA_8) 172JAVA_7_ONLY= 173$(BLD_JAVA_8)JAVA_7_ONLY=$(POUND_SIGN) 174 175TITANIC_VERSION_MAJOR.cmd = echo $(VERSION) | sed -e 's/titanic_\([^.]*\).*/\1/' 176TITANIC_VERSION_MAJOR = $(TITANIC_VERSION_MAJOR.cmd:sh) 177TITANIC_VERSION_MAJOR_NEXT.cmd = echo $$(($(TITANIC_VERSION_MAJOR) + 1)) 178TITANIC_VERSION_MAJOR_NEXT = $(TITANIC_VERSION_MAJOR_NEXT.cmd:sh) 179 180PKGMOG_DEFINES= \ 181 i386_ONLY=$(POUND_SIGN) \ 182 sparc_ONLY=$(POUND_SIGN) \ 183 $(PKGMACH)_ONLY= \ 184 ARCH=$(PKGMACH) \ 185 ARCH32=$($(PKGMACH)_ARCH32) \ 186 ARCH64=$($(PKGMACH)_ARCH64) \ 187 PKGVERS_COMPONENT=$(PKGVERS_COMPONENT) \ 188 PKGVERS_BUILTON=$(PKGVERS_BUILTON) \ 189 PKGVERS_BRANCH=$(PKGVERS_BRANCH) \ 190 PKGVERS=$(PKGVERS) \ 191 PERL_ARCH=$(PERL_ARCH) \ 192 PERL_VERSION=$(PERL_VERSION) \ 193 PERL_PKGVERS=$(PERL_PKGVERS) \ 194 PYTHON_VERSION=$(PYTHON_VERSION) \ 195 PYTHON3_VERSION=$(PYTHON3_VERSION) \ 196 PYTHON_PKGVERS=$(PYTHON_PKGVERS) \ 197 PYTHON3_PKGVERS=$(PYTHON3_PKGVERS) \ 198 python2_ONLY=$(BUILDPY2) \ 199 python3_ONLY=$(BUILDPY3) \ 200 JAVA_8_ONLY=$(JAVA_8_ONLY) \ 201 JAVA_7_ONLY=$(JAVA_7_ONLY) \ 202 TITANIC_VERSION_MAJOR=$(TITANIC_VERSION_MAJOR) \ 203 TITANIC_VERSION_MAJOR_NEXT=$(TITANIC_VERSION_MAJOR_NEXT) 204 205PKGDEP_TOKENS_i386= \ 206 'PLATFORM=i86hvm' \ 207 'PLATFORM=i86pc' \ 208 'PLATFORM=i86xpv' \ 209 'ISALIST=amd64' \ 210 'ISALIST=i386' 211PKGDEP_TOKENS_sparc= \ 212 'PLATFORM=sun4u' \ 213 'PLATFORM=sun4v' \ 214 'ISALIST=sparcv9' \ 215 'ISALIST=sparc' 216PKGDEP_TOKENS= $(PKGDEP_TOKENS_$(PKGMACH)) 217 218# 219# The package lists are generated with $(PKGDEP_TYPE) as their 220# dependency types, so that they can be included by either an 221# incorporation or a group package. 222# 223$(PDIR)/osnet-redist.mog := PKGDEP_TYPE= require 224$(PDIR)/osnet-incorporation.mog:= PKGDEP_TYPE= incorporate 225 226PKGDEP_INCORP= \ 227 depend fmri=consolidation/osnet/osnet-incorporation type=require 228 229# 230# All packaging build products should go into $(PDIR), so they don't 231# need to be included separately in CLOBBERFILES. 232# 233CLOBBERFILES= $(PDIR) proto_list_$(PKGMACH) install-$(PKGMACH).out \ 234 license-list 235 236# 237# By default, PKGS will list all manifests. To build and/or publish a 238# subset of packages, override this on the command line or in the 239# build environment and then reference (implicitly or explicitly) the all 240# or install targets. 241# 242# We want some manifests to optionally build based on environment options, so 243# those are excluded when generating the list of manifests and added back in if 244# necessary. We also want a relatively easy way to add files to the list of 245# manifests given special treatment. Add any other special ones to the 246# SPECIAL_MANIFESTS variable. It can contain wildcards in regexp form, i.e. 247# SUNW.* as one useful example. 248# 249SPECIAL_MANIFESTS = system-library-python-.* 250LIST_MANIFESTS_CMD = (cd manifests ; /usr/bin/ls -1 *.mf |\ 251 $(SED) $(SPECIAL_MANIFESTS:%=-e '/^%$$/d') ) 252MANIFESTS = $(LIST_MANIFESTS_CMD:sh) 253 254# Conditionally add back python modules 255$(BUILDPY2) MANIFESTS += \ 256 system-library-python-libbe-2.mf \ 257 system-library-python-solaris-2.mf \ 258 system-library-python-zfs-2.mf 259$(BUILDPY3) MANIFESTS += \ 260 system-library-python-libbe-3.mf \ 261 system-library-python-solaris-3.mf \ 262 system-library-python-zfs-3.mf 263 264PKGS= $(MANIFESTS:%.mf=%) 265DEP_PKGS= $(PKGS:%=$(PDIR)/%.dep) 266PROC_PKGS= $(PKGS:%=$(PDIR)/%.mog) 267 268# 269# Track the synthetic manifests separately so we can properly express 270# build rules and dependencies. The synthetic and real packages use 271# different sets of transforms and macros for pkgmogrify. 272# 273SYNTH_PKGS= osnet-incorporation osnet-redist 274DEP_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.dep) 275PROC_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.mog) 276 277# 278# Root of pkg image to use for dependency resolution 279# Normally / on the machine used to build the binaries 280# 281PKGDEP_RESOLVE_IMAGE = / 282 283# 284# For each package, we determine the target repository based on 285# manifest-embedded metadata. Because we make that determination on 286# the fly, the publication target cannot be expressed as a 287# subdirectory inside the unknown-by-the-makefile target repository. 288# 289# In order to limit the target set to real files in known locations, 290# we use a ".pub" file in $(PDIR) for each processed manifest, regardless 291# of content or target repository. 292# 293PUB_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.pub) $(PKGS:%=$(PDIR)/%.pub) 294 295# 296# Any given repository- and status-specific package list may be empty, 297# but we can only determine that dynamically, so we always generate all 298# lists for each repository we're building. 299# 300# The meanings of each package status are as follows: 301# 302# PKGSTAT meaning 303# ---------- ---------------------------------------------------- 304# noincorp Do not include in incorporation or group package 305# obsolete Include in incorporation, but not group package 306# renamed Include in incorporation, but not group package 307# current Include in incorporation and group package 308# 309# Since the semantics of the "noincorp" package status dictate that 310# such packages are not included in the incorporation or group packages, 311# there is no need to build noincorp package lists. 312# 313PKGLISTS= \ 314 $(REPOS:%=$(PDIR)/packages.%.current) \ 315 $(REPOS:%=$(PDIR)/packages.%.renamed) \ 316 $(REPOS:%=$(PDIR)/packages.%.obsolete) 317 318.KEEP_STATE: 319 320.PARALLEL: $(PKGS) $(PROC_PKGS) $(DEP_PKGS) \ 321 $(PROC_SYNTH_PKGS) $(DEP_SYNTH_PKGS) $(PUB_PKGS) 322 323# 324# For a single manifest, the dependency chain looks like this: 325# 326# raw manifest (mypkg.mf) 327# | 328# | use pkgmogrify to process raw manifest 329# | 330# processed manifest (mypkg.mog) 331# | 332# * | use pkgdepend generate to generate dependencies 333# | 334# manifest with TBD dependencies (mypkg.dep) 335# | 336# % | use pkgdepend resolve to resolve dependencies 337# | 338# manifest with dependencies resolved (mypkg.res) 339# | 340# | use pkgsend to publish the package 341# | 342# placeholder to indicate successful publication (mypkg.pub) 343# 344# * This may be suppressed via SUPPRESSPKGDEP. The resulting 345# packages will install correctly, but care must be taken to 346# install all dependencies, because pkg will not have the input 347# it needs to determine this automatically. 348# 349# % This is included in this diagram to make the picture complete, but 350# this is a point of synchronization in the build process. 351# Dependency resolution is actually done once on the entire set of 352# manifests, not on a per-package basis. 353# 354# The full dependency chain for generating everything that needs to be 355# published, without actually publishing it, looks like this: 356# 357# processed synthetic packages 358# | | 359# package lists synthetic package manifests 360# | 361# processed real packages 362# | | 363# package dir real package manifests 364# 365# Here, each item is a set of real or synthetic packages. For this 366# portion of the build, no reference is made to the proto area. It is 367# therefore suitable for the "all" target, as opposed to "install." 368# 369# Since each of these steps is expressed explicitly, "all" need only 370# depend on the head of the chain. 371# 372# From the end of manifest processing, the publication dependency 373# chain looks like this: 374# 375# repository metadata (catalogs and search indices) 376# | 377# | pkgrepo refresh 378# | 379# published packages 380# | | 381# | | pkgsend publish 382# | | 383# repositories resolved dependencies 384# | | 385# pkgsend | | pkgdepend resolve 386# create-repository | 387# | generated dependencies 388# repo directories | 389# | pkgdepend 390# | 391# processed manifests 392# 393 394ALL_TARGETS= $(PROC_SYNTH_PKGS) proto_list_$(PKGMACH) 395 396all: $(ALL_TARGETS) 397 398# 399# This will build the directory to contain the processed manifests 400# and the metadata symlinks. 401# 402$(PDIR): 403 @print "Creating $(@)" 404 $(PKGDEBUG)$(INS.dir) 405 406# 407# This rule resolves dependencies across all published manifests. 408# 409# We shouldn't have to ignore the error from pkgdepend, but until 410# 16012 and its dependencies are resolved, pkgdepend will always exit 411# with an error. 412# 413$(PDIR)/gendeps: $(DEP_SYNTH_PKGS) $(DEP_PKGS) 414 -$(PKGDEBUG)if [ "$(SUPPRESSPKGDEP)" = "true" ]; then \ 415 print "Suppressing dependency resolution"; \ 416 for p in $(DEP_PKGS:%.dep=%); do \ 417 $(CP) $$p.dep $$p.res; \ 418 done; \ 419 else \ 420 print "Resolving dependencies"; \ 421 pkgdepend -R $(PKGDEP_RESOLVE_IMAGE) resolve \ 422 -m $(DEP_SYNTH_PKGS) $(DEP_PKGS); \ 423 for p in $(DEP_SYNTH_PKGS:%.dep=%) $(DEP_PKGS:%.dep=%); do \ 424 if [ "$$(print $$p.metadata.*)" = \ 425 "$$(print $$p.metadata.noincorp.*)" ]; \ 426 then \ 427 print "Removing dependency versions from $$p"; \ 428 $(PKGMOGRIFY) $(PKGMOG_VERBOSE) \ 429 -O $$p.res -I transforms \ 430 strip_versions $$p.dep.res; \ 431 $(RM) $$p.dep.res; \ 432 else \ 433 $(MV) $$p.dep.res $$p.res; \ 434 fi; \ 435 done; \ 436 fi 437 $(PKGDEBUG)$(TOUCH) $(@) 438 439install: $(ALL_TARGETS) repository-metadata 440 441repository-metadata: publish_pkgs 442 $(PKGDEBUG)for r in $(REPOS); do \ 443 pkgrepo refresh -s $(PKGDEST)/repo.$$r; \ 444 done 445 446# 447# Since we create zero-length processed manifests for a graceful abort 448# from pkgmogrify, we need to detect that here and make no effort to 449# publish the package. 450# 451# For all other packages, we publish them regardless of status. We 452# derive the target repository as a component of the metadata-derived 453# symlink for each package. 454# 455publish_pkgs: $(REPOS:%=$(PKGDEST)/repo.%) $(PDIR)/gendeps .WAIT $(PUB_PKGS) 456 457# 458# Before publishing, we want to pull the license files from $CODEMGR_WS 459# into the proto area. This allows us to NOT pass $SRC (or 460# $CODEMGR_WS) as a basedir for publication. 461# 462$(PUB_PKGS): stage-licenses 463 464# 465# Initialize the empty on-disk repositories 466# 467$(REPOS:%=$(PKGDEST)/repo.%): 468 @print "Initializing $(@F)" 469 $(PKGDEBUG)$(INS.dir) 470 $(PKGDEBUG)pkgsend -s file://$(@) create-repository \ 471 --set-property publisher.prefix=$(PKGPUBLISHER) 472 473# 474# rule to process real manifests 475# 476# To allow redistributability and package status to change, we must 477# remove not only the actual build target (the processed manifest), but 478# also the incidental ones (the metadata-derived symlinks). 479# 480# If pkgmogrify exits cleanly but fails to create the specified output 481# file, it means that it encountered an abort directive. That means 482# that this package should not be published for this particular build 483# environment. Since we can't prune such packages from $(PKGS) 484# retroactively, we need to create an empty target file to keep make 485# from trying to rebuild it every time. For these empty targets, we 486# do not create metadata symlinks. 487# 488# Automatic dependency resolution to files is also done at this phase of 489# processing. The skipped packages are skipped due to existing bugs 490# in pkgdepend. 491# 492# The incorporation dependency is tricky: it needs to go into all 493# current and renamed manifests (ie all incorporated packages), but we 494# don't know which those are until after we run pkgmogrify. So 495# instead of expressing it as a transform, we tack it on ex post facto. 496# 497# Implementation notes: 498# 499# - The first $(RM) must not match other manifests, or we'll run into 500# race conditions with parallel manifest processing. 501# 502# - The make macros [ie $(MACRO)] are evaluated when the makefile is 503# read in, and will result in a fixed, macro-expanded rule for each 504# target enumerated in $(PROC_PKGS). 505# 506# - The shell variables (ie $$VAR) are assigned on the fly, as the rule 507# is executed. The results may only be referenced in the shell in 508# which they are assigned, so from the perspective of make, all code 509# that needs these variables needs to be part of the same line of 510# code. Hence the use of command separators and line continuation 511# characters. 512# 513# - The extract_metadata transforms are designed to spit out shell 514# variable assignments to stdout. Those are published to the 515# .vars temporary files, and then used as input to the eval 516# statement. This is done in stages specifically so that pkgmogrify 517# can signal failure if the manifest has a syntactic or other error. 518# The eval statement should begin with the default values, and the 519# output from pkgmogrify (if any) should be in the form of a 520# variable assignment to override those defaults. 521# 522# - When this rule completes execution, it must leave an updated 523# target file ($@) in place, or make will reprocess the package 524# every time it encounters it as a dependency. Hence the "touch" 525# statement to ensure that the target is created, even when 526# pkgmogrify encounters an abort in the publish transforms. 527# 528 529.SUFFIXES: .mf .mog .dep .res .pub 530 531$(PDIR)/%.mog: manifests/%.mf 532 @print "Processing manifest $(<F)" 533 @env PKGFMT_OUTPUT=v1 pkgfmt -c $< 534 $(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) $(@:%.mog=%.nodepend) \ 535 $(@:%.mog=%.lics) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars 536 $(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \ 537 $(PKGMOG_DEFINES:%=-D %) -P $(@).vars -O $(@) \ 538 $(<) $(PM_TRANSFORMS) 539 $(PKGDEBUG)eval REPO=redist PKGSTAT=current NODEPEND=$(SUPPRESSPKGDEP) \ 540 `$(CAT) -s $(@).vars`; \ 541 if [ -f $(@) ]; then \ 542 if [ "$$NODEPEND" != "false" ]; then \ 543 $(TOUCH) $(@:%.mog=%.nodepend); \ 544 fi; \ 545 $(LN) -s $(@F) \ 546 $(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \ 547 if [ \( "$$PKGSTAT" = "current" \) -o \ 548 \( "$$PKGSTAT" = "renamed" \) ]; \ 549 then print $(PKGDEP_INCORP) >> $(@); \ 550 fi; \ 551 print $$LICS > $(@:%.mog=%.lics); \ 552 else \ 553 $(TOUCH) $(@) $(@:%.mog=%.lics); \ 554 fi 555 $(PKGDEBUG)$(RM) $(@).vars 556 557$(PDIR)/%.dep: $(PDIR)/%.mog 558 @print "Generating dependencies for $(<F)" 559 $(PKGDEBUG)$(RM) $(@) 560 $(PKGDEBUG)if [ ! -f $(@:%.dep=%.nodepend) ]; then \ 561 pkgdepend generate -m $(PKGDEP_TOKENS:%=-D %) $(<) \ 562 $(PKGROOT) > $(@); \ 563 else \ 564 $(CP) $(<) $(@); \ 565 fi 566 567# 568# The full chain implies that there should be a .dep.res suffix rule, 569# but dependency generation is done on a set of manifests, rather than 570# on a per-manifest basis. Instead, see the gendeps rule above. 571# 572 573$(PDIR)/%.pub: $(PDIR)/%.res 574 $(PKGDEBUG)m=$$(basename $(@:%.pub=%).metadata.*); \ 575 r=$${m#$(@F:%.pub=%.metadata.)+(?).}; \ 576 if [ -s $(<) ]; then \ 577 print "Publishing $(@F:%.pub=%) to $$r repository"; \ 578 pkgsend -s file://$(PKGDEST)/repo.$$r publish \ 579 -d $(PKGROOT) -d $(TOOLSROOT) \ 580 -d license_files -d $(PKGROOT)/licenses \ 581 --fmri-in-manifest --no-index --no-catalog $(<) \ 582 > /dev/null; \ 583 fi; \ 584 $(TOUCH) $(@); 585 586# 587# rule to build the synthetic manifests 588# 589# This rule necessarily has PKGDEP_TYPE that changes according to 590# the specific synthetic manifest. Rather than escape command 591# dependency checking for the real manifest processing, or failing to 592# express the (indirect) dependency of synthetic manifests on real 593# manifests, we simply split this rule out from the one above. 594# 595# The implementation notes from the previous rule are applicable 596# here, too. 597# 598$(PROC_SYNTH_PKGS): $(PKGLISTS) $$(@F:%.mog=%.mf) 599 @print "Processing synthetic manifest $(@F:%.mog=%.mf)" 600 $(PKGDEBUG)$(RM) $(@) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars 601 $(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) -I transforms -I $(PDIR) \ 602 $(PKGMOG_DEFINES:%=-D %) -D PKGDEP_TYPE=$(PKGDEP_TYPE) \ 603 -P $(@).vars -O $(@) $(@F:%.mog=%.mf) \ 604 $(PM_TRANSFORMS) synthetic 605 $(PKGDEBUG)eval REPO=redist PKGSTAT=current `$(CAT) -s $(@).vars`; \ 606 if [ -f $(@) ]; then \ 607 $(LN) -s $(@F) \ 608 $(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \ 609 else \ 610 $(TOUCH) $(@); \ 611 fi 612 $(PKGDEBUG)$(RM) $(@).vars 613 614$(DEP_SYNTH_PKGS): $$(@:%.dep=%.mog) 615 @print "Skipping dependency generation for $(@F:%.dep=%)" 616 $(PKGDEBUG)$(CP) $(@:%.dep=%.mog) $(@) 617 618clean: 619 620clobber: clean 621 $(RM) -r $(CLOBBERFILES) 622 623# 624# This rule assumes that all links in the $PKGSTAT directories 625# point to valid manifests, and will fail the make run if one 626# does not contain an fmri. 627# 628# We do this in the BEGIN action instead of using pattern matching 629# because we expect the fmri to be at or near the first line of each input 630# file, and this way lets us avoid reading the rest of the file after we 631# find what we need. 632# 633# We keep track of a failure to locate an fmri, so we can fail the 634# make run, but we still attempt to process each package in the 635# repo/pkgstat-specific subdir, in hopes of maybe giving some 636# additional useful info. 637# 638# The protolist is used for bfu archive creation, which may be invoked 639# interactively by the user. Both protolist and PKGLISTS targets 640# depend on $(PROC_PKGS), but protolist builds them recursively. 641# To avoid collisions, we insert protolist into the dependency chain 642# here. This has two somewhat subtle benefits: it allows bfu archive 643# creation to work correctly, even when -a was not part of NIGHTLY_OPTIONS, 644# and it ensures that a protolist file here will always correspond to the 645# contents of the processed manifests, which can vary depending on build 646# environment. 647# 648$(PKGLISTS): $(PROC_PKGS) 649 $(PKGDEBUG)sdotr=$(@F:packages.%=%); \ 650 r=$${sdotr%.+(?)}; s=$${sdotr#+(?).}; \ 651 print "Generating $$r $$s package list"; \ 652 $(RM) $(@); $(TOUCH) $(@); \ 653 $(AWK) 'BEGIN { \ 654 if (ARGC < 2) { \ 655 exit; \ 656 } \ 657 retcode = 0; \ 658 for (i = 1; i < ARGC; i++) { \ 659 do { \ 660 e = getline f < ARGV[i]; \ 661 } while ((e == 1) && (f !~ /name=pkg.fmri/)); \ 662 close(ARGV[i]); \ 663 if (e == 1) { \ 664 l = split(f, a, "="); \ 665 print "depend fmri=" a[l], \ 666 "type=$$(PKGDEP_TYPE)"; \ 667 } else { \ 668 print "no fmri in " ARGV[i] >> "/dev/stderr"; \ 669 retcode = 2; \ 670 } \ 671 } \ 672 exit retcode; \ 673 }' `find $(PDIR) -type l -a \( $(PKGS:%=-name %.metadata.$$s.$$r -o) \ 674 -name NOSUCHFILE \)` >> $(@) 675 676# 677# rules to validate proto area against manifests, check for safe 678# file permission modes, and generate a faux proto list 679# 680# For the check targets, the dependencies on $(PROC_PKGS) is specified 681# as a subordinate make process in order to suppress output. 682# 683makesilent: 684 @$(MAKE) -e $(PROC_PKGS) PKGMACH=$(PKGMACH) \ 685 SUPPRESSPKGDEP=$(SUPPRESSPKGDEP) > /dev/null 686 687# 688# The .lics files were created during pkgmogrification, and list the 689# set of licenses to pull from $SRC for each package. Because 690# licenses may be duplicated between packages, we uniquify them as 691# well as aggregating them here. 692# 693license-list: makesilent 694 $(PKGDEBUG)( for l in `cat $(PROC_PKGS:%.mog=%.lics)`; \ 695 do print $$l; done ) | sort -u > $@ 696 697# 698# Staging the license and description files in the proto area allows 699# us to do proper unreferenced file checking of both license and 700# description files without blanket exceptions, and to pull license 701# content without reference to $CODEMGR_WS during publication. 702# 703stage-licenses: license-list FRC 704 $(PKGDEBUG)$(MAKE) -e -f Makefile.lic \ 705 PKGDEBUG=$(PKGDEBUG) LICROOT=$(PKGROOT)/licenses \ 706 `$(AWK) '{ \ 707 print "$(PKGROOT)/licenses/" $$0; \ 708 print "$(PKGROOT)/licenses/" $$0 ".descrip"; \ 709 }' license-list` > /dev/null; 710 711protocmp: makesilent 712 @validate_pkg -a $(PKGMACH) -v \ 713 $(EXCEPTIONS:%=-e $(CODEMGR_WS)/exception_lists/%) \ 714 -m $(PDIR) -p $(PKGROOT) -p $(TOOLSROOT) 715 716pmodes: makesilent 717 @validate_pkg -a $(PKGMACH) -M -m $(PDIR) \ 718 -e $(CODEMGR_WS)/exception_lists/pmodes 719 720check: protocmp pmodes 721 722protolist: proto_list_$(PKGMACH) 723 724proto_list_$(PKGMACH): $(PROC_PKGS) 725 @validate_pkg -a $(PKGMACH) -L -m $(PDIR) > $(@) 726 727$(PROC_PKGS): $(PDIR) 728 729# 730# This is a convenience target to allow package names to function as 731# build targets. Generally, using it is only useful when iterating on 732# development of a manifest. 733# 734# When processing a manifest, use the basename (without extension) of 735# the package. When publishing, use the basename with a ".pub" 736# extension. 737# 738# Other than during manifest development, the preferred usage is to 739# avoid these targets and override PKGS on the make command line and 740# use the provided all and install targets. 741# 742$(PKGS) $(SYNTH_PKGS): $(PDIR)/$$(@:%=%.mog) 743 744$(PKGS:%=%.pub) $(SYNTH_PKGS:%=%.pub): $(PDIR)/$$(@) 745 746# 747# This is a convenience target to resolve dependencies without publishing 748# packages. 749# 750gendeps: $(PDIR)/gendeps 751 752# 753# These are convenience targets for cross-platform packaging. If you 754# want to build any of "the normal" targets for a different 755# architecture, simply use "arch/target" as your build target. 756# 757# Since the most common use case for this is "install," the architecture 758# specific install targets have been further abbreviated to elide "/install." 759# 760i386/% sparc/%: 761 $(MAKE) -e $(@F) PKGMACH=$(@D) SUPPRESSPKGDEP=$(SUPPRESSPKGDEP) 762 763i386 sparc: $$(@)/install 764 765FRC: 766