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