xref: /illumos-gate/usr/src/pkg/Makefile (revision ac823a0f31ed9c8cbe505cee2def262ac92ea6cd)
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# Root of pkg image to use for dependency resolution
231# Normally / on the machine used to build the binaries
232#
233PKGDEP_RESOLVE_IMAGE = /
234
235#
236# For each package, we determine the target repository based on
237# manifest-embedded metadata.  Because we make that determination on
238# the fly, the publication target cannot be expressed as a
239# subdirectory inside the unknown-by-the-makefile target repository.
240#
241# In order to limit the target set to real files in known locations,
242# we use a ".pub" file in $(PDIR) for each processed manifest, regardless
243# of content or target repository.
244#
245PUB_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.pub) $(PKGS:%=$(PDIR)/%.pub)
246
247#
248# Any given repository- and status-specific package list may be empty,
249# but we can only determine that dynamically, so we always generate all
250# lists for each repository we're building.
251#
252# The meanings of each package status are as follows:
253#
254# 	PKGSTAT		meaning
255# 	----------	----------------------------------------------------
256# 	noincorp	Do not include in incorporation or group package
257#	obsolete	Include in incorporation, but not group package
258#	renamed		Include in incorporation, but not group package
259#	current		Include in incorporation and group package
260#
261# Since the semantics of the "noincorp" package status dictate that
262# such packages are not included in the incorporation or group packages,
263# there is no need to build noincorp package lists.
264#
265PKGLISTS= \
266	$(REPOS:%=$(PDIR)/packages.%.current) \
267	$(REPOS:%=$(PDIR)/packages.%.renamed) \
268	$(REPOS:%=$(PDIR)/packages.%.obsolete)
269
270.KEEP_STATE:
271
272.PARALLEL: $(PKGS) $(PROC_PKGS) $(DEP_PKGS) \
273	$(PROC_SYNTH_PKGS) $(DEP_SYNTH_PKGS) $(PUB_PKGS)
274
275#
276# For a single manifest, the dependency chain looks like this:
277#
278#	raw manifest (mypkg.mf)
279#		|
280#		| use pkgmogrify to process raw manifest
281#		|
282#	processed manifest (mypkg.mog)
283#		|
284#	   *    | use pkgdepend generate to generate dependencies
285#		|
286#	manifest with TBD dependencies (mypkg.dep)
287#		|
288#	   %    | use pkgdepend resolve to resolve dependencies
289#		|
290#	manifest with dependencies resolved (mypkg.res)
291#		|
292#		| use pkgsend to publish the package
293#		|
294#	placeholder to indicate successful publication (mypkg.pub)
295#
296# * This may be suppressed via SUPPRESSPKGDEP.  The resulting
297#   packages will install correctly, but care must be taken to
298#   install all dependencies, because pkg will not have the input
299#   it needs to determine this automatically.
300#
301# % This is included in this diagram to make the picture complete, but
302#   this is a point of synchronization in the build process.
303#   Dependency resolution is actually done once on the entire set of
304#   manifests, not on a per-package basis.
305#
306# The full dependency chain for generating everything that needs to be
307# published, without actually publishing it, looks like this:
308#
309#	processed synthetic packages
310#		|		|
311#       package lists	    synthetic package manifests
312#		|
313#	processed real packages
314#	    |		|
315#	package dir	real package manifests
316#
317# Here, each item is a set of real or synthetic packages.  For this
318# portion of the build, no reference is made to the proto area.  It is
319# therefore suitable for the "all" target, as opposed to "install."
320#
321# Since each of these steps is expressed explicitly, "all" need only
322# depend on the head of the chain.
323#
324# From the end of manifest processing, the publication dependency
325# chain looks like this:
326#
327#		repository metadata (catalogs and search indices)
328#			|
329#			| pkg.depotd
330#			|
331#		published packages
332#		 |		|
333#		 |		| pkgsend publish
334#		 |		|
335#	  repositories 	    resolved dependencies
336#		 |			|
337# pkgsend	 |			| pkgdepend resolve
338# create-repository	 	 	|
339#		 |		generated dependencies
340#	 repo directories		|
341#					| pkgdepend
342#					|
343#				processed manifests
344#
345
346ALL_TARGETS= $(PROC_SYNTH_PKGS) proto_list_$(PKGMACH)
347
348all: $(ALL_TARGETS)
349
350#
351# This will build the directory to contain the processed manifests
352# and the metadata symlinks.
353#
354$(PDIR):
355	@print "Creating $(@)"
356	$(PKGDEBUG)$(INS.dir)
357
358#
359# This rule resolves dependencies across all published manifests.
360#
361# We shouldn't have to ignore the error from pkgdepend, but until
362# 16012 and its dependencies are resolved, pkgdepend will always exit
363# with an error.
364#
365$(PDIR)/gendeps: $(DEP_SYNTH_PKGS) $(DEP_PKGS)
366	-$(PKGDEBUG)if [ "$(SUPPRESSPKGDEP)" = "true" ]; then \
367		print "Suppressing dependency resolution"; \
368		for p in $(DEP_PKGS:%.dep=%); do \
369			$(CP) $$p.dep $$p.res; \
370		done; \
371	else \
372		print "Resolving dependencies"; \
373		pkgdepend -R $(PKGDEP_RESOLVE_IMAGE) resolve \
374		    -m $(DEP_SYNTH_PKGS) $(DEP_PKGS); \
375		for p in $(DEP_SYNTH_PKGS:%.dep=%) $(DEP_PKGS:%.dep=%); do \
376			if [ "$$(print $$p.metadata.*)" = \
377			     "$$(print $$p.metadata.noincorp.*)" ]; \
378			then \
379				print "Removing dependency versions from $$p"; \
380				$(PKGMOGRIFY) $(PKGMOG_VERBOSE) \
381				    -O $$p.res -I transforms \
382				    strip_versions $$p.dep.res; \
383				$(RM) $$p.dep.res; \
384			else \
385				$(MV) $$p.dep.res $$p.res; \
386			fi; \
387		done; \
388	fi
389	$(PKGDEBUG)$(TOUCH) $(@)
390
391install: $(ALL_TARGETS) repository-metadata
392
393repository-metadata: publish_pkgs
394	@print "Creating repository metadata"
395	$(PKGDEBUG)for r in $(REPOS); do \
396		/usr/lib/pkg.depotd -d $(PKGDEST)/repo.$$r \
397			--add-content --exit-ready; \
398	done
399
400#
401# Since we create zero-length processed manifests for a graceful abort
402# from pkgmogrify, we need to detect that here and make no effort to
403# publish the package.
404#
405# For all other packages, we publish them regardless of status.  We
406# derive the target repository as a component of the metadata-derived
407# symlink for each package.
408#
409publish_pkgs: $(REPOS:%=$(PKGDEST)/repo.%) $(PDIR)/gendeps .WAIT $(PUB_PKGS)
410
411#
412# Before publishing, we want to pull the license files from $CODEMGR_WS
413# into the proto area.  This allows us to NOT pass $SRC (or
414# $CODEMGR_WS) as a basedir for publication.
415#
416$(PUB_PKGS): stage-licenses
417
418#
419# Initialize the empty on-disk repositories
420#
421$(REPOS:%=$(PKGDEST)/repo.%):
422	@print "Initializing $(@F)"
423	$(PKGDEBUG)$(INS.dir)
424	$(PKGDEBUG)pkgsend -s file://$(@) create-repository \
425		--set-property publisher.prefix=$(PKGPUBLISHER)
426
427#
428# rule to process real manifests
429#
430# To allow redistributability and package status to change, we must
431# remove not only the actual build target (the processed manifest), but
432# also the incidental ones (the metadata-derived symlinks).
433#
434# If pkgmogrify exits cleanly but fails to create the specified output
435# file, it means that it encountered an abort directive.  That means
436# that this package should not be published for this particular build
437# environment.  Since we can't prune such packages from $(PKGS)
438# retroactively, we need to create an empty target file to keep make
439# from trying to rebuild it every time.  For these empty targets, we
440# do not create metadata symlinks.
441#
442# Automatic dependency resolution to files is also done at this phase of
443# processing.  The skipped packages are skipped due to existing bugs
444# in pkgdepend.
445#
446# The incorporation dependency is tricky: it needs to go into all
447# current and renamed manifests (ie all incorporated packages), but we
448# don't know which those are until after we run pkgmogrify.  So
449# instead of expressing it as a transform, we tack it on ex post facto.
450#
451# Implementation notes:
452#
453# - The first $(RM) must not match other manifests, or we'll run into
454#   race conditions with parallel manifest processing.
455#
456# - The make macros [ie $(MACRO)] are evaluated when the makefile is
457#   read in, and will result in a fixed, macro-expanded rule for each
458#   target enumerated in $(PROC_PKGS).
459#
460# - The shell variables (ie $$VAR) are assigned on the fly, as the rule
461#   is executed.  The results may only be referenced in the shell in
462#   which they are assigned, so from the perspective of make, all code
463#   that needs these variables needs to be part of the same line of
464#   code.  Hence the use of command separators and line continuation
465#   characters.
466#
467# - The extract_metadata transforms are designed to spit out shell
468#   variable assignments to stdout.  Those are published to the
469#   .vars temporary files, and then used as input to the eval
470#   statement.  This is done in stages specifically so that pkgmogrify
471#   can signal failure if the manifest has a syntactic or other error.
472#   The eval statement should begin with the default values, and the
473#   output from pkgmogrify (if any) should be in the form of a
474#   variable assignment to override those defaults.
475#
476# - When this rule completes execution, it must leave an updated
477#   target file ($@) in place, or make will reprocess the package
478#   every time it encounters it as a dependency.  Hence the "touch"
479#   statement to ensure that the target is created, even when
480#   pkgmogrify encounters an abort in the publish transforms.
481#
482
483.SUFFIXES: .mf .mog .dep .res .pub
484
485$(PDIR)/%.mog: manifests/%.mf
486	@print "Processing manifest $(<F)"
487	@pkgfmt -c $<
488	$(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) $(@:%.mog=%.nodepend) \
489		$(@:%.mog=%.lics) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars
490	$(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \
491		$(PKGMOG_DEFINES:%=-D %) -P $(@).vars -O $(@) \
492		$(<) $(PM_TRANSFORMS)
493	$(PKGDEBUG)eval REPO=redist PKGSTAT=current NODEPEND=$(SUPPRESSPKGDEP) \
494		`$(CAT) -s $(@).vars`; \
495	if [ -f $(@) ]; then \
496		if [ "$$NODEPEND" != "false" ]; then \
497			 $(TOUCH) $(@:%.mog=%.nodepend); \
498		fi; \
499		$(LN) -s $(@F) \
500			$(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \
501		if [ \( "$$PKGSTAT" = "current" \) -o \
502		     \( "$$PKGSTAT" = "renamed" \) ]; \
503			then print $(PKGDEP_INCORP) >> $(@); \
504		fi; \
505		print $$LICS > $(@:%.mog=%.lics); \
506	else \
507		$(TOUCH) $(@) $(@:%.mog=%.lics); \
508	fi
509	$(PKGDEBUG)$(RM) $(@).vars
510
511$(PDIR)/%.dep: $(PDIR)/%.mog
512	@print "Generating dependencies for $(<F)"
513	$(PKGDEBUG)$(RM) $(@)
514	$(PKGDEBUG)if [ ! -f $(@:%.dep=%.nodepend) ]; then \
515		pkgdepend generate -m $(PKGDEP_TOKENS:%=-D %) $(<) \
516			$(PKGROOT) > $(@); \
517	else \
518		$(CP) $(<) $(@); \
519	fi
520
521#
522# The full chain implies that there should be a .dep.res suffix rule,
523# but dependency generation is done on a set of manifests, rather than
524# on a per-manifest basis.  Instead, see the gendeps rule above.
525#
526
527$(PDIR)/%.pub: $(PDIR)/%.res
528	$(PKGDEBUG)m=$$(basename $(@:%.pub=%).metadata.*); \
529	r=$${m#$(@F:%.pub=%.metadata.)+(?).}; \
530	if [ -s $(<) ]; then \
531		print "Publishing $(@F:%.pub=%) to $$r repository"; \
532		pkgsend -s file://$(PKGDEST)/repo.$$r publish \
533		    -d $(PKGROOT) -d $(TOOLSROOT) \
534		    -d license_files -d $(PKGROOT)/licenses \
535		    --fmri-in-manifest --no-index --no-catalog $(<) \
536		    > /dev/null; \
537	fi; \
538	$(TOUCH) $(@);
539
540#
541# rule to build the synthetic manifests
542#
543# This rule necessarily has PKGDEP_TYPE that changes according to
544# the specific synthetic manifest.  Rather than escape command
545# dependency checking for the real manifest processing, or failing to
546# express the (indirect) dependency of synthetic manifests on real
547# manifests, we simply split this rule out from the one above.
548#
549# The implementation notes from the previous rule are applicable
550# here, too.
551#
552$(PROC_SYNTH_PKGS): $(PKGLISTS) $$(@F:%.mog=%.mf)
553	@print "Processing synthetic manifest $(@F:%.mog=%.mf)"
554	$(PKGDEBUG)$(RM) $(@) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars
555	$(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) -I transforms -I $(PDIR) \
556		$(PKGMOG_DEFINES:%=-D %) -D PKGDEP_TYPE=$(PKGDEP_TYPE) \
557		-P $(@).vars -O $(@) $(@F:%.mog=%.mf) \
558		$(PM_TRANSFORMS) synthetic
559	$(PKGDEBUG)eval REPO=redist PKGSTAT=current `$(CAT) -s $(@).vars`; \
560	if [ -f $(@) ]; then \
561		$(LN) -s $(@F) \
562			$(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \
563	else \
564		$(TOUCH) $(@); \
565	fi
566	$(PKGDEBUG)$(RM) $(@).vars
567
568$(DEP_SYNTH_PKGS): $$(@:%.dep=%.mog)
569	@print "Skipping dependency generation for $(@F:%.dep=%)"
570	$(PKGDEBUG)$(CP) $(@:%.dep=%.mog) $(@)
571
572clean:
573
574clobber: clean
575	$(RM) -r $(CLOBBERFILES)
576
577#
578# This rule assumes that all links in the $PKGSTAT directories
579# point to valid manifests, and will fail the make run if one
580# does not contain an fmri.
581#
582# We do this in the BEGIN action instead of using pattern matching
583# because we expect the fmri to be at or near the first line of each input
584# file, and this way lets us avoid reading the rest of the file after we
585# find what we need.
586#
587# We keep track of a failure to locate an fmri, so we can fail the
588# make run, but we still attempt to process each package in the
589# repo/pkgstat-specific subdir, in hopes of maybe giving some
590# additional useful info.
591#
592# The protolist is used for bfu archive creation, which may be invoked
593# interactively by the user.  Both protolist and PKGLISTS targets
594# depend on $(PROC_PKGS), but protolist builds them recursively.
595# To avoid collisions, we insert protolist into the dependency chain
596# here.  This has two somewhat subtle benefits: it allows bfu archive
597# creation to work correctly, even when -a was not part of NIGHTLY_OPTIONS,
598# and it ensures that a protolist file here will always correspond to the
599# contents of the processed manifests, which can vary depending on build
600# environment.
601#
602$(PKGLISTS): $(PROC_PKGS)
603	$(PKGDEBUG)sdotr=$(@F:packages.%=%); \
604	r=$${sdotr%.+(?)}; s=$${sdotr#+(?).}; \
605	print "Generating $$r $$s package list"; \
606	$(RM) $(@); $(TOUCH) $(@); \
607	$(NAWK) 'BEGIN { \
608		if (ARGC < 2) { \
609			exit; \
610		} \
611		retcode = 0; \
612		for (i = 1; i < ARGC; i++) { \
613			do { \
614				e = getline f < ARGV[i]; \
615			} while ((e == 1) && (f !~ /name=pkg.fmri/)); \
616			close(ARGV[i]); \
617			if (e == 1) { \
618				l = split(f, a, "="); \
619				print "depend fmri=" a[l], \
620					"type=$$(PKGDEP_TYPE)"; \
621			} else { \
622				print "no fmri in " ARGV[i] >> "/dev/stderr"; \
623				retcode = 2; \
624			} \
625		} \
626		exit retcode; \
627	}' `find $(PDIR) -type l -a \( $(PKGS:%=-name %.metadata.$$s.$$r -o) \
628		-name NOSUCHFILE \)` >> $(@)
629
630#
631# rules to validate proto area against manifests, check for safe
632# file permission modes, and generate a faux proto list
633#
634# For the check targets, the dependencies on $(PROC_PKGS) is specified
635# as a subordinate make process in order to suppress output.
636#
637makesilent:
638	@$(MAKE) -e $(PROC_PKGS) PKGMACH=$(PKGMACH) \
639		SUPPRESSPKGDEP=$(SUPPRESSPKGDEP) > /dev/null
640
641#
642# The .lics files were created during pkgmogrification, and list the
643# set of licenses to pull from $SRC for each package.  Because
644# licenses may be duplicated between packages, we uniquify them as
645# well as aggregating them here.
646#
647license-list: makesilent
648	$(PKGDEBUG)( for l in `cat $(PROC_PKGS:%.mog=%.lics)`; \
649		do print $$l; done ) | sort -u > $@
650
651#
652# Staging the license and description files in the proto area allows
653# us to do proper unreferenced file checking of both license and
654# description files without blanket exceptions, and to pull license
655# content without reference to $CODEMGR_WS during publication.
656#
657stage-licenses: license-list FRC
658	$(PKGDEBUG)$(MAKE) -e -f Makefile.lic \
659		PKGDEBUG=$(PKGDEBUG) LICROOT=$(PKGROOT)/licenses \
660		`$(NAWK) '{ \
661			print "$(PKGROOT)/licenses/" $$0; \
662			print "$(PKGROOT)/licenses/" $$0 ".descrip"; \
663		}' license-list` > /dev/null;
664
665protocmp: makesilent
666	@validate_pkg -a $(PKGMACH) -v \
667		$(EXCEPTIONS:%=-e $(CODEMGR_WS)/exception_lists/%) \
668		-m $(PDIR) -p $(PKGROOT) -p $(TOOLSROOT)
669
670pmodes: makesilent
671	@validate_pkg -a $(PKGMACH) -M -m $(PDIR) \
672		-e $(CODEMGR_WS)/exception_lists/pmodes
673
674check: protocmp pmodes
675
676protolist: proto_list_$(PKGMACH)
677
678proto_list_$(PKGMACH): $(PROC_PKGS)
679	@validate_pkg -a $(PKGMACH) -L -m $(PDIR) > $(@)
680
681$(PROC_PKGS): $(PDIR)
682
683#
684# This is a convenience target to allow package names to function as
685# build targets.  Generally, using it is only useful when iterating on
686# development of a manifest.
687#
688# When processing a manifest, use the basename (without extension) of
689# the package.  When publishing, use the basename with a ".pub"
690# extension.
691#
692# Other than during manifest development, the preferred usage is to
693# avoid these targets and override PKGS on the make command line and
694# use the provided all and install targets.
695#
696$(PKGS) $(SYNTH_PKGS): $(PDIR)/$$(@:%=%.mog)
697
698$(PKGS:%=%.pub) $(SYNTH_PKGS:%=%.pub): $(PDIR)/$$(@)
699
700#
701# This is a convenience target to resolve dependencies without publishing
702# packages.
703#
704gendeps: $(PDIR)/gendeps
705
706#
707# These are convenience targets for cross-platform packaging.  If you
708# want to build any of "the normal" targets for a different
709# architecture, simply use "arch/target" as your build target.
710#
711# Since the most common use case for this is "install," the architecture
712# specific install targets have been further abbreviated to elide "/install."
713#
714i386/% sparc/%:
715	$(MAKE) -e $(@F) PKGMACH=$(@D) SUPPRESSPKGDEP=$(SUPPRESSPKGDEP)
716
717i386 sparc: $$(@)/install
718
719FRC:
720
721# EXPORT DELETE START
722XMOD_PKGS= \
723	BRCMbnx \
724	BRCMbnxe \
725	SUNWadpu320 \
726	SUNWibsdpib \
727	SUNWkdc \
728	SUNWlsimega \
729	SUNWwbint \
730	SUNWwbsup
731
732EXPORT_SRC: CRYPT_SRC
733	$(RM) $(XMOD_PKGS:%=manifests/%.mf)
734	$(RM) Makefile+
735	$(SED) -e "/^# EXPORT DELETE START/,/^# EXPORT DELETE END/d" \
736		< Makefile > Makefile+
737	$(MV) -f Makefile+ Makefile
738	$(CHMOD) 444 Makefile
739# EXPORT DELETE END
740