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