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