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