xref: /titanic_50/usr/src/pkg/Makefile (revision 52244c0958bdf281ca42932b449f644b4decfdc2)
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#
26
27include $(SRC)/Makefile.master
28include $(SRC)/Makefile.buildnum
29
30#
31# Make sure we're getting a consistent execution environment for the
32# embedded scripts.
33#
34SHELL= /usr/bin/ksh93
35
36#
37# To suppress package dependency generation on any system, regardless
38# of how it was installed, set SUPPRESSPKGDEP=true in the build
39# environment.
40#
41SUPPRESSPKGDEP= false
42
43#
44# Comment this line out or set "PKGDEBUG=" in your build environment
45# to get more verbose output from the make processes in usr/src/pkg
46#
47PKGDEBUG= @
48
49#
50# Cross platform packaging notes
51#
52# By default, we package the proto area from the same architecture as
53# the packaging build.  In other words, if you're running nightly or
54# bldenv on an x86 platform, it will take objects from the x86 proto
55# area and use them to create x86 repositories.
56#
57# If you want to create repositories for an architecture that's
58# different from $(uname -p), you do so by setting PKGMACH in your
59# build environment.
60#
61# For this to work correctly, the following must all happen:
62#
63#   1. You need the desired proto area, which you can get either by
64#      doing a gatekeeper-style build with the -U option to
65#      nightly(1), or by using rsync.  If you don't do this, you will
66#      get packaging failures building all packages, because pkgsend
67#      is unable to find the required binaries.
68#   2. You need the desired tools proto area, which you can get in the
69#      same ways as the normal proto area.  If you don't do this, you
70#      will get packaging failures building onbld, because pkgsend is
71#      unable to find the tools binaries.
72#   3. The remainder of this Makefile should never refer directly to
73#      $(MACH).  Instead, $(PKGMACH) should be used whenever an
74#      architecture-specific path or token is needed.  If this is done
75#      incorrectly, then packaging will fail, and you will see the
76#      value of $(uname -p) instead of the value of $(PKGMACH) in the
77#      commands that fail.
78#   4. Each time a rule in this Makefile invokes $(MAKE), it should
79#      pass PKGMACH=$(PKGMACH) explicitly on the command line.  If
80#      this is done incorrectly, then packaging will fail, and you
81#      will see the value of $(uname -p) instead of the value of
82#      $(PKGMACH) in the commands that fail.
83#
84# Refer also to the convenience targets defined later in this
85# Makefile.
86#
87PKGMACH=	$(MACH)
88
89#
90# ROOT, TOOLS_PROTO, and PKGARCHIVE should be set by nightly or
91# bldenv.  These macros translate them into terms of $PKGMACH, instead
92# of $ARCH.
93#
94PKGROOT.cmd=	print $(ROOT) | sed -e s:/root_$(MACH):/root_$(PKGMACH):
95PKGROOT=	$(PKGROOT.cmd:sh)
96TOOLSROOT.cmd=	print $(TOOLS_PROTO) | sed -e s:/root_$(MACH):/root_$(PKGMACH):
97TOOLSROOT=	$(TOOLSROOT.cmd:sh)
98PKGDEST.cmd=	print $(PKGARCHIVE) | sed -e s:/$(MACH)/:/$(PKGMACH)/:
99PKGDEST=	$(PKGDEST.cmd:sh)
100
101EXCEPTIONS= packaging
102
103PKGMOGRIFY= pkgmogrify
104
105#
106# Always build the redistributable repository, but only build the
107# nonredistributable bits if we have access to closed source.
108#
109# Some objects that result from the closed build are still
110# redistributable, and should be packaged as part of an open-only
111# build.  Access to those objects is provided via the closed-bins
112# tarball.  See usr/src/tools/scripts/bindrop.sh for details.
113#
114REPOS= redist
115
116#
117# The packages directory will contain the processed manifests as
118# direct build targets and subdirectories for package metadata extracted
119# incidentally during manifest processing.
120#
121# Nothing underneath $(PDIR) should ever be managed by SCM.
122#
123PDIR= packages.$(PKGMACH)
124
125#
126# The tools proto must be specified for dependency generation.
127# Publication from the tools proto area is managed in the
128# publication rule.
129#
130$(PDIR)/developer-build-onbld.dep:= PKGROOT= $(TOOLSROOT)
131
132PKGPUBLISHER= $(PKGPUBLISHER_REDIST)
133
134#
135# To get these defaults, manifests should simply refer to $(PKGVERS).
136#
137PKGVERS_COMPONENT= 0.$(RELEASE)
138PKGVERS_BUILTON= $(RELEASE)
139PKGVERS_BRANCH= 0.$(ONNV_BUILDNUM)
140PKGVERS= $(PKGVERS_COMPONENT),$(PKGVERS_BUILTON)-$(PKGVERS_BRANCH)
141
142#
143# The ARCH32 and ARCH64 macros are used in the manifests to express
144# architecture-specific subdirectories in the installation paths
145# for isaexec'd commands.
146#
147# We can't simply use $(MACH32) and $(MACH64) here, because they're
148# only defined for the build architecture.  To do cross-platform
149# packaging, we need both values.
150#
151i386_ARCH32= i86
152sparc_ARCH32= sparcv7
153i386_ARCH64= amd64
154sparc_ARCH64= sparcv9
155
156#
157# macros and transforms needed by pkgmogrify
158#
159# If you append to this list using target-specific assignments (:=),
160# be very careful that the targets are of the form $(PDIR)/pkgname.  If
161# you use a higher level target, or a package list, you'll trigger a
162# complete reprocessing of all manifests because they'll fail command
163# dependency checking.
164#
165PM_TRANSFORMS= common_actions publish restart_fmri facets defaults \
166	extract_metadata
167PM_INC= transforms manifests
168
169PKGMOG_DEFINES= \
170	i386_ONLY=$(POUND_SIGN) \
171	sparc_ONLY=$(POUND_SIGN) \
172	$(PKGMACH)_ONLY= \
173	ARCH=$(PKGMACH) \
174	ARCH32=$($(PKGMACH)_ARCH32) \
175	ARCH64=$($(PKGMACH)_ARCH64) \
176	PKGVERS_COMPONENT=$(PKGVERS_COMPONENT) \
177	PKGVERS_BUILTON=$(PKGVERS_BUILTON) \
178	PKGVERS_BRANCH=$(PKGVERS_BRANCH) \
179	PKGVERS=$(PKGVERS) \
180	PERL_ARCH=$(PERL_ARCH) \
181	PERL_VERSION=$(PERL_VERSION) \
182	PERL_PKGVERS=$(PERL_PKGVERS)
183
184PKGDEP_TOKENS_i386= \
185	'PLATFORM=i86hvm' \
186	'PLATFORM=i86pc' \
187	'PLATFORM=i86xpv' \
188	'ISALIST=amd64' \
189	'ISALIST=i386'
190PKGDEP_TOKENS_sparc= \
191	'PLATFORM=sun4u' \
192	'PLATFORM=sun4v' \
193	'ISALIST=sparcv9' \
194	'ISALIST=sparc'
195PKGDEP_TOKENS= $(PKGDEP_TOKENS_$(PKGMACH))
196
197#
198# The package lists are generated with $(PKGDEP_TYPE) as their
199# dependency types, so that they can be included by either an
200# incorporation or a group package.
201#
202$(PDIR)/osnet-redist.mog := PKGDEP_TYPE= require
203$(PDIR)/osnet-incorporation.mog:= PKGDEP_TYPE= incorporate
204
205PKGDEP_INCORP= \
206	depend fmri=consolidation/osnet/osnet-incorporation type=require
207
208#
209# All packaging build products should go into $(PDIR), so they don't
210# need to be included separately in CLOBBERFILES.
211#
212CLOBBERFILES= $(PDIR) proto_list_$(PKGMACH) install-$(PKGMACH).out \
213	license-list
214
215#
216# By default, PKGS will list all manifests.  To build and/or publish a
217# subset of packages, override this on the command line or in the
218# build environment and then reference (implicitly or explicitly) the all
219# or install targets.  Using ls -1 (that's a one) or print or echo to
220# get the list of manifests is a little hackish, but avoids having a
221# 900+ line file to explicitly list them all.
222#
223# We want some manifests to optionally built based on environment
224# options, so those are excluded and optionally added back in.
225# We also want a relatively easy way to add files to the list of
226# manifests given special treatment.  Add any other special ones
227# to the SPECIAL_MANIFESTS vaiable.  It can contain wildcards in
228# regexp form, i.e. SUNW.* as one useful example.
229#
230SPECIAL_MANIFESTS = print-lp-ipp-ipp-listener.mf
231LIST_MANIFESTS_CMD = (cd manifests ; /usr/bin/ls -1 *.mf |\
232	$(SED) $(SPECIAL_MANIFESTS:%=-e '/^%$$/d') )
233MANIFESTS = $(LIST_MANIFESTS_CMD:sh)
234
235# Conditionally add back lp-ipp
236$(ENABLE_IPP_PRINTING) MANIFESTS += print-lp-ipp-ipp-listener.mf
237
238PKGS= $(MANIFESTS:%.mf=%)
239DEP_PKGS= $(PKGS:%=$(PDIR)/%.dep)
240PROC_PKGS= $(PKGS:%=$(PDIR)/%.mog)
241
242#
243# Track the synthetic manifests separately so we can properly express
244# build rules and dependencies.  The synthetic and real packages use
245# different sets of transforms and macros for pkgmogrify.
246#
247SYNTH_PKGS= osnet-incorporation osnet-redist
248DEP_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.dep)
249PROC_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.mog)
250
251#
252# Root of pkg image to use for dependency resolution
253# Normally / on the machine used to build the binaries
254#
255PKGDEP_RESOLVE_IMAGE = /
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#
267PUB_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#
287PKGLISTS= \
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
368ALL_TARGETS= $(PROC_SYNTH_PKGS) proto_list_$(PKGMACH)
369
370all: $(ALL_TARGETS)
371
372#
373# This will build the directory to contain the processed manifests
374# and the metadata symlinks.
375#
376$(PDIR):
377	@print "Creating $(@)"
378	$(PKGDEBUG)$(INS.dir)
379
380#
381# This rule resolves dependencies across all published manifests.
382#
383# We shouldn't have to ignore the error from pkgdepend, but until
384# 16012 and its dependencies are resolved, pkgdepend will always exit
385# with an error.
386#
387$(PDIR)/gendeps: $(DEP_SYNTH_PKGS) $(DEP_PKGS)
388	-$(PKGDEBUG)if [ "$(SUPPRESSPKGDEP)" = "true" ]; then \
389		print "Suppressing dependency resolution"; \
390		for p in $(DEP_PKGS:%.dep=%); do \
391			$(CP) $$p.dep $$p.res; \
392		done; \
393	else \
394		print "Resolving dependencies"; \
395		pkgdepend -R $(PKGDEP_RESOLVE_IMAGE) resolve \
396		    -m $(DEP_SYNTH_PKGS) $(DEP_PKGS); \
397		for p in $(DEP_SYNTH_PKGS:%.dep=%) $(DEP_PKGS:%.dep=%); do \
398			if [ "$$(print $$p.metadata.*)" = \
399			     "$$(print $$p.metadata.noincorp.*)" ]; \
400			then \
401				print "Removing dependency versions from $$p"; \
402				$(PKGMOGRIFY) $(PKGMOG_VERBOSE) \
403				    -O $$p.res -I transforms \
404				    strip_versions $$p.dep.res; \
405				$(RM) $$p.dep.res; \
406			else \
407				$(MV) $$p.dep.res $$p.res; \
408			fi; \
409		done; \
410	fi
411	$(PKGDEBUG)$(TOUCH) $(@)
412
413install: $(ALL_TARGETS) repository-metadata
414
415repository-metadata: publish_pkgs
416	$(PKGDEBUG)for r in $(REPOS); do \
417		pkgrepo refresh -s $(PKGDEST)/repo.$$r; \
418	done
419
420#
421# Since we create zero-length processed manifests for a graceful abort
422# from pkgmogrify, we need to detect that here and make no effort to
423# publish the package.
424#
425# For all other packages, we publish them regardless of status.  We
426# derive the target repository as a component of the metadata-derived
427# symlink for each package.
428#
429publish_pkgs: $(REPOS:%=$(PKGDEST)/repo.%) $(PDIR)/gendeps .WAIT $(PUB_PKGS)
430
431#
432# Before publishing, we want to pull the license files from $CODEMGR_WS
433# into the proto area.  This allows us to NOT pass $SRC (or
434# $CODEMGR_WS) as a basedir for publication.
435#
436$(PUB_PKGS): stage-licenses
437
438#
439# Initialize the empty on-disk repositories
440#
441$(REPOS:%=$(PKGDEST)/repo.%):
442	@print "Initializing $(@F)"
443	$(PKGDEBUG)$(INS.dir)
444	$(PKGDEBUG)pkgsend -s file://$(@) create-repository \
445		--set-property publisher.prefix=$(PKGPUBLISHER)
446
447#
448# rule to process real manifests
449#
450# To allow redistributability and package status to change, we must
451# remove not only the actual build target (the processed manifest), but
452# also the incidental ones (the metadata-derived symlinks).
453#
454# If pkgmogrify exits cleanly but fails to create the specified output
455# file, it means that it encountered an abort directive.  That means
456# that this package should not be published for this particular build
457# environment.  Since we can't prune such packages from $(PKGS)
458# retroactively, we need to create an empty target file to keep make
459# from trying to rebuild it every time.  For these empty targets, we
460# do not create metadata symlinks.
461#
462# Automatic dependency resolution to files is also done at this phase of
463# processing.  The skipped packages are skipped due to existing bugs
464# in pkgdepend.
465#
466# The incorporation dependency is tricky: it needs to go into all
467# current and renamed manifests (ie all incorporated packages), but we
468# don't know which those are until after we run pkgmogrify.  So
469# instead of expressing it as a transform, we tack it on ex post facto.
470#
471# Implementation notes:
472#
473# - The first $(RM) must not match other manifests, or we'll run into
474#   race conditions with parallel manifest processing.
475#
476# - The make macros [ie $(MACRO)] are evaluated when the makefile is
477#   read in, and will result in a fixed, macro-expanded rule for each
478#   target enumerated in $(PROC_PKGS).
479#
480# - The shell variables (ie $$VAR) are assigned on the fly, as the rule
481#   is executed.  The results may only be referenced in the shell in
482#   which they are assigned, so from the perspective of make, all code
483#   that needs these variables needs to be part of the same line of
484#   code.  Hence the use of command separators and line continuation
485#   characters.
486#
487# - The extract_metadata transforms are designed to spit out shell
488#   variable assignments to stdout.  Those are published to the
489#   .vars temporary files, and then used as input to the eval
490#   statement.  This is done in stages specifically so that pkgmogrify
491#   can signal failure if the manifest has a syntactic or other error.
492#   The eval statement should begin with the default values, and the
493#   output from pkgmogrify (if any) should be in the form of a
494#   variable assignment to override those defaults.
495#
496# - When this rule completes execution, it must leave an updated
497#   target file ($@) in place, or make will reprocess the package
498#   every time it encounters it as a dependency.  Hence the "touch"
499#   statement to ensure that the target is created, even when
500#   pkgmogrify encounters an abort in the publish transforms.
501#
502
503.SUFFIXES: .mf .mog .dep .res .pub
504
505$(PDIR)/%.mog: manifests/%.mf
506	@print "Processing manifest $(<F)"
507	@env PKGFMT_OUTPUT=v1 pkgfmt -c $<
508	$(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) $(@:%.mog=%.nodepend) \
509		$(@:%.mog=%.lics) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars
510	$(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \
511		$(PKGMOG_DEFINES:%=-D %) -P $(@).vars -O $(@) \
512		$(<) $(PM_TRANSFORMS)
513	$(PKGDEBUG)eval REPO=redist PKGSTAT=current NODEPEND=$(SUPPRESSPKGDEP) \
514		`$(CAT) -s $(@).vars`; \
515	if [ -f $(@) ]; then \
516		if [ "$$NODEPEND" != "false" ]; then \
517			 $(TOUCH) $(@:%.mog=%.nodepend); \
518		fi; \
519		$(LN) -s $(@F) \
520			$(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \
521		if [ \( "$$PKGSTAT" = "current" \) -o \
522		     \( "$$PKGSTAT" = "renamed" \) ]; \
523			then print $(PKGDEP_INCORP) >> $(@); \
524		fi; \
525		print $$LICS > $(@:%.mog=%.lics); \
526	else \
527		$(TOUCH) $(@) $(@:%.mog=%.lics); \
528	fi
529	$(PKGDEBUG)$(RM) $(@).vars
530
531$(PDIR)/%.dep: $(PDIR)/%.mog
532	@print "Generating dependencies for $(<F)"
533	$(PKGDEBUG)$(RM) $(@)
534	$(PKGDEBUG)if [ ! -f $(@:%.dep=%.nodepend) ]; then \
535		pkgdepend generate -m $(PKGDEP_TOKENS:%=-D %) $(<) \
536			$(PKGROOT) > $(@); \
537	else \
538		$(CP) $(<) $(@); \
539	fi
540
541#
542# The full chain implies that there should be a .dep.res suffix rule,
543# but dependency generation is done on a set of manifests, rather than
544# on a per-manifest basis.  Instead, see the gendeps rule above.
545#
546
547$(PDIR)/%.pub: $(PDIR)/%.res
548	$(PKGDEBUG)m=$$(basename $(@:%.pub=%).metadata.*); \
549	r=$${m#$(@F:%.pub=%.metadata.)+(?).}; \
550	if [ -s $(<) ]; then \
551		print "Publishing $(@F:%.pub=%) to $$r repository"; \
552		pkgsend -s file://$(PKGDEST)/repo.$$r publish \
553		    -d $(PKGROOT) -d $(TOOLSROOT) \
554		    -d license_files -d $(PKGROOT)/licenses \
555		    --fmri-in-manifest --no-index --no-catalog $(<) \
556		    > /dev/null; \
557	fi; \
558	$(TOUCH) $(@);
559
560#
561# rule to build the synthetic manifests
562#
563# This rule necessarily has PKGDEP_TYPE that changes according to
564# the specific synthetic manifest.  Rather than escape command
565# dependency checking for the real manifest processing, or failing to
566# express the (indirect) dependency of synthetic manifests on real
567# manifests, we simply split this rule out from the one above.
568#
569# The implementation notes from the previous rule are applicable
570# here, too.
571#
572$(PROC_SYNTH_PKGS): $(PKGLISTS) $$(@F:%.mog=%.mf)
573	@print "Processing synthetic manifest $(@F:%.mog=%.mf)"
574	$(PKGDEBUG)$(RM) $(@) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars
575	$(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) -I transforms -I $(PDIR) \
576		$(PKGMOG_DEFINES:%=-D %) -D PKGDEP_TYPE=$(PKGDEP_TYPE) \
577		-P $(@).vars -O $(@) $(@F:%.mog=%.mf) \
578		$(PM_TRANSFORMS) synthetic
579	$(PKGDEBUG)eval REPO=redist PKGSTAT=current `$(CAT) -s $(@).vars`; \
580	if [ -f $(@) ]; then \
581		$(LN) -s $(@F) \
582			$(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \
583	else \
584		$(TOUCH) $(@); \
585	fi
586	$(PKGDEBUG)$(RM) $(@).vars
587
588$(DEP_SYNTH_PKGS): $$(@:%.dep=%.mog)
589	@print "Skipping dependency generation for $(@F:%.dep=%)"
590	$(PKGDEBUG)$(CP) $(@:%.dep=%.mog) $(@)
591
592clean:
593
594clobber: clean
595	$(RM) -r $(CLOBBERFILES)
596
597#
598# This rule assumes that all links in the $PKGSTAT directories
599# point to valid manifests, and will fail the make run if one
600# does not contain an fmri.
601#
602# We do this in the BEGIN action instead of using pattern matching
603# because we expect the fmri to be at or near the first line of each input
604# file, and this way lets us avoid reading the rest of the file after we
605# find what we need.
606#
607# We keep track of a failure to locate an fmri, so we can fail the
608# make run, but we still attempt to process each package in the
609# repo/pkgstat-specific subdir, in hopes of maybe giving some
610# additional useful info.
611#
612# The protolist is used for bfu archive creation, which may be invoked
613# interactively by the user.  Both protolist and PKGLISTS targets
614# depend on $(PROC_PKGS), but protolist builds them recursively.
615# To avoid collisions, we insert protolist into the dependency chain
616# here.  This has two somewhat subtle benefits: it allows bfu archive
617# creation to work correctly, even when -a was not part of NIGHTLY_OPTIONS,
618# and it ensures that a protolist file here will always correspond to the
619# contents of the processed manifests, which can vary depending on build
620# environment.
621#
622$(PKGLISTS): $(PROC_PKGS)
623	$(PKGDEBUG)sdotr=$(@F:packages.%=%); \
624	r=$${sdotr%.+(?)}; s=$${sdotr#+(?).}; \
625	print "Generating $$r $$s package list"; \
626	$(RM) $(@); $(TOUCH) $(@); \
627	$(NAWK) 'BEGIN { \
628		if (ARGC < 2) { \
629			exit; \
630		} \
631		retcode = 0; \
632		for (i = 1; i < ARGC; i++) { \
633			do { \
634				e = getline f < ARGV[i]; \
635			} while ((e == 1) && (f !~ /name=pkg.fmri/)); \
636			close(ARGV[i]); \
637			if (e == 1) { \
638				l = split(f, a, "="); \
639				print "depend fmri=" a[l], \
640					"type=$$(PKGDEP_TYPE)"; \
641			} else { \
642				print "no fmri in " ARGV[i] >> "/dev/stderr"; \
643				retcode = 2; \
644			} \
645		} \
646		exit retcode; \
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		`$(NAWK) '{ \
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
694check: protocmp pmodes
695
696protolist: proto_list_$(PKGMACH)
697
698proto_list_$(PKGMACH): $(PROC_PKGS)
699	@validate_pkg -a $(PKGMACH) -L -m $(PDIR) > $(@)
700
701$(PROC_PKGS): $(PDIR)
702
703#
704# This is a convenience target to allow package names to function as
705# build targets.  Generally, using it is only useful when iterating on
706# development of a manifest.
707#
708# When processing a manifest, use the basename (without extension) of
709# the package.  When publishing, use the basename with a ".pub"
710# extension.
711#
712# Other than during manifest development, the preferred usage is to
713# avoid these targets and override PKGS on the make command line and
714# use the provided all and install targets.
715#
716$(PKGS) $(SYNTH_PKGS): $(PDIR)/$$(@:%=%.mog)
717
718$(PKGS:%=%.pub) $(SYNTH_PKGS:%=%.pub): $(PDIR)/$$(@)
719
720#
721# This is a convenience target to resolve dependencies without publishing
722# packages.
723#
724gendeps: $(PDIR)/gendeps
725
726#
727# These are convenience targets for cross-platform packaging.  If you
728# want to build any of "the normal" targets for a different
729# architecture, simply use "arch/target" as your build target.
730#
731# Since the most common use case for this is "install," the architecture
732# specific install targets have been further abbreviated to elide "/install."
733#
734i386/% sparc/%:
735	$(MAKE) -e $(@F) PKGMACH=$(@D) SUPPRESSPKGDEP=$(SUPPRESSPKGDEP)
736
737i386 sparc: $$(@)/install
738
739FRC:
740