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