Unleashed v1.2
[unleashed.git] / usr / src / pkg / Makefile
blobea1f084c043cd9a8e297c518721d8f029f9a92e3
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
31 # Make sure we're getting a consistent execution environment for the
32 # embedded scripts.
34 SHELL= /usr/bin/ksh93
37 # To suppress package dependency generation on any system, regardless
38 # of how it was installed, set SUPPRESSPKGDEP=true in the build
39 # environment.
41 SUPPRESSPKGDEP= false
44 # Comment this line out or set "PKGDEBUG=" in your build environment
45 # to get more verbose output from the make processes in usr/src/pkg
47 PKGDEBUG= @
49 # Hackery to deal with uname transition
50 SETLEGACYUNAME:sh= if [ `uname` != SunOS ]; then echo puname; fi
53 # Cross platform packaging notes
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.
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.
64 # For this to work correctly, the following must all happen:
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.
87 # Refer also to the convenience targets defined later in this
88 # Makefile.
90 PKGMACH= $(MACH)
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.
97 PKGROOT.cmd= print $(ROOT) | sed -e s:/root_$(MACH):/root_$(PKGMACH):
98 PKGROOT= $(PKGROOT.cmd:sh)
99 TOOLSROOT.cmd= print $(TOOLS_PROTO) | sed -e s:/root_$(MACH):/root_$(PKGMACH):
100 TOOLSROOT= $(TOOLSROOT.cmd:sh)
101 PKGDEST.cmd= print $(PKGARCHIVE) | sed -e s:/$(MACH)/:/$(PKGMACH)/:
102 PKGDEST= $(PKGDEST.cmd:sh)
104 EXCEPTIONS= packaging
106 PKGMOGRIFY= pkgmogrify
109 # Always build the redistributable repository, but only build the
110 # nonredistributable bits if we have access to closed source.
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.
117 REPOS= redist
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.
124 # Nothing underneath $(PDIR) should ever be managed by SCM.
126 PDIR= packages.$(PKGMACH)
129 # The tools proto must be specified for dependency generation.
130 # Publication from the tools proto area is managed in the
131 # publication rule.
133 $(PDIR)/developer-build-onbld.dep:= PKGROOT= $(TOOLSROOT)
136 # To get these defaults, manifests should simply refer to $(PKGVERS).
138 # NOTE WELL:
139 # Because of the circular dependencies in the osnet incorporation, it
140 # is COMPLETELY AND UTTERLY IMPOSSIBLE TO UPDATE YOUR SYSTEM if your
141 # build doesn't have the same leading components. CHANGE THIS AT YOUR
142 # OWN RISK. If you're not using an existing distro, feel free to change
143 # this in your environment. This setting has no impact on tools that
144 # don't examine packaging versions.
146 PKGVERS_COMPONENT= 1.2
147 PKGVERS_BUILTON= 5.11
148 PKGVERS_BRANCH=
149 PKGVERS= $(PKGVERS_COMPONENT),$(PKGVERS_BUILTON)$(PKGVERS_BRANCH)
152 # The ARCH32 and ARCH64 macros are used in the manifests to express
153 # architecture-specific subdirectories in the installation paths
154 # for isaexec'd commands.
156 # We can't simply use $(MACH32) and $(MACH64) here, because they're
157 # only defined for the build architecture. To do cross-platform
158 # packaging, we need both values.
160 i386_ARCH32= i386
161 i386_ARCH64= amd64
164 # macros and transforms needed by pkgmogrify
166 # If you append to this list using target-specific assignments (:=),
167 # be very careful that the targets are of the form $(PDIR)/pkgname. If
168 # you use a higher level target, or a package list, you'll trigger a
169 # complete reprocessing of all manifests because they'll fail command
170 # dependency checking.
172 PM_TRANSFORMS= common_actions publish restart_fmri facets defaults \
173 extract_metadata
174 PM_INC= transforms manifests
176 PKGMOG_DEFINES= \
177 ARCH=$(PKGMACH) \
178 ARCH32=$($(PKGMACH)_ARCH32) \
179 ARCH64=$($(PKGMACH)_ARCH64) \
180 PKGVERS_COMPONENT=$(PKGVERS_COMPONENT) \
181 PKGVERS_BUILTON=$(PKGVERS_BUILTON) \
182 PKGVERS_BRANCH=$(PKGVERS_BRANCH) \
183 PKGVERS=$(PKGVERS) \
184 ENABLE_PERL64=$(ENABLE_PERL64) \
185 PERL_ARCH=$(PERL_ARCH) \
186 PERL_ARCH64=$(PERL_ARCH64) \
187 PERL_VERSION=$(PERL_VERSION) \
188 PERL_PKGVERS=$(PERL_PKGVERS) \
189 PYTHON_VERSION=$(PYTHON_VERSION) \
190 PYTHON_PKGVERS=$(PYTHON_PKGVERS) \
191 HUMAN_VERSION=$(VERSION)
193 PKGDEP_TOKENS_i386= \
194 'ISALIST=amd64' \
195 'ISALIST=i386'
196 PKGDEP_TOKENS= $(PKGDEP_TOKENS_$(PKGMACH))
199 # The package lists are generated with $(PKGDEP_TYPE) as their
200 # dependency types, so that they can be included by either an
201 # incorporation or a group package.
203 $(PDIR)/osnet-redist.mog := PKGDEP_TYPE= require
204 $(PDIR)/osnet-incorporation.mog:= PKGDEP_TYPE= incorporate
206 PKGDEP_INCORP= \
207 depend fmri=consolidation/osnet/osnet-incorporation type=require
210 # All packaging build products should go into $(PDIR), so they don't
211 # need to be included separately in CLOBBERFILES.
213 CLOBBERFILES= $(PDIR) proto_list_$(PKGMACH) install-$(PKGMACH).out \
214 license-list
217 # By default, PKGS will list all manifests. To build and/or publish a
218 # subset of packages, override this on the command line or in the
219 # build environment and then reference (implicitly or explicitly) the all
220 # or install targets.
222 MANIFESTS :sh= (cd manifests; print *.mf)
224 PKGS= $(MANIFESTS:%.mf=%)
225 DEP_PKGS= $(PKGS:%=$(PDIR)/%.dep)
226 PROC_PKGS= $(PKGS:%=$(PDIR)/%.mog)
229 # Track the synthetic manifests separately so we can properly express
230 # build rules and dependencies. The synthetic and real packages use
231 # different sets of transforms and macros for pkgmogrify.
233 SYNTH_PKGS= osnet-incorporation osnet-redist
234 DEP_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.dep)
235 PROC_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.mog)
238 # Root of pkg image to use for dependency resolution
239 # Normally / on the machine used to build the binaries
241 PKGDEP_RESOLVE_IMAGE = /
244 # For each package, we determine the target repository based on
245 # manifest-embedded metadata. Because we make that determination on
246 # the fly, the publication target cannot be expressed as a
247 # subdirectory inside the unknown-by-the-makefile target repository.
249 # In order to limit the target set to real files in known locations,
250 # we use a ".pub" file in $(PDIR) for each processed manifest, regardless
251 # of content or target repository.
253 PUB_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.pub) $(PKGS:%=$(PDIR)/%.pub)
256 # Any given repository- and status-specific package list may be empty,
257 # but we can only determine that dynamically, so we always generate all
258 # lists for each repository we're building.
260 # The meanings of each package status are as follows:
262 # PKGSTAT meaning
263 # ---------- ----------------------------------------------------
264 # noincorp Do not include in incorporation or group package
265 # obsolete Include in incorporation, but not group package
266 # renamed Include in incorporation, but not group package
267 # current Include in incorporation and group package
269 # Since the semantics of the "noincorp" package status dictate that
270 # such packages are not included in the incorporation or group packages,
271 # there is no need to build noincorp package lists.
273 PKGLISTS= \
274 $(REPOS:%=$(PDIR)/packages.%.current) \
275 $(REPOS:%=$(PDIR)/packages.%.renamed) \
276 $(REPOS:%=$(PDIR)/packages.%.obsolete)
278 .KEEP_STATE:
280 .PARALLEL: $(PKGS) $(PROC_PKGS) $(DEP_PKGS) \
281 $(PROC_SYNTH_PKGS) $(DEP_SYNTH_PKGS) $(PUB_PKGS)
284 # For a single manifest, the dependency chain looks like this:
286 # raw manifest (mypkg.mf)
288 # | use pkgmogrify to process raw manifest
290 # processed manifest (mypkg.mog)
292 # * | use pkgdepend generate to generate dependencies
294 # manifest with TBD dependencies (mypkg.dep)
296 # % | use pkgdepend resolve to resolve dependencies
298 # manifest with dependencies resolved (mypkg.res)
300 # | use pkgsend to publish the package
302 # placeholder to indicate successful publication (mypkg.pub)
304 # * This may be suppressed via SUPPRESSPKGDEP. The resulting
305 # packages will install correctly, but care must be taken to
306 # install all dependencies, because pkg will not have the input
307 # it needs to determine this automatically.
309 # % This is included in this diagram to make the picture complete, but
310 # this is a point of synchronization in the build process.
311 # Dependency resolution is actually done once on the entire set of
312 # manifests, not on a per-package basis.
314 # The full dependency chain for generating everything that needs to be
315 # published, without actually publishing it, looks like this:
317 # processed synthetic packages
318 # | |
319 # package lists synthetic package manifests
321 # processed real packages
322 # | |
323 # package dir real package manifests
325 # Here, each item is a set of real or synthetic packages. For this
326 # portion of the build, no reference is made to the proto area. It is
327 # therefore suitable for the "all" target, as opposed to "install."
329 # Since each of these steps is expressed explicitly, "all" need only
330 # depend on the head of the chain.
332 # From the end of manifest processing, the publication dependency
333 # chain looks like this:
335 # repository metadata (catalogs and search indices)
337 # | pkgrepo refresh
339 # published packages
340 # | |
341 # | | pkgsend publish
342 # | |
343 # repositories resolved dependencies
344 # | |
345 # pkgsend | | pkgdepend resolve
346 # create-repository |
347 # | generated dependencies
348 # repo directories |
349 # | pkgdepend
351 # processed manifests
354 ALL_TARGETS= $(PROC_SYNTH_PKGS) proto_list_$(PKGMACH)
356 all: $(ALL_TARGETS)
359 # This will build the directory to contain the processed manifests
360 # and the metadata symlinks.
362 $(PDIR):
363 @print "Creating $(@)"
364 $(PKGDEBUG)$(INS.dir)
367 # This rule resolves dependencies across all published manifests.
369 # We shouldn't have to ignore the error from pkgdepend, but until
370 # 16012 and its dependencies are resolved, pkgdepend will always exit
371 # with an error.
373 # Note that for now pkgdepend relies on uname -s -r == SunOS 5.11.
374 # This is a bug inherited via its use of terminatorlib via simpljson.
376 $(PDIR)/gendeps: $(DEP_SYNTH_PKGS) $(DEP_PKGS)
377 -$(PKGDEBUG)if [ "$(SUPPRESSPKGDEP)" = "true" ]; then \
378 print "Suppressing dependency resolution"; \
379 for p in $(DEP_PKGS:%.dep=%); do \
380 $(CP) $$p.dep $$p.res; \
381 done; \
382 else \
383 print "Resolving dependencies"; \
384 $(SETLEGACYUNAME) pkgdepend -R $(PKGDEP_RESOLVE_IMAGE) resolve \
385 -m $(DEP_SYNTH_PKGS) $(DEP_PKGS); \
386 for p in $(DEP_SYNTH_PKGS:%.dep=%) $(DEP_PKGS:%.dep=%); do \
387 if [ "$$(print $$p.metadata.*)" = \
388 "$$(print $$p.metadata.noincorp.*)" ]; \
389 then \
390 print "Removing dependency versions from $$p"; \
391 $(PKGMOGRIFY) $(PKGMOG_VERBOSE) \
392 -O $$p.res -I transforms \
393 strip_versions $$p.dep.res; \
394 $(RM) $$p.dep.res; \
395 else \
396 $(MV) $$p.dep.res $$p.res; \
397 fi; \
398 done; \
400 $(PKGDEBUG)$(TOUCH) $(@)
402 install: $(ALL_TARGETS) repository-metadata
404 repository-metadata: publish_pkgs
405 $(PKGDEBUG)for r in $(REPOS); do \
406 pkgrepo refresh -s $(PKGDEST)/repo.$$r; \
407 done
410 # Since we create zero-length processed manifests for a graceful abort
411 # from pkgmogrify, we need to detect that here and make no effort to
412 # publish the package.
414 # For all other packages, we publish them regardless of status. We
415 # derive the target repository as a component of the metadata-derived
416 # symlink for each package.
418 publish_pkgs: $(REPOS:%=$(PKGDEST)/repo.%) $(PDIR)/gendeps .WAIT $(PUB_PKGS)
421 # Before publishing, we want to pull the license files from $SRCTOP
422 # into the proto area. This allows us to NOT pass $SRC (or
423 # $SRCTOP) as a basedir for publication.
425 $(PUB_PKGS): stage-licenses
428 # Initialize the empty on-disk repositories
430 $(REPOS:%=$(PKGDEST)/repo.%):
431 @print "Initializing $(@F)"
432 $(PKGDEBUG)$(INS.dir)
433 $(PKGDEBUG)pkgsend -s file://$(@) create-repository \
434 --set-property publisher.prefix=$(PKGPUBLISHER)
437 # rule to process real manifests
439 # To allow redistributability and package status to change, we must
440 # remove not only the actual build target (the processed manifest), but
441 # also the incidental ones (the metadata-derived symlinks).
443 # If pkgmogrify exits cleanly but fails to create the specified output
444 # file, it means that it encountered an abort directive. That means
445 # that this package should not be published for this particular build
446 # environment. Since we can't prune such packages from $(PKGS)
447 # retroactively, we need to create an empty target file to keep make
448 # from trying to rebuild it every time. For these empty targets, we
449 # do not create metadata symlinks.
451 # Automatic dependency resolution to files is also done at this phase of
452 # processing. The skipped packages are skipped due to existing bugs
453 # in pkgdepend.
455 # The incorporation dependency is tricky: it needs to go into all
456 # current and renamed manifests (ie all incorporated packages), but we
457 # don't know which those are until after we run pkgmogrify. So
458 # instead of expressing it as a transform, we tack it on ex post facto.
460 # Implementation notes:
462 # - The first $(RM) must not match other manifests, or we'll run into
463 # race conditions with parallel manifest processing.
465 # - The make macros [ie $(MACRO)] are evaluated when the makefile is
466 # read in, and will result in a fixed, macro-expanded rule for each
467 # target enumerated in $(PROC_PKGS).
469 # - The shell variables (ie $$VAR) are assigned on the fly, as the rule
470 # is executed. The results may only be referenced in the shell in
471 # which they are assigned, so from the perspective of make, all code
472 # that needs these variables needs to be part of the same line of
473 # code. Hence the use of command separators and line continuation
474 # characters.
476 # - The extract_metadata transforms are designed to spit out shell
477 # variable assignments to stdout. Those are published to the
478 # .vars temporary files, and then used as input to the eval
479 # statement. This is done in stages specifically so that pkgmogrify
480 # can signal failure if the manifest has a syntactic or other error.
481 # The eval statement should begin with the default values, and the
482 # output from pkgmogrify (if any) should be in the form of a
483 # variable assignment to override those defaults.
485 # - When this rule completes execution, it must leave an updated
486 # target file ($@) in place, or make will reprocess the package
487 # every time it encounters it as a dependency. Hence the "touch"
488 # statement to ensure that the target is created, even when
489 # pkgmogrify encounters an abort in the publish transforms.
492 .SUFFIXES: .mf .mog .dep .res .pub
494 $(PDIR)/%.mog: manifests/%.mf
495 @print "Processing manifest $(<F)"
496 $(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) $(@:%.mog=%.nodepend) \
497 $(@:%.mog=%.lics) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars
498 $(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \
499 $(PKGMOG_DEFINES:%=-D %) -P $(@).vars -O $(@) \
500 $(<) $(PM_TRANSFORMS)
501 $(PKGDEBUG)eval REPO=redist PKGSTAT=current NODEPEND=$(SUPPRESSPKGDEP) \
502 `$(CAT) -s $(@).vars`; \
503 if [ -f $(@) ]; then \
504 if [ "$$NODEPEND" != "false" ]; then \
505 $(TOUCH) $(@:%.mog=%.nodepend); \
506 fi; \
507 $(LN) -s $(@F) \
508 $(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \
509 if [ \( "$$PKGSTAT" = "current" \) -o \
510 \( "$$PKGSTAT" = "renamed" \) ]; \
511 then print $(PKGDEP_INCORP) >> $(@); \
512 fi; \
513 print $$LICS > $(@:%.mog=%.lics); \
514 else \
515 $(TOUCH) $(@) $(@:%.mog=%.lics); \
517 $(PKGDEBUG)$(RM) $(@).vars
519 $(PDIR)/%.dep: $(PDIR)/%.mog
520 @print "Generating dependencies for $(<F)"
521 $(PKGDEBUG)$(RM) $(@)
522 $(PKGDEBUG)if [ ! -f $(@:%.dep=%.nodepend) ]; then \
523 $(SETLEGACYUNAME) pkgdepend generate -m \
524 $(PKGDEP_TOKENS:%=-D %) $(<) $(PKGROOT) > $(@); \
525 else \
526 $(CP) $(<) $(@); \
530 # The full chain implies that there should be a .dep.res suffix rule,
531 # but dependency generation is done on a set of manifests, rather than
532 # on a per-manifest basis. Instead, see the gendeps rule above.
535 $(PDIR)/%.pub: $(PDIR)/%.res
536 $(PKGDEBUG)m=$$(basename $(@:%.pub=%).metadata.*); \
537 r=$${m#$(@F:%.pub=%.metadata.)+(?).}; \
538 if [ -s $(<) ]; then \
539 print "Publishing $(@F:%.pub=%) to $$r repository"; \
540 pkgsend -s file://$(PKGDEST)/repo.$$r publish \
541 -d $(PKGROOT) -d $(TOOLSROOT) \
542 -d license_files -d $(PKGROOT)/licenses \
543 --fmri-in-manifest --no-index --no-catalog $(<) \
544 > /dev/null; \
545 fi; \
546 $(TOUCH) $(@);
549 # rule to build the synthetic manifests
551 # This rule necessarily has PKGDEP_TYPE that changes according to
552 # the specific synthetic manifest. Rather than escape command
553 # dependency checking for the real manifest processing, or failing to
554 # express the (indirect) dependency of synthetic manifests on real
555 # manifests, we simply split this rule out from the one above.
557 # The implementation notes from the previous rule are applicable
558 # here, too.
560 $(PROC_SYNTH_PKGS): $(PKGLISTS) $$(@F:%.mog=%.mf)
561 @print "Processing synthetic manifest $(@F:%.mog=%.mf)"
562 $(PKGDEBUG)$(RM) $(@) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars
563 $(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) -I transforms -I $(PDIR) \
564 $(PKGMOG_DEFINES:%=-D %) -D PKGDEP_TYPE=$(PKGDEP_TYPE) \
565 -P $(@).vars -O $(@) $(@F:%.mog=%.mf) \
566 $(PM_TRANSFORMS) synthetic
567 $(PKGDEBUG)eval REPO=redist PKGSTAT=current `$(CAT) -s $(@).vars`; \
568 if [ -f $(@) ]; then \
569 $(LN) -s $(@F) \
570 $(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \
571 else \
572 $(TOUCH) $(@); \
574 $(PKGDEBUG)$(RM) $(@).vars
576 $(DEP_SYNTH_PKGS): $$(@:%.dep=%.mog)
577 @print "Skipping dependency generation for $(@F:%.dep=%)"
578 $(PKGDEBUG)$(CP) $(@:%.dep=%.mog) $(@)
580 clean:
582 clobber: clean
583 $(RM) -r $(CLOBBERFILES)
586 # This rule assumes that all links in the $PKGSTAT directories
587 # point to valid manifests, and will fail the make run if one
588 # does not contain an fmri.
590 # We do this in the BEGIN action instead of using pattern matching
591 # because we expect the fmri to be at or near the first line of each input
592 # file, and this way lets us avoid reading the rest of the file after we
593 # find what we need.
595 # We keep track of a failure to locate an fmri, so we can fail the
596 # make run, but we still attempt to process each package in the
597 # repo/pkgstat-specific subdir, in hopes of maybe giving some
598 # additional useful info.
600 # The protolist is used for bfu archive creation, which may be invoked
601 # interactively by the user. Both protolist and PKGLISTS targets
602 # depend on $(PROC_PKGS), but protolist builds them recursively.
603 # To avoid collisions, we insert protolist into the dependency chain
604 # here. This has two somewhat subtle benefits: it allows bfu archive
605 # creation to work correctly, even when -a was not part of NIGHTLY_OPTIONS,
606 # and it ensures that a protolist file here will always correspond to the
607 # contents of the processed manifests, which can vary depending on build
608 # environment.
610 $(PKGLISTS): $(PROC_PKGS)
611 $(PKGDEBUG)sdotr=$(@F:packages.%=%); \
612 r=$${sdotr%.+(?)}; s=$${sdotr#+(?).}; \
613 print "Generating $$r $$s package list"; \
614 $(RM) $(@); $(TOUCH) $(@); \
615 $(AWK) 'BEGIN { \
616 if (ARGC < 2) { \
617 exit; \
619 retcode = 0; \
620 for (i = 1; i < ARGC; i++) { \
621 do { \
622 e = getline f < ARGV[i]; \
623 } while ((e == 1) && (f !~ /name=pkg.fmri/)); \
624 close(ARGV[i]); \
625 if (e == 1) { \
626 l = split(f, a, "="); \
627 print "depend fmri=" a[l], \
628 "type=$$(PKGDEP_TYPE)"; \
629 } else { \
630 print "no fmri in " ARGV[i] >> "/dev/stderr"; \
631 retcode = 2; \
634 exit retcode; \
635 }' `find $(PDIR) -type l -a \( $(PKGS:%=-name %.metadata.$$s.$$r -o) \
636 -name NOSUCHFILE \)` >> $(@)
639 # rules to validate proto area against manifests, check for safe
640 # file permission modes, and generate a faux proto list
642 # For the check targets, the dependencies on $(PROC_PKGS) is specified
643 # as a subordinate make process in order to suppress output.
645 makesilent:
646 @$(MAKE) -e $(PROC_PKGS) PKGMACH=$(PKGMACH) \
647 SUPPRESSPKGDEP=$(SUPPRESSPKGDEP) > /dev/null
650 # The .lics files were created during pkgmogrification, and list the
651 # set of licenses to pull from $SRC for each package. Because
652 # licenses may be duplicated between packages, we uniquify them as
653 # well as aggregating them here.
655 license-list: makesilent
656 $(PKGDEBUG)( for l in `cat $(PROC_PKGS:%.mog=%.lics)`; \
657 do print $$l; done ) | sort -u > $@
660 # Staging the license and description files in the proto area allows
661 # us to do proper unreferenced file checking of both license and
662 # description files without blanket exceptions, and to pull license
663 # content without reference to $SRCTOP during publication.
665 stage-licenses: license-list FRC
666 $(PKGDEBUG)$(MAKE) -e -f Makefile.lic \
667 PKGDEBUG=$(PKGDEBUG) LICROOT=$(PKGROOT)/licenses \
668 `$(AWK) '{ \
669 print "$(PKGROOT)/licenses/" $$0; \
670 print "$(PKGROOT)/licenses/" $$0 ".descrip"; \
671 }' license-list` > /dev/null;
673 protocmp: makesilent
674 @validate_pkg -a $(PKGMACH) -v \
675 $(EXCEPTIONS:%=-e $(SRCTOP)/exception_lists/%) \
676 -m $(PDIR) -p $(PKGROOT) -p $(TOOLSROOT)
678 pmodes: makesilent
679 @validate_pkg -a $(PKGMACH) -M -m $(PDIR) \
680 -e $(SRCTOP)/exception_lists/pmodes
682 check: protocmp pmodes
684 protolist: proto_list_$(PKGMACH)
686 proto_list_$(PKGMACH): $(PROC_PKGS)
687 @validate_pkg -a $(PKGMACH) -L -m $(PDIR) > $(@)
689 $(PROC_PKGS): $(PDIR)
692 # This is a convenience target to allow package names to function as
693 # build targets. Generally, using it is only useful when iterating on
694 # development of a manifest.
696 # When processing a manifest, use the basename (without extension) of
697 # the package. When publishing, use the basename with a ".pub"
698 # extension.
700 # Other than during manifest development, the preferred usage is to
701 # avoid these targets and override PKGS on the make command line and
702 # use the provided all and install targets.
704 $(PKGS) $(SYNTH_PKGS): $(PDIR)/$$(@:%=%.mog)
706 $(PKGS:%=%.pub) $(SYNTH_PKGS:%=%.pub): $(PDIR)/$$(@)
709 # This is a convenience target to resolve dependencies without publishing
710 # packages.
712 gendeps: $(PDIR)/gendeps
715 # These are convenience targets for cross-platform packaging. If you
716 # want to build any of "the normal" targets for a different
717 # architecture, simply use "arch/target" as your build target.
719 # Since the most common use case for this is "install," the architecture
720 # specific install targets have been further abbreviated to elide "/install."
722 i386/%:
723 $(MAKE) -e $(@F) PKGMACH=$(@D) SUPPRESSPKGDEP=$(SUPPRESSPKGDEP)
725 i386: $$(@)/install
727 FRC: