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