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