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