xref: /titanic_44/usr/src/pkg/Makefile (revision dd49f125507979bb2ab505a8daf2a46d1be27051)
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 SUNWonbld, because pkgsend is
70#      unable to find the tools binaries.
71#   3. You need to have built the appropriate third party license
72#      files in $SRC, which generally means you should override SRC in
73#      your build environment.  If you don't do this, you will get
74#      packaging failures because pkgsend is unable to find various
75#      THIRDPARTYLICENSE files.
76#   4. 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#   5. 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
105#
106# The publish transforms, EXCEPTIONS list, and some manifests need to
107# know when we're building open-only and when we're using internal
108# crypto bits.
109#
110# We only use internal crypto when we're doing a closed build, the
111# CODESIGN_USER env variable is not set, and ON_CRYPTO_BINS is not set.
112# This matches the conditions under which the internal key and cert
113# are needed for the packaged objects.
114#
115# We use X_FLAG, as exported by nightly and bldenv, to decide when we
116# need IHV-related exceptions for protocmp.
117#
118$(CLOSED_BUILD)OPEN_ONLY_BUILD= $(POUND_SIGN)
119
120USE_INTERNAL_CRYPTO= $(POUND_SIGN)
121UI1= $(CODESIGN_USER:%=$(POUND_SIGN))
122$(UI1)UI2= $(ON_CRYPTO_BINS:%=$(POUND_SIGN))
123$(CLOSED_BUILD)USE_INTERNAL_CRYPTO= $(UI1)$(UI2)
124USE_SIGNED_CRYPTO=
125$(USE_INTERNAL_CRYPTO)USE_SIGNED_CRYPTO= $(POUND_SIGN)
126
127X_FLAG=			n
128IHV_COPY_BUILD1=	$(X_FLAG:n%=$(POUND_SIGN)%)
129IHV_COPY_BUILD=		$(IHV_COPY_BUILD1:y%=%)
130
131
132EXCEPTIONS= packaging
133$(CLOSED_BUILD)EXCEPTIONS += packaging.closed
134$(OPEN_ONLY_BUILD)EXCEPTIONS += packaging.open
135$(IHV_COPY_BUILD)EXCEPTIONS += packaging.ihv
136
137PKGMOGRIFY= pkgmogrify
138
139#
140# Always build the redistributable repository, but only build the
141# nonredistributable bits if we have access to closed source.
142#
143# Some objects that result from the closed build are still
144# redistributable, and should be packaged as part of an open-only
145# build.  Access to those objects is provided via the closed-bins
146# tarball.  See usr/src/tools/scripts/bindrop.sh for details.
147#
148REPOS= redist
149$(CLOSED_BUILD)REPOS += extra
150
151#
152# The packages directory will contain the processed manifests as
153# direct build targets and subdirectories for package metadata extracted
154# incidentally during manifest processing.
155#
156# Nothing underneath $(PDIR) should ever be managed by SCM.
157#
158PDIR= packages.$(PKGMACH)
159
160#
161# The tools proto must be specified for dependency generation.
162# Publication from the tools proto area is managed in the
163# publication rule.
164#
165$(PDIR)/developer-build-onbld.dep:= PKGROOT= $(TOOLSROOT)
166
167PKGPUBLISHER= $(PKGPUBLISHER_REDIST)
168$(PKGDEST)/repo.extra:= PKGPUBLISHER= $(PKGPUBLISHER_NONREDIST)
169
170#
171# To get these defaults, manifests should simply refer to $(PKGVERS).
172#
173PKGVERS_COMPONENT= 0.$(RELEASE)
174PKGVERS_BUILTON= $(RELEASE)
175PKGVERS_BRANCH= 0.$(ONNV_BUILDNUM)
176PKGVERS= $(PKGVERS_COMPONENT),$(PKGVERS_BUILTON)-$(PKGVERS_BRANCH)
177
178#
179# The ARCH32 and ARCH64 macros are used in the manifests to express
180# architecture-specific subdirectories in the installation paths
181# for isaexec'd commands.
182#
183# We can't simply use $(MACH32) and $(MACH64) here, because they're
184# only defined for the build architecture.  To do cross-platform
185# packaging, we need both values.
186#
187i386_ARCH32= i86
188sparc_ARCH32= sparcv7
189i386_ARCH64= amd64
190sparc_ARCH64= sparcv9
191
192#
193# macros and transforms needed by pkgmogrify
194#
195# If you append to this list using target-specific assignments (:=),
196# be very careful that the targets are of the form $(PDIR)/pkgname.  If
197# you use a higher level target, or a package list, you'll trigger a
198# complete reprocessing of all manifests because they'll fail command
199# dependency checking.
200#
201PM_TRANSFORMS= common_actions publish restart_fmri defaults extract_metadata
202PM_INC= transforms
203
204PKGMOG_DEFINES= \
205	i386_ONLY=$(POUND_SIGN) \
206	sparc_ONLY=$(POUND_SIGN) \
207	$(PKGMACH)_ONLY= \
208	ARCH=$(PKGMACH) \
209	ARCH32=$($(PKGMACH)_ARCH32) \
210	ARCH64=$($(PKGMACH)_ARCH64) \
211	PKGVERS_COMPONENT=$(PKGVERS_COMPONENT) \
212	PKGVERS_BUILTON=$(PKGVERS_BUILTON) \
213	PKGVERS_BRANCH=$(PKGVERS_BRANCH) \
214	PKGVERS=$(PKGVERS) \
215	SRC=$(SRC) \
216	CLOSED_BUILD=$(CLOSED_BUILD) \
217	OPEN_BUILD=$(OPEN_ONLY_BUILD) \
218	USE_INTERNAL_CRYPTO=$(USE_INTERNAL_CRYPTO) \
219	USE_SIGNED_CRYPTO=$(USE_SIGNED_CRYPTO)
220
221PKGDEP_TOKENS_i386= \
222	'PLATFORM=i86hvm' \
223	'PLATFORM=i86pc' \
224	'PLATFORM=i86xpv' \
225	'ISALIST=amd64' \
226	'ISALIST=i386'
227PKGDEP_TOKENS_sparc= \
228	'PLATFORM=sun4u' \
229	'PLATFORM=sun4v' \
230	'ISALIST=sparcv9' \
231	'ISALIST=sparc'
232PKGDEP_TOKENS= $(PKGDEP_TOKENS_$(PKGMACH))
233
234#
235# The package lists are generated with $(PKGDEP_TYPE) as their
236# dependency types, so that they can be included by either an
237# incorporation or a group package.
238#
239$(PDIR)/osnet-redist.mog $(PDIR)/osnet-extra.mog:= PKGDEP_TYPE= require
240$(PDIR)/osnet-incorporation.mog:= PKGDEP_TYPE= incorporate
241
242PKGDEP_INCORP= \
243	depend fmri=consolidation/osnet/osnet-incorporation type=require
244
245#
246# All packaging build products should go into $(PDIR), so they don't
247# need to be included separately in CLOBBERFILES.
248#
249CLOBBERFILES= $(PDIR) proto_list_$(PKGMACH)
250
251#
252# By default, PKGS will list all manifests.  To build and/or publish a
253# subset of packages, override this on the command line or in the
254# build environment and then reference (implicitly or explicitly) the all
255# or install targets.
256#
257MANIFESTS :sh= (cd manifests; print *.mf)
258PKGS= $(MANIFESTS:%.mf=%)
259DEP_PKGS= $(PKGS:%=$(PDIR)/%.dep)
260PROC_PKGS= $(PKGS:%=$(PDIR)/%.mog)
261
262#
263# Track the synthetic manifests separately so we can properly express
264# build rules and dependencies.  The synthetic and real packages use
265# different sets of transforms and macros for pkgmogrify.
266#
267SYNTH_PKGS= osnet-incorporation osnet-redist
268$(CLOSED_BUILD)SYNTH_PKGS += osnet-extra
269DEP_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.dep)
270PROC_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.mog)
271
272#
273# For each package, we determine the target repository based on
274# manifest-embedded metadata.  Because we make that determination on
275# the fly, the publication target cannot be expressed as a
276# subdirectory inside the unknown-by-the-makefile target repository.
277#
278# In order to limit the target set to real files in known locations,
279# we use a ".pub" file in $(PDIR) for each processed manifest, regardless
280# of content or target repository.
281#
282PUB_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.pub) $(PKGS:%=$(PDIR)/%.pub)
283
284#
285# Any given repository- and status-specific package list may be empty,
286# but we can only determine that dynamically, so we always generate all
287# lists for each repository we're building.
288#
289# The meanings of each package status are as follows:
290#
291# 	PKGSTAT		meaning
292# 	----------	----------------------------------------------------
293# 	noincorp	Do not include in incorporation or group package
294#	obsolete	Include in incorporation, but not group package
295#	renamed		Include in incorporation, but not group package
296#	current		Include in incorporation and group package
297#
298# Since the semantics of the "noincorp" package status dictate that
299# such packages are not included in the incorporation or group packages,
300# there is no need to build noincorp package lists.
301#
302PKGLISTS= \
303	$(REPOS:%=$(PDIR)/packages.%.current) \
304	$(REPOS:%=$(PDIR)/packages.%.renamed) \
305	$(REPOS:%=$(PDIR)/packages.%.obsolete)
306
307.KEEP_STATE:
308
309.PARALLEL: $(PKGS) $(PROC_PKGS) $(DEP_PKGS) \
310	$(PROC_SYNTH_PKGS) $(DEP_SYNTH_PKGS) $(PUB_PKGS)
311
312#
313# For a single manifest, the dependency chain looks like this:
314#
315#	raw manifest (mypkg.mf)
316#		|
317#		| use pkgmogrify to process raw manifest
318#		|
319#	processed manifest (mypkg.mog)
320#		|
321#	   *    | use pkgdepend generate to generate dependencies
322#		|
323#	manifest with TBD dependencies (mypkg.dep)
324#		|
325#	   %    | use pkgdepend resolve to resolve dependencies
326#		|
327#	manifest with dependencies resolved (mypkg.res)
328#		|
329#		| use pkgsend to publish the package
330#		|
331#	placeholder to indicate successful publication (mypkg.pub)
332#
333# * This may be suppressed via SUPPRESSPKGDEP.  The resulting
334#   packages will install correctly, but care must be taken to
335#   install all dependencies, because pkg will not have the input
336#   it needs to determine this automatically.
337#
338# % This is included in this diagram to make the picture complete, but
339#   this is a point of synchronization in the build process.
340#   Dependency resolution is actually done once on the entire set of
341#   manifests, not on a per-package basis.
342#
343# The full dependency chain for generating everything that needs to be
344# published, without actually publishing it, looks like this:
345#
346#	processed synthetic packages
347#		|		|
348#       package lists	    synthetic package manifests
349#		|
350#	processed real packages
351#	    |		|
352#	package dir	real package manifests
353#
354# Here, each item is a set of real or synthetic packages.  For this
355# portion of the build, no reference is made to the proto area.  It is
356# therefore suitable for the "all" target, as opposed to "install."
357#
358# Since each of these steps is expressed explicitly, "all" need only
359# depend on the head of the chain.
360#
361# From the end of manifest processing, the publication dependency
362# chain looks like this:
363#
364#		repository metadata (catalogs and search indices)
365#			|
366#			| pkg.depotd
367#			|
368#		published packages
369#		 |		|
370#		 |		| pkgsend publish
371#		 |		|
372#	  repositories 	    resolved dependencies
373#		 |			|
374# pkgsend	 |			| pkgdepend resolve
375# create-repository	 	 	|
376#		 |		generated dependencies
377#	 repo directories		|
378#					| pkgdepend
379#					|
380#				processed manifests
381#
382# Due to limitations in pkgdepend, we cannot simply treat synthetic
383# and real manifests identically.  But we don't really want to
384# maintain a separate chain for synthetic manifests, so for the left
385# side of this diagram, we actually do faux dependency generation and
386# resolution, so we end up with the expected set of files in $(PDIR),
387# per the individual file chain described above: mf, mog, dep, res,
388# and pub files for each manifest.
389#
390all: $(PROC_SYNTH_PKGS) proto_list_$(PKGMACH)
391
392#
393# This will build the directory to contain the processed manifests
394# and the metadata symlinks.
395#
396$(PDIR):
397	@print "Creating $(@)"
398	$(PKGDEBUG)$(INS.dir)
399
400#
401# This rule resolves dependencies across all published manifests.
402# We should be able to do this with
403#
404#    pkgdepend resolve -m $(PUB_PKGS:%.pub=%.dep)
405#
406# but until 14113 is fixed, the incorporations confuse pkgdepend, so we
407# just create the .res file for DEP_SYNTH_PKGS directly.
408#
409# We also shouldn't have to ignore the error from pkgdepend, but
410# until at least 14110 is resolved, pkgdepend will always exit with
411# an error.
412#
413$(PDIR)/gendeps: $(DEP_SYNTH_PKGS) $(DEP_PKGS)
414	-$(PKGDEBUG)if [ "$(SUPPRESSPKGDEP)" = "true" ]; then \
415		print "Suppressing dependency resolution"; \
416		for p in $(DEP_PKGS:%.dep=%); do \
417			$(CP) $$p.dep $$p.res; \
418		done; \
419	else \
420		print "Resolving dependencies"; \
421		pkgdepend resolve -m $(DEP_PKGS); \
422		for p in $(DEP_PKGS:%.dep=%); do \
423			if [ "$$(print $$p.metadata.*)" = \
424			     "$$(print $$p.metadata.noincorp.*)" ]; \
425			then \
426				print "Removing dependency versions from $$p"; \
427				$(PKGMOGRIFY) $(PKGMOG_VERBOSE) \
428				    -O $$p.res -I transforms \
429				    strip_versions $$p.dep.res; \
430				$(RM) $$p.dep.res; \
431			else \
432				$(MV) $$p.dep.res $$p.res; \
433			fi; \
434		done; \
435	fi
436	$(PKGDEBUG)for p in $(DEP_SYNTH_PKGS:%.dep=%); \
437	do \
438		$(CP) $$p.dep $$p.res; \
439	done
440	$(PKGDEBUG)$(TOUCH) $(@)
441
442install: repository-metadata
443
444repository-metadata: publish_pkgs
445	@print "Creating repository metadata"
446	$(PKGDEBUG)for r in $(REPOS); do \
447		/usr/lib/pkg.depotd -d $(PKGDEST)/repo.$$r \
448			--add-content --exit-ready; \
449		chmod a+r $(PKGDEST)/repo.$$r/cfg_cache; \
450	done
451
452#
453# Since we create zero-length processed manifests for a graceful abort
454# from pkgmogrify, we need to detect that here and make no effort to
455# publish the package.
456#
457# For all other packages, we publish them regardless of status.  We
458# derive the target repository as a component of the metadata-derived
459# symlink for each package.
460#
461publish_pkgs: $(REPOS:%=$(PKGDEST)/repo.%) $(PDIR)/gendeps .WAIT $(PUB_PKGS)
462
463$(PUB_PKGS): FRC
464
465#
466# Initialize the empty on-disk repositories
467#
468$(REPOS:%=$(PKGDEST)/repo.%):
469	@print "Initializing $(@F)"
470	$(PKGDEBUG)$(INS.dir)
471	$(PKGDEBUG)pkgsend -s file://$(@) create-repository \
472		--set-property publisher.prefix=$(PKGPUBLISHER)
473
474#
475# rule to process real manifests
476#
477# To allow redistributability and package status to change, we must
478# remove not only the actual build target (the processed manifest), but
479# also the incidental ones (the metadata-derived symlinks).
480#
481# If pkgmogrify exits cleanly but fails to create the specified output
482# file, it means that it encountered an abort directive.  That means
483# that this package should not be published for this particular build
484# environment.  Since we can't prune such packages from $(PKGS)
485# retroactively, we need to create an empty target file to keep make
486# from trying to rebuild it every time.  For these empty targets, we
487# do not create metadata symlinks.
488#
489# Automatic dependency resolution to files is also done at this phase of
490# processing.  The skipped packages are skipped due to existing bugs
491# in pkgdepend.
492#
493# The incorporation dependency is tricky: it needs to go into all
494# current and renamed manifests (ie all incorporated packages), but we
495# don't know which those are until after we run pkgmogrify.  So
496# instead of expressing it as a transform, we tack it on ex post facto.
497#
498# Implementation notes:
499#
500# - The first $(RM) must not match other manifests, or we'll run into
501#   race conditions with parallel manifest processing.
502#
503# - The make macros [ie $(MACRO)] are evaluated when the makefile is
504#   read in, and will result in a fixed, macro-expanded rule for each
505#   target enumerated in $(PROC_PKGS).
506#
507# - The shell variables (ie $$VAR) are assigned on the fly, as the rule
508#   is executed.  The results may only be referenced in the shell in
509#   which they are assigned, so from the perspective of make, all code
510#   that needs these variables needs to be part of the same line of
511#   code.  Hence the use of command separators and line continuation
512#   characters.
513#
514# - The extract_metadata transforms are designed to spit out shell
515#   variable assignments to stdout.  Those are published to the
516#   .vars temporary files, and then used as input to the eval
517#   statement.  This is done in stages specifically so that pkgmogrify
518#   can signal failure if the manifest has a syntactic or other error.
519#   The eval statement should begin with the default values, and the
520#   output from pkgmogrify (if any) should be in the form of a
521#   variable assignment to override those defaults.
522#
523# - When this rule completes execution, it must leave an updated
524#   target file ($@) in place, or make will reprocess the package
525#   every time it encounters it as a dependency.  Hence the "touch"
526#   statement to ensure that the target is created, even when
527#   pkgmogrify encounters an abort in the publish transforms.  This
528#   will not cause publication failures when switching build
529#   environments, because $(CLOSED_BUILD) and $(OPEN_ONLY) are
530#   referenced in $(PKGMOG_DEFINES), and changes will therefore
531#   trigger a rebuild for command dependency failure.  (Command
532#   dependency checking is turned on by .KEEP_STATE: above.)
533#
534
535.SUFFIXES: .mf .mog .dep .res .pub
536
537$(PDIR)/%.mog: manifests/%.mf
538	@print "Processing manifest $(<F)"
539	$(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) $(@:%.mog=%.nodepend) \
540		$(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars
541	$(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \
542		$(PKGMOG_DEFINES:%=-D %) -P $(@).vars -O $(@) \
543		$(<) $(PM_TRANSFORMS)
544	$(PKGDEBUG)eval REPO=redist PKGSTAT=current NODEPEND=$(SUPPRESSPKGDEP) \
545		`$(CAT) -s $(@).vars`; \
546	if [ -f $(@) ]; then \
547		if [ "$$NODEPEND" != "false" ]; then \
548			 $(TOUCH) $(@:%.mog=%.nodepend); \
549		fi; \
550		$(LN) -s $(@F) \
551			$(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \
552		if [ \( "$$PKGSTAT" = "current" \) -o \
553		     \( "$$PKGSTAT" = "renamed" \) ]; \
554			then print $(PKGDEP_INCORP) >> $(@); \
555		fi; \
556	else \
557		$(TOUCH) $(@); \
558	fi
559	$(PKGDEBUG)$(RM) $(@).vars
560
561$(PDIR)/%.dep: $(PDIR)/%.mog
562	@print "Generating dependencies for $(<F)"
563	$(PKGDEBUG)$(RM) $(@)
564	$(PKGDEBUG)if [ ! -f $(@:%.dep=%.nodepend) ]; then \
565		pkgdepend generate -m $(PKGDEP_TOKENS:%=-D %) $(<) \
566			$(PKGROOT) > $(@); \
567	else \
568		$(CP) $(<) $(@); \
569	fi
570
571#
572# The full chain implies that there should be a .dep.res suffix rule,
573# but dependency generation is done on a set of manifests, rather than
574# on a per-manifest basis.  Instead, see the gendeps rule above.
575#
576
577$(PDIR)/%.pub: $(PDIR)/%.res
578	$(PKGDEBUG)m=$$(basename $(@:%.pub=%).metadata.*); \
579	r=$${m#$(@F:%.pub=%.metadata.)+(?).}; \
580	if [ -s $(<) ]; then \
581		print "Publishing $(@F:%.pub=%) to $$r repository"; \
582		pkgsend -s file://$(PKGDEST)/repo.$$r publish \
583		    -d $(PKGROOT) -d $(TOOLSROOT) -d $(SRC)/pkg/license_files \
584		    -d $(SRC) --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=%.mf)
602	@print "Processing synthetic manifest $(@F:%.mog=%.mf)"
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=%.mf) \
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# We do this in the BEGIN action instead of using pattern matching
632# because we expect the fmri to be at or near the first line of each input
633# file, and this way lets us avoid reading the rest of the file after we
634# find what we need.
635#
636# We keep track of a failure to locate an fmri, so we can fail the
637# make run, but we still attempt to process each package in the
638# repo/pkgstat-specific subdir, in hopes of maybe giving some
639# additional useful info.
640#
641# The protolist is used for bfu archive creation, which may be invoked
642# interactively by the user.  Both protolist and PKGLISTS targets
643# depend on $(PROC_PKGS), but protolist builds them recursively.
644# To avoid collisions, we insert protolist into the dependency chain
645# here.  This has two somewhat subtle benefits: it allows bfu archive
646# creation to work correctly, even when -a was not part of NIGHTLY_OPTIONS,
647# and it ensures that a protolist file here will always correspond to the
648# contents of the processed manifests, which can vary depending on build
649# environment.
650#
651$(PKGLISTS): $(PROC_PKGS)
652	$(PKGDEBUG)sdotr=$(@F:packages.%=%); \
653	r=$${sdotr%.+(?)}; s=$${sdotr#+(?).}; \
654	print "Generating $$r $$s package list"; \
655	$(RM) $(@); $(TOUCH) $(@); \
656	$(NAWK) 'BEGIN { \
657		if (ARGC < 2) { \
658			exit; \
659		} \
660		retcode = 0; \
661		for (i = 1; i < ARGC; i++) { \
662			do { \
663				e = getline f < ARGV[i]; \
664			} while ((e == 1) && (f !~ /name=pkg.fmri/)); \
665			close(ARGV[i]); \
666			if (e == 1) { \
667				l = split(f, a, "="); \
668				print "depend fmri=" a[l], \
669					"type=$$(PKGDEP_TYPE)"; \
670			} else { \
671				print "no fmri in " ARGV[i] >> "/dev/stderr"; \
672				retcode = 2; \
673			} \
674		} \
675		exit retcode; \
676	}' `find $(PDIR) -type l -a \( $(PKGS:%=-name %.metadata.$$s.$$r -o) \
677		-name NOSUCHFILE \)` >> $(@)
678
679#
680# rules to validate proto area against manifests, check for safe
681# file permission modes, and generate a faux proto list
682#
683# For the check targets, the dependencies on $(PROC_PKGS) is specified
684# as a subordinate make process in order to suppress output.
685#
686makesilent:
687	@$(MAKE) -e $(PROC_PKGS) PKGMACH=$(PKGMACH) \
688		SUPPRESSPKGDEP=$(SUPPRESSPKGDEP) > /dev/null
689
690protocmp: makesilent
691	@validate_pkg -a $(PKGMACH) -v \
692		$(EXCEPTIONS:%=-e $(CODEMGR_WS)/exception_lists/%) \
693		-m $(PDIR) -p $(PKGROOT) -p $(TOOLSROOT)
694
695pmodes: makesilent
696	@validate_pkg -a $(PKGMACH) -M -m $(PDIR) \
697		-e $(CODEMGR_WS)/exception_lists/pmodes
698
699check: protocmp pmodes
700
701protolist: proto_list_$(PKGMACH)
702
703proto_list_$(PKGMACH): $(PROC_PKGS)
704	@validate_pkg -a $(PKGMACH) -L -m $(PDIR) > $(@)
705
706$(PROC_PKGS): $(PDIR)
707
708#
709# This is a convenience target to allow package names to function as
710# build targets.  Generally, using it is only useful when iterating on
711# development of a manifest.
712#
713# When processing a manifest, use the basename (without extension) of
714# the package.  When publishing, use the basename with a ".pub"
715# extension.
716#
717# Other than during manifest development, the preferred usage is to
718# avoid these targets and override PKGS on the make command line and
719# use the provided all and install targets.
720#
721$(PKGS) $(SYNTH_PKGS): $(PDIR)/$$(@:%=%.mog)
722
723$(PKGS:%=%.pub) $(SYNTH_PKGS:%=%.pub): $(PDIR)/$$(@)
724
725#
726# This is a convenience target to resolve dependencies without publishing
727# packages.
728#
729gendeps: $(PDIR)/gendeps
730
731#
732# These are convenience targets for cross-platform packaging.  If you
733# want to build any of "the normal" targets for a different
734# architecture, simply use "arch/target" as your build target.
735#
736# Since the most common use case for this is "install," the architecture
737# specific install targets have been further abbreviated to elide "/install."
738#
739i386/% sparc/%:
740	$(MAKE) -e $(@F) PKGMACH=$(@D) SUPPRESSPKGDEP=$(SUPPRESSPKGDEP)
741
742i386 sparc: $$(@)/install
743
744FRC:
745
746# EXPORT DELETE START
747XMOD_PKGS= \
748	BRCMbnx \
749	BRCMbnxe \
750	SUNWadpu320 \
751	SUNWcryptoint \
752	SUNWibsdpib \
753	SUNWkdc \
754	SUNWlsimega \
755	SUNWsvvs \
756	SUNWwbint \
757	SUNWwbsup
758
759EXPORT_SRC: CRYPT_SRC
760	$(RM) $(XMOD_PKGS:%=manifests/%.mf)
761	$(RM) Makefile+
762	$(SED) -e "/^# EXPORT DELETE START/,/^# EXPORT DELETE END/d" \
763		< Makefile > Makefile+
764	$(MV) -f Makefile+ Makefile
765	$(CHMOD) 444 Makefile
766
767CRYPT_SRC:
768	$(RM) manifests/SUNWcryptoint.mf+
769	$(SED) -e "/^# CRYPT DELETE START/,/^# CRYPT DELETE END/d" \
770		< manifests/SUNWcryptoint.mf > manifests/SUNWcryptoint.mf+
771	$(MV) manifests/SUNWcryptoint.mf+ manifests/SUNWcryptoint.mf
772	$(CHMOD) 444 manifests/SUNWcryptoint.mf
773
774# EXPORT DELETE END
775