xref: /titanic_52/usr/src/pkg/Makefile (revision 0ea64585698b885134cf212069f5ff7ebda376a6)
1ead1f93eSLiane Praza#
2ead1f93eSLiane Praza# CDDL HEADER START
3ead1f93eSLiane Praza#
4ead1f93eSLiane Praza# The contents of this file are subject to the terms of the
5ead1f93eSLiane Praza# Common Development and Distribution License (the "License").
6ead1f93eSLiane Praza# You may not use this file except in compliance with the License.
7ead1f93eSLiane Praza#
8ead1f93eSLiane Praza# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9ead1f93eSLiane Praza# or http://www.opensolaris.org/os/licensing.
10ead1f93eSLiane Praza# See the License for the specific language governing permissions
11ead1f93eSLiane Praza# and limitations under the License.
12ead1f93eSLiane Praza#
13ead1f93eSLiane Praza# When distributing Covered Code, include this CDDL HEADER in each
14ead1f93eSLiane Praza# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15ead1f93eSLiane Praza# If applicable, add the following below this CDDL HEADER, with the
16ead1f93eSLiane Praza# fields enclosed by brackets "[]" replaced with your own identifying
17ead1f93eSLiane Praza# information: Portions Copyright [yyyy] [name of copyright owner]
18ead1f93eSLiane Praza#
19ead1f93eSLiane Praza# CDDL HEADER END
20ead1f93eSLiane Praza#
21ead1f93eSLiane Praza
22ead1f93eSLiane Praza#
23ead1f93eSLiane Praza# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24ead1f93eSLiane Praza# Use is subject to license terms.
25ead1f93eSLiane Praza#
26ead1f93eSLiane Praza
27ead1f93eSLiane Prazainclude $(SRC)/Makefile.master
28ead1f93eSLiane Prazainclude $(SRC)/Makefile.buildnum
29ead1f93eSLiane Praza
30ead1f93eSLiane Praza#
31ead1f93eSLiane Praza# Make sure we're getting a consistent execution environment for the
32ead1f93eSLiane Praza# embedded scripts.
33ead1f93eSLiane Praza#
34ead1f93eSLiane PrazaSHELL= /usr/bin/ksh93
35ead1f93eSLiane Praza
36ead1f93eSLiane Praza#
37ead1f93eSLiane Praza# On non-OpenSolaris systems, the fallback to the build system to
38ead1f93eSLiane Praza# satisfy interconsolidation dependencies won't work.  To avoid that
39ead1f93eSLiane Praza# pitfall, disable package dependency generation on such systems.
40ead1f93eSLiane Praza#
41ead1f93eSLiane Praza# For any OpenSolaris system, SUNWcs should be installed, and is not
42ead1f93eSLiane Praza# expected to be renamed soon.
43ead1f93eSLiane Praza#
44ead1f93eSLiane Praza# To suppress package dependency generation on any system, regardless
45ead1f93eSLiane Praza# of how it was installed, set SUPPRESSPKGDEP=true in the build
46ead1f93eSLiane Praza# environment.
47ead1f93eSLiane Praza#
48ead1f93eSLiane PrazaSUPPRESSPKGDEP :sh= \
49ead1f93eSLiane Praza	tdir=`mktemp -d`; \
50ead1f93eSLiane Praza	PKG_CACHEDIR=$tdir pkg list SUNWcs > /dev/null 2>&1; \
51ead1f93eSLiane Praza	if [ $? -ne 0 ]; then \
52ead1f93eSLiane Praza		print "true"; \
53ead1f93eSLiane Praza	else \
54ead1f93eSLiane Praza		print "false"; \
55ead1f93eSLiane Praza	fi; rm -rf $tdir
56ead1f93eSLiane Praza
57ead1f93eSLiane Praza#
58ead1f93eSLiane Praza# Comment this line out or set "PKGDEBUG=" in your build environment
59ead1f93eSLiane Praza# to get more verbose output from the make processes in usr/src/pkg
60ead1f93eSLiane Praza#
61ead1f93eSLiane PrazaPKGDEBUG= @
62ead1f93eSLiane Praza
63ead1f93eSLiane Praza#
64ead1f93eSLiane Praza# Cross platform packaging notes
65ead1f93eSLiane Praza#
66ead1f93eSLiane Praza# By default, we package the proto area from the same architecture as
67ead1f93eSLiane Praza# the packaging build.  In other words, if you're running nightly or
68ead1f93eSLiane Praza# bldenv on an x86 platform, it will take objects from the x86 proto
69ead1f93eSLiane Praza# area and use them to create x86 repositories.
70ead1f93eSLiane Praza#
71ead1f93eSLiane Praza# If you want to create repositories for an architecture that's
72ead1f93eSLiane Praza# different from $(uname -p), you do so by setting PKGMACH in your
73ead1f93eSLiane Praza# build environment.
74ead1f93eSLiane Praza#
75ead1f93eSLiane Praza# For this to work correctly, the following must all happen:
76ead1f93eSLiane Praza#
77ead1f93eSLiane Praza#   1. You need the desired proto area, which you can get either by
78ead1f93eSLiane Praza#      doing a gatekeeper-style build with the -U option to
79ead1f93eSLiane Praza#      nightly(1), or by using rsync.  If you don't do this, you will
80ead1f93eSLiane Praza#      get packaging failures building all packages, because pkgsend
81ead1f93eSLiane Praza#      is unable to find the required binaries.
82ead1f93eSLiane Praza#   2. You need the desired tools proto area, which you can get in the
83ead1f93eSLiane Praza#      same ways as the normal proto area.  If you don't do this, you
84ead1f93eSLiane Praza#      will get packaging failures building SUNWonbld, because pkgsend is
85ead1f93eSLiane Praza#      unable to find the tools binaries.
86ead1f93eSLiane Praza#   3. You need to have built the appropriate third party license
87ead1f93eSLiane Praza#      files in $SRC, which generally means you should override SRC in
88ead1f93eSLiane Praza#      your build environment.  If you don't do this, you will get
89ead1f93eSLiane Praza#      packaging failures because pkgsend is unable to find various
90ead1f93eSLiane Praza#      THIRDPARTYLICENSE files.
91ead1f93eSLiane Praza#   4. The remainder of this Makefile should never refer directly to
92ead1f93eSLiane Praza#      $(MACH).  Instead, $(PKGMACH) should be used whenever an
93ead1f93eSLiane Praza#      architecture-specific path or token is needed.  If this is done
94ead1f93eSLiane Praza#      incorrectly, then packaging will fail, and you will see the
95ead1f93eSLiane Praza#      value of $(uname -p) instead of the value of $(PKGMACH) in the
96ead1f93eSLiane Praza#      commands that fail.
97ead1f93eSLiane Praza#   5. Each time a rule in this Makefile invokes $(MAKE), it should
98ead1f93eSLiane Praza#      pass PKGMACH=$(PKGMACH) explicitly on the command line.  If
99ead1f93eSLiane Praza#      this is done incorrectly, then packaging will fail, and you
100ead1f93eSLiane Praza#      will see the value of $(uname -p) instead of the value of
101ead1f93eSLiane Praza#      $(PKGMACH) in the commands that fail.
102ead1f93eSLiane Praza#
103ead1f93eSLiane Praza# Refer also to the convenience targets defined later in this
104ead1f93eSLiane Praza# Makefile.
105ead1f93eSLiane Praza#
106ead1f93eSLiane PrazaPKGMACH=	$(MACH)
107ead1f93eSLiane Praza
108ead1f93eSLiane Praza#
109ead1f93eSLiane Praza# ROOT, TOOLS_PROTO, and PKGARCHIVE should be set by nightly or
110ead1f93eSLiane Praza# bldenv.  These macros translate them into terms of $PKGMACH, instead
111ead1f93eSLiane Praza# of $ARCH.
112ead1f93eSLiane Praza#
113ead1f93eSLiane PrazaPKGROOT.cmd=	print $(ROOT) | sed -e s:/root_$(MACH):/root_$(PKGMACH):
114ead1f93eSLiane PrazaPKGROOT=	$(PKGROOT.cmd:sh)
115ead1f93eSLiane PrazaTOOLSROOT.cmd=	print $(TOOLS_PROTO) | sed -e s:/root_$(MACH):/root_$(PKGMACH):
116ead1f93eSLiane PrazaTOOLSROOT=	$(TOOLSROOT.cmd:sh)
117ead1f93eSLiane PrazaPKGDEST.cmd=	print $(PKGARCHIVE) | sed -e s:/$(MACH)/:/$(PKGMACH)/:
118ead1f93eSLiane PrazaPKGDEST=	$(PKGDEST.cmd:sh)
119ead1f93eSLiane Praza
120ead1f93eSLiane Praza#
121ead1f93eSLiane Praza# The publish transforms, EXCEPTIONS list, and some manifests need to
122ead1f93eSLiane Praza# know when we're building open-only and when we're using internal
123ead1f93eSLiane Praza# crypto bits.
124ead1f93eSLiane Praza#
125ead1f93eSLiane Praza# We only use internal crypto when we're doing a closed build, the
126ead1f93eSLiane Praza# CODESIGN_USER env variable is not set, and ON_CRYPTO_BINS is not set.
127ead1f93eSLiane Praza# This matches the conditions under which the internal key and cert
128ead1f93eSLiane Praza# are needed for the packaged objects.
129ead1f93eSLiane Praza#
130ead1f93eSLiane Praza# We use X_FLAG, as exported by nightly and bldenv, to decide when we
131ead1f93eSLiane Praza# need IHV-related exceptions for protocmp.
132ead1f93eSLiane Praza#
133ead1f93eSLiane Praza$(CLOSED_BUILD)OPEN_ONLY_BUILD= $(POUND_SIGN)
134ead1f93eSLiane Praza
135ead1f93eSLiane PrazaUSE_INTERNAL_CRYPTO= $(POUND_SIGN)
136ead1f93eSLiane PrazaUI1= $(CODESIGN_USER:%=$(POUND_SIGN))
137ead1f93eSLiane Praza$(UI1)UI2= $(ON_CRYPTO_BINS:%=$(POUND_SIGN))
138ead1f93eSLiane Praza$(CLOSED_BUILD)USE_INTERNAL_CRYPTO= $(UI1)$(UI2)
139ead1f93eSLiane PrazaUSE_SIGNED_CRYPTO=
140ead1f93eSLiane Praza$(USE_INTERNAL_CRYPTO)USE_SIGNED_CRYPTO= $(POUND_SIGN)
141ead1f93eSLiane Praza
142ead1f93eSLiane PrazaX_FLAG=			n
143ead1f93eSLiane PrazaIHV_COPY_BUILD1=	$(X_FLAG:n%=$(POUND_SIGN)%)
144ead1f93eSLiane PrazaIHV_COPY_BUILD=		$(IHV_COPY_BUILD1:y%=%)
145ead1f93eSLiane Praza
146ead1f93eSLiane Praza
147ead1f93eSLiane PrazaEXCEPTIONS= packaging
148ead1f93eSLiane Praza$(CLOSED_BUILD)EXCEPTIONS += packaging.closed
149ead1f93eSLiane Praza$(OPEN_ONLY_BUILD)EXCEPTIONS += packaging.open
150ead1f93eSLiane Praza$(IHV_COPY_BUILD)EXCEPTIONS += packaging.ihv
151ead1f93eSLiane Praza
152ead1f93eSLiane PrazaPKGMOGRIFY= pkgmogrify
153ead1f93eSLiane Praza
154ead1f93eSLiane Praza#
155ead1f93eSLiane Praza# Always build the redistributable repository, but only build the
156ead1f93eSLiane Praza# nonredistributable bits if we have access to closed source.
157ead1f93eSLiane Praza#
158ead1f93eSLiane Praza# Some objects that result from the closed build are still
159ead1f93eSLiane Praza# redistributable, and should be packaged as part of an open-only
160ead1f93eSLiane Praza# build.  Access to those objects is provided via the closed-bins
161ead1f93eSLiane Praza# tarball.  See usr/src/tools/scripts/bindrop.sh for details.
162ead1f93eSLiane Praza#
163ead1f93eSLiane PrazaREPOS= redist
164ead1f93eSLiane Praza$(CLOSED_BUILD)REPOS += extra
165ead1f93eSLiane Praza
166ead1f93eSLiane Praza#
167ead1f93eSLiane Praza# The packages directory will contain the processed manifests as
168ead1f93eSLiane Praza# direct build targets and subdirectories for package metadata extracted
169ead1f93eSLiane Praza# incidentally during manifest processing.
170ead1f93eSLiane Praza#
171ead1f93eSLiane Praza# Nothing underneath $(PDIR) should ever be managed by SCM.
172ead1f93eSLiane Praza#
173ead1f93eSLiane PrazaPDIR= packages.$(PKGMACH)
174ead1f93eSLiane Praza
175ead1f93eSLiane Praza#
176ead1f93eSLiane Praza# The tools proto must be specified for dependency generation.
177ead1f93eSLiane Praza# Publication from the tools proto area is managed in the
178ead1f93eSLiane Praza# publication rule.
179ead1f93eSLiane Praza#
180ead1f93eSLiane Praza$(PDIR)/SUNWonbld.dep:= PKGROOT= $(TOOLSROOT)
181ead1f93eSLiane Praza
182ead1f93eSLiane PrazaPKGPUBLISHER= $(PKGPUBLISHER_REDIST)
183ead1f93eSLiane Praza$(PKGDEST)/repo.extra:= PKGPUBLISHER= $(PKGPUBLISHER_NONREDIST)
184ead1f93eSLiane Praza
185ead1f93eSLiane Praza#
186ead1f93eSLiane Praza# To get these defaults, manifests should simply refer to $(PKGVERS).
187ead1f93eSLiane Praza#
188ead1f93eSLiane PrazaPKGVERS_COMPONENT= 0.$(RELEASE)
189ead1f93eSLiane PrazaPKGVERS_BUILTON= $(RELEASE)
190ead1f93eSLiane PrazaPKGVERS_BRANCH= 0.$(ONNV_BUILDNUM)
191ead1f93eSLiane PrazaPKGVERS= $(PKGVERS_COMPONENT),$(PKGVERS_BUILTON)-$(PKGVERS_BRANCH)
192ead1f93eSLiane Praza
193ead1f93eSLiane Praza#
194ead1f93eSLiane Praza# The ARCH32 and ARCH64 macros are used in the manifests to express
195ead1f93eSLiane Praza# architecture-specific subdirectories in the installation paths
196ead1f93eSLiane Praza# for isaexec'd commands.
197ead1f93eSLiane Praza#
198ead1f93eSLiane Praza# We can't simply use $(MACH32) and $(MACH64) here, because they're
199ead1f93eSLiane Praza# only defined for the build architecture.  To do cross-platform
200ead1f93eSLiane Praza# packaging, we need both values.
201ead1f93eSLiane Praza#
202ead1f93eSLiane Prazai386_ARCH32= i86
203ead1f93eSLiane Prazasparc_ARCH32= sparcv7
204ead1f93eSLiane Prazai386_ARCH64= amd64
205ead1f93eSLiane Prazasparc_ARCH64= sparcv9
206ead1f93eSLiane Praza
207ead1f93eSLiane Praza#
208ead1f93eSLiane Praza# macros and transforms needed by pkgmogrify
209ead1f93eSLiane Praza#
210ead1f93eSLiane Praza# If you append to this list using target-specific assignments (:=),
211ead1f93eSLiane Praza# be very careful that the targets are of the form $(PDIR)/pkgname.  If
212ead1f93eSLiane Praza# you use a higher level target, or a package list, you'll trigger a
213ead1f93eSLiane Praza# complete reprocessing of all manifests because they'll fail command
214ead1f93eSLiane Praza# dependency checking.
215ead1f93eSLiane Praza#
216ead1f93eSLiane PrazaPM_TRANSFORMS= publish restart_fmri defaults extract_metadata
217ead1f93eSLiane PrazaPM_INC= transforms
218ead1f93eSLiane Praza
219ead1f93eSLiane PrazaPKGMOG_DEFINES= \
220ead1f93eSLiane Praza	i386_ONLY=$(POUND_SIGN) \
221ead1f93eSLiane Praza	sparc_ONLY=$(POUND_SIGN) \
222ead1f93eSLiane Praza	$(PKGMACH)_ONLY= \
223ead1f93eSLiane Praza	ARCH=$(PKGMACH) \
224ead1f93eSLiane Praza	ARCH32=$($(PKGMACH)_ARCH32) \
225ead1f93eSLiane Praza	ARCH64=$($(PKGMACH)_ARCH64) \
226ead1f93eSLiane Praza	PKGVERS_COMPONENT=$(PKGVERS_COMPONENT) \
227ead1f93eSLiane Praza	PKGVERS_BUILTON=$(PKGVERS_BUILTON) \
228ead1f93eSLiane Praza	PKGVERS_BRANCH=$(PKGVERS_BRANCH) \
229ead1f93eSLiane Praza	PKGVERS=$(PKGVERS) \
230ead1f93eSLiane Praza	SRC=$(SRC) \
231ead1f93eSLiane Praza	CLOSED_BUILD=$(CLOSED_BUILD) \
232ead1f93eSLiane Praza	OPEN_BUILD=$(OPEN_ONLY_BUILD) \
233ead1f93eSLiane Praza	USE_INTERNAL_CRYPTO=$(USE_INTERNAL_CRYPTO) \
234ead1f93eSLiane Praza	USE_SIGNED_CRYPTO=$(USE_SIGNED_CRYPTO)
235ead1f93eSLiane Praza
236ead1f93eSLiane PrazaPKGDEP_TOKENS_i386= \
237ead1f93eSLiane Praza	'PLATFORM=i86hvm' \
238ead1f93eSLiane Praza	'PLATFORM=i86pc' \
239ead1f93eSLiane Praza	'PLATFORM=i86xpv' \
240ead1f93eSLiane Praza	'ISALIST=amd64' \
241ead1f93eSLiane Praza	'ISALIST=i386'
242ead1f93eSLiane PrazaPKGDEP_TOKENS_sparc= \
243ead1f93eSLiane Praza	'PLATFORM=sun4u' \
244ead1f93eSLiane Praza	'PLATFORM=sun4v' \
245ead1f93eSLiane Praza	'ISALIST=sparcv9' \
246ead1f93eSLiane Praza	'ISALIST=sparc'
247ead1f93eSLiane PrazaPKGDEP_TOKENS= $(PKGDEP_TOKENS_$(PKGMACH))
248ead1f93eSLiane Praza
249ead1f93eSLiane Praza#
250ead1f93eSLiane Praza# The package lists are generated with $(PKGDEP_TYPE) as their
251ead1f93eSLiane Praza# dependency types, so that they can be included by either an
252ead1f93eSLiane Praza# incorporation or a group package.
253ead1f93eSLiane Praza#
254ead1f93eSLiane Praza$(PDIR)/osnet-redist.mog $(PDIR)/osnet-extra.mog:= PKGDEP_TYPE= require
255ead1f93eSLiane Praza$(PDIR)/osnet-incorporation.mog:= PKGDEP_TYPE= incorporate
256ead1f93eSLiane Praza
257ead1f93eSLiane PrazaPKGDEP_INCORP= \
258ead1f93eSLiane Praza	depend fmri=consolidation/osnet/osnet-incorporation type=require
259ead1f93eSLiane Praza
260ead1f93eSLiane Praza#
261ead1f93eSLiane Praza# All packaging build products should go into $(PDIR), so they don't
262ead1f93eSLiane Praza# need to be included separately in CLOBBERFILES.
263ead1f93eSLiane Praza#
264ead1f93eSLiane PrazaCLOBBERFILES= $(PDIR) proto_list_$(PKGMACH)
265ead1f93eSLiane Praza
266ead1f93eSLiane Praza#
267ead1f93eSLiane Praza# By default, PKGS will list all manifests.  To build and/or publish a
268ead1f93eSLiane Praza# subset of packages, override this on the command line or in the
269ead1f93eSLiane Praza# build environment and then reference (implicitly or explicitly) the all
270ead1f93eSLiane Praza# or install targets.
271ead1f93eSLiane Praza#
272ead1f93eSLiane PrazaMANIFESTS :sh= (cd manifests; print *.mf)
273ead1f93eSLiane PrazaPKGS= $(MANIFESTS:%.mf=%)
274ead1f93eSLiane PrazaDEP_PKGS= $(PKGS:%=$(PDIR)/%.dep)
275ead1f93eSLiane PrazaPROC_PKGS= $(PKGS:%=$(PDIR)/%.mog)
276ead1f93eSLiane Praza
277ead1f93eSLiane Praza#
278ead1f93eSLiane Praza# Track the synthetic manifests separately so we can properly express
279ead1f93eSLiane Praza# build rules and dependencies.  The synthetic and real packages use
280ead1f93eSLiane Praza# different sets of transforms and macros for pkgmogrify.
281ead1f93eSLiane Praza#
282ead1f93eSLiane PrazaSYNTH_PKGS= osnet-incorporation osnet-redist
283ead1f93eSLiane Praza$(CLOSED_BUILD)SYNTH_PKGS += osnet-extra
284ead1f93eSLiane PrazaDEP_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.dep)
285ead1f93eSLiane PrazaPROC_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.mog)
286ead1f93eSLiane Praza
287ead1f93eSLiane Praza#
288ead1f93eSLiane Praza# For each package, we determine the target repository based on
289ead1f93eSLiane Praza# manifest-embedded metadata.  Because we make that determination on
290ead1f93eSLiane Praza# the fly, the publication target cannot be expressed as a
291ead1f93eSLiane Praza# subdirectory inside the unknown-by-the-makefile target repository.
292ead1f93eSLiane Praza#
293ead1f93eSLiane Praza# In order to limit the target set to real files in known locations,
294ead1f93eSLiane Praza# we use a ".pub" file in $(PDIR) for each processed manifest, regardless
295ead1f93eSLiane Praza# of content or target repository.
296ead1f93eSLiane Praza#
297ead1f93eSLiane PrazaPUB_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.pub) $(PKGS:%=$(PDIR)/%.pub)
298ead1f93eSLiane Praza
299ead1f93eSLiane Praza#
300ead1f93eSLiane Praza# Any given repository- and status-specific package list may be empty,
301ead1f93eSLiane Praza# but we can only determine that dynamically, so we always generate all
302ead1f93eSLiane Praza# lists for each repository we're building.
303ead1f93eSLiane Praza#
304ead1f93eSLiane Praza# The meanings of each package status are as follows:
305ead1f93eSLiane Praza#
306ead1f93eSLiane Praza# 	PKGSTAT		meaning
307ead1f93eSLiane Praza# 	----------	----------------------------------------------------
308ead1f93eSLiane Praza# 	noincorp	Do not include in incorporation or group package
309ead1f93eSLiane Praza#	obsolete	Include in incorporation, but not group package
310*0ea64585SLiane Praza#	renamed		Include in incorporation, but not group package
311ead1f93eSLiane Praza#	current		Include in incorporation and group package
312ead1f93eSLiane Praza#
313ead1f93eSLiane Praza# Since the semantics of the "noincorp" package status dictate that
314ead1f93eSLiane Praza# such packages are not included in the incorporation or group packages,
315ead1f93eSLiane Praza# there is no need to build noincorp package lists.
316ead1f93eSLiane Praza#
317ead1f93eSLiane Praza# Since packages depend on their incorporation, noincorp necessarily
318ead1f93eSLiane Praza# implies nodepend, or it would inadvertently pull in other packages.
319ead1f93eSLiane Praza#
320ead1f93eSLiane PrazaPKGLISTS= \
321ead1f93eSLiane Praza	$(REPOS:%=$(PDIR)/packages.%.current) \
322ead1f93eSLiane Praza	$(REPOS:%=$(PDIR)/packages.%.renamed) \
323ead1f93eSLiane Praza	$(REPOS:%=$(PDIR)/packages.%.obsolete)
324ead1f93eSLiane Praza
325ead1f93eSLiane Praza.KEEP_STATE:
326ead1f93eSLiane Praza
327ead1f93eSLiane Praza#
328ead1f93eSLiane Praza# XXX Once we can publish in parallel, we can add $(PUB_PKGS) here.
329ead1f93eSLiane Praza# And then we can also remove the leading "all .WAIT" from the
330ead1f93eSLiane Praza# install target, which currently allows us to at least process in
331ead1f93eSLiane Praza# parallel.
332ead1f93eSLiane Praza#
333ead1f93eSLiane Praza.PARALLEL: $(PKGS) $(PROC_PKGS) $(DEP_PKGS) \
334ead1f93eSLiane Praza	$(PROC_SYNTH_PKGS) $(DEP_SYNTH_PKGS)
335ead1f93eSLiane Praza
336ead1f93eSLiane Praza#
337ead1f93eSLiane Praza# For a single manifest, the dependency chain looks like this:
338ead1f93eSLiane Praza#
339ead1f93eSLiane Praza#	raw manifest (mypkg.mf)
340ead1f93eSLiane Praza#		|
341ead1f93eSLiane Praza#		| use pkgmogrify to process raw manifest
342ead1f93eSLiane Praza#		|
343ead1f93eSLiane Praza#	processed manifest (mypkg.mog)
344ead1f93eSLiane Praza#		|
345ead1f93eSLiane Praza#	   *    | use pkgdepend generate to generate dependencies
346ead1f93eSLiane Praza#		|
347ead1f93eSLiane Praza#	manifest with TBD dependencies (mypkg.dep)
348ead1f93eSLiane Praza#		|
349ead1f93eSLiane Praza#	   %    | use pkgdepend resolve to resolve dependencies
350ead1f93eSLiane Praza#		|
351ead1f93eSLiane Praza#	manifest with dependencies resolved (mypkg.res)
352ead1f93eSLiane Praza#		|
353ead1f93eSLiane Praza#		| use pkgsend to publish the package
354ead1f93eSLiane Praza#		|
355ead1f93eSLiane Praza#	placeholder to indicate successful publication (mypkg.pub)
356ead1f93eSLiane Praza#
357ead1f93eSLiane Praza# * This may be suppressed via SUPPRESSPKGDEP.  The resulting
358ead1f93eSLiane Praza#   packages will install correctly, but care must be taken to
359ead1f93eSLiane Praza#   install all dependencies, because pkg will not have the input
360ead1f93eSLiane Praza#   it needs to determine this automatically.
361ead1f93eSLiane Praza#
362ead1f93eSLiane Praza# % This is included in this diagram to make the picture complete, but
363ead1f93eSLiane Praza#   this is a point of synchronization in the build process.
364ead1f93eSLiane Praza#   Dependency resolution is actually done once on the entire set of
365ead1f93eSLiane Praza#   manifests, not on a per-package basis.
366ead1f93eSLiane Praza#
367ead1f93eSLiane Praza# The full dependency chain for generating everything that needs to be
368ead1f93eSLiane Praza# published, without actually publishing it, looks like this:
369ead1f93eSLiane Praza#
370ead1f93eSLiane Praza#	processed synthetic packages
371ead1f93eSLiane Praza#		|		|
372ead1f93eSLiane Praza#       package lists	    synthetic package manifests
373ead1f93eSLiane Praza#		|
374ead1f93eSLiane Praza#	processed real packages
375ead1f93eSLiane Praza#	    |		|
376ead1f93eSLiane Praza#	package dir	real package manifests
377ead1f93eSLiane Praza#
378ead1f93eSLiane Praza# Here, each item is a set of real or synthetic packages.  For this
379ead1f93eSLiane Praza# portion of the build, no reference is made to the proto area.  It is
380ead1f93eSLiane Praza# therefore suitable for the "all" target, as opposed to "install."
381ead1f93eSLiane Praza#
382ead1f93eSLiane Praza# Since each of these steps is expressed explicitly, "all" need only
383ead1f93eSLiane Praza# depend on the head of the chain.
384ead1f93eSLiane Praza#
385ead1f93eSLiane Praza# From the end of manifest processing, the publication dependency
386ead1f93eSLiane Praza# chain looks like this:
387ead1f93eSLiane Praza#
388ead1f93eSLiane Praza#		repository metadata (catalogs and search indices)
389ead1f93eSLiane Praza#			|
390ead1f93eSLiane Praza#			| pkg.depotd
391ead1f93eSLiane Praza#			|
392ead1f93eSLiane Praza#		published packages
393ead1f93eSLiane Praza#		 |		|
394ead1f93eSLiane Praza#		 |		| pkgsend publish
395ead1f93eSLiane Praza#		 |		|
396ead1f93eSLiane Praza#	  repositories 	    resolved dependencies
397ead1f93eSLiane Praza#		 |			|
398ead1f93eSLiane Praza# pkgsend	 |			| pkgdepend resolve
399ead1f93eSLiane Praza# create-repository	 	 	|
400ead1f93eSLiane Praza#		 |		generated dependencies
401ead1f93eSLiane Praza#	 repo directories		|
402ead1f93eSLiane Praza#					| pkgdepend
403ead1f93eSLiane Praza#					|
404ead1f93eSLiane Praza#				processed manifests
405ead1f93eSLiane Praza#
406ead1f93eSLiane Praza# Due to limitations in pkgdepend, we cannot simply treat synthetic
407ead1f93eSLiane Praza# and real manifests identically.  But we don't really want to
408ead1f93eSLiane Praza# maintain a separate chain for synthetic manifests, so for the left
409ead1f93eSLiane Praza# side of this diagram, we actually do faux dependency generation and
410ead1f93eSLiane Praza# resolution, so we end up with the expected set of files in $(PDIR),
411ead1f93eSLiane Praza# per the individual file chain described above: mf, mog, dep, res,
412ead1f93eSLiane Praza# and pub files for each manifest.
413ead1f93eSLiane Praza#
414ead1f93eSLiane Prazaall: $(PROC_SYNTH_PKGS) proto_list_$(PKGMACH)
415ead1f93eSLiane Praza
416ead1f93eSLiane Praza#
417ead1f93eSLiane Praza# This will build the directory to contain the processed manifests
418ead1f93eSLiane Praza# and the metadata symlinks.
419ead1f93eSLiane Praza#
420ead1f93eSLiane Praza$(PDIR):
421ead1f93eSLiane Praza	@print "Creating $(@)"
422ead1f93eSLiane Praza	$(PKGDEBUG)$(INS.dir)
423ead1f93eSLiane Praza
424ead1f93eSLiane Praza#
425ead1f93eSLiane Praza# This rule resolves dependencies across all published manifests.
426ead1f93eSLiane Praza# We should be able to do this with
427ead1f93eSLiane Praza#
428ead1f93eSLiane Praza#    pkgdepend resolve -m $(PUB_PKGS:%.pub=%.dep)
429ead1f93eSLiane Praza#
430ead1f93eSLiane Praza# but until 14113 is fixed, the incorporations confuse pkgdepend, so we
431ead1f93eSLiane Praza# just create the .res file for DEP_SYNTH_PKGS directly.
432ead1f93eSLiane Praza#
433ead1f93eSLiane Praza# We also shouldn't have to ignore the error from pkgdepend, but
434ead1f93eSLiane Praza# until at least 14110 is resolved, pkgdepend will always exit with
435ead1f93eSLiane Praza# an error.
436ead1f93eSLiane Praza#
437ead1f93eSLiane Praza$(PDIR)/gendeps: $(DEP_SYNTH_PKGS) $(DEP_PKGS)
438ead1f93eSLiane Praza	-$(PKGDEBUG)if [ "$(SUPPRESSPKGDEP)" = "true" ]; then \
439ead1f93eSLiane Praza		print "Suppressing dependency resolution"; \
440ead1f93eSLiane Praza		for p in $(DEP_PKGS:%.dep=%); do \
441ead1f93eSLiane Praza			$(CP) $$p.dep $$p.res; \
442ead1f93eSLiane Praza		done; \
443ead1f93eSLiane Praza	else \
444ead1f93eSLiane Praza		print "Resolving dependencies"; \
445ead1f93eSLiane Praza		pkgdepend resolve -m $(DEP_PKGS); \
446ead1f93eSLiane Praza		for p in $(DEP_PKGS:%.dep=%); do \
447ead1f93eSLiane Praza			$(MV) $$p.dep.res $$p.res; \
448ead1f93eSLiane Praza		done; \
449ead1f93eSLiane Praza	fi
450ead1f93eSLiane Praza	$(PKGDEBUG)for p in $(DEP_SYNTH_PKGS:%.dep=%); \
451ead1f93eSLiane Praza	do \
452ead1f93eSLiane Praza		$(CP) $$p.dep $$p.res; \
453ead1f93eSLiane Praza	done
454ead1f93eSLiane Praza	$(PKGDEBUG)$(TOUCH) $(@)
455ead1f93eSLiane Praza
456ead1f93eSLiane Prazainstall: repository-metadata
457ead1f93eSLiane Praza
458ead1f93eSLiane Prazarepository-metadata: publish_pkgs
459ead1f93eSLiane Praza	@print "Creating repository metadata"
460ead1f93eSLiane Praza	$(PKGDEBUG)for r in $(REPOS); do \
461ead1f93eSLiane Praza		/usr/lib/pkg.depotd -d $(PKGDEST)/repo.$$r \
462ead1f93eSLiane Praza			--add-content --exit-ready; \
463ead1f93eSLiane Praza	done
464ead1f93eSLiane Praza
465ead1f93eSLiane Praza#
466ead1f93eSLiane Praza# Since we create zero-length processed manifests for a graceful abort
467ead1f93eSLiane Praza# from pkgmogrify, we need to detect that here and make no effort to
468ead1f93eSLiane Praza# publish the package.
469ead1f93eSLiane Praza#
470ead1f93eSLiane Praza# For all other packages, we publish them regardless of status.  We
471ead1f93eSLiane Praza# derive the target repository as a component of the metadata-derived
472ead1f93eSLiane Praza# symlink for each package.
473ead1f93eSLiane Praza#
474ead1f93eSLiane Prazapublish_pkgs: $(REPOS:%=$(PKGDEST)/repo.%) $(PDIR)/gendeps .WAIT $(PUB_PKGS)
475ead1f93eSLiane Praza
476ead1f93eSLiane Praza$(PUB_PKGS): FRC
477ead1f93eSLiane Praza
478ead1f93eSLiane Praza#
479ead1f93eSLiane Praza# Initialize the empty on-disk repositories
480ead1f93eSLiane Praza#
481ead1f93eSLiane Praza$(REPOS:%=$(PKGDEST)/repo.%):
482ead1f93eSLiane Praza	@print "Initializing $(@F)"
483ead1f93eSLiane Praza	$(PKGDEBUG)$(INS.dir)
484ead1f93eSLiane Praza	$(PKGDEBUG)pkgsend -s file://$(@) create-repository \
485ead1f93eSLiane Praza		--set-property publisher.prefix=$(PKGPUBLISHER)
486ead1f93eSLiane Praza
487ead1f93eSLiane Praza#
488ead1f93eSLiane Praza# rule to process real manifests
489ead1f93eSLiane Praza#
490ead1f93eSLiane Praza# To allow redistributability and package status to change, we must
491ead1f93eSLiane Praza# remove not only the actual build target (the processed manifest), but
492ead1f93eSLiane Praza# also the incidental ones (the metadata-derived symlinks).
493ead1f93eSLiane Praza#
494ead1f93eSLiane Praza# If pkgmogrify exits cleanly but fails to create the specified output
495ead1f93eSLiane Praza# file, it means that it encountered an abort directive.  That means
496ead1f93eSLiane Praza# that this package should not be published for this particular build
497ead1f93eSLiane Praza# environment.  Since we can't prune such packages from $(PKGS)
498ead1f93eSLiane Praza# retroactively, we need to create an empty target file to keep make
499ead1f93eSLiane Praza# from trying to rebuild it every time.  For these empty targets, we
500ead1f93eSLiane Praza# do not create metadata symlinks.
501ead1f93eSLiane Praza#
502ead1f93eSLiane Praza# Automatic dependency resolution to files is also done at this phase of
503ead1f93eSLiane Praza# processing.  The skipped packages are skipped due to existing bugs
504ead1f93eSLiane Praza# in pkgdepend.
505ead1f93eSLiane Praza#
506ead1f93eSLiane Praza# The incorporation dependency is tricky: it needs to go into all
507ead1f93eSLiane Praza# current and renamed manifests (ie all incorporated packages), but we
508ead1f93eSLiane Praza# don't know which those are until after we run pkgmogrify.  So
509ead1f93eSLiane Praza# instead of expressing it as a transform, we tack it on ex post facto.
510ead1f93eSLiane Praza#
511ead1f93eSLiane Praza# Implementation notes:
512ead1f93eSLiane Praza#
513ead1f93eSLiane Praza# - The first $(RM) must not match other manifests, or we'll run into
514ead1f93eSLiane Praza#   race conditions with parallel manifest processing.
515ead1f93eSLiane Praza#
516ead1f93eSLiane Praza# - The make macros [ie $(MACRO)] are evaluated when the makefile is
517ead1f93eSLiane Praza#   read in, and will result in a fixed, macro-expanded rule for each
518ead1f93eSLiane Praza#   target enumerated in $(PROC_PKGS).
519ead1f93eSLiane Praza#
520ead1f93eSLiane Praza# - The shell variables (ie $$VAR) are assigned on the fly, as the rule
521ead1f93eSLiane Praza#   is executed.  The results may only be referenced in the shell in
522ead1f93eSLiane Praza#   which they are assigned, so from the perspective of make, all code
523ead1f93eSLiane Praza#   that needs these variables needs to be part of the same line of
524ead1f93eSLiane Praza#   code.  Hence the use of command separators and line continuation
525ead1f93eSLiane Praza#   characters.
526ead1f93eSLiane Praza#
527ead1f93eSLiane Praza# - The extract_metadata transforms are designed to spit out shell
528ead1f93eSLiane Praza#   variable assignments to stdout.  So the eval statement should
529ead1f93eSLiane Praza#   begin with the default values, and any output from pkgmogrify
530ead1f93eSLiane Praza#   should be in the form of a variable assignment to override those
531ead1f93eSLiane Praza#   defaults.
532ead1f93eSLiane Praza#
533ead1f93eSLiane Praza# - When this rule completes execution, it must leave an updated
534ead1f93eSLiane Praza#   target file ($@) in place, or make will reprocess the package
535ead1f93eSLiane Praza#   every time it encounters it as a dependency.  Hence the "touch"
536ead1f93eSLiane Praza#   statement to ensure that the target is created, even when
537ead1f93eSLiane Praza#   pkgmogrify encounters an abort in the publish transforms.  This
538ead1f93eSLiane Praza#   will not cause publication failures when switching build
539ead1f93eSLiane Praza#   environments, because $(CLOSED_BUILD) and $(OPEN_ONLY) are
540ead1f93eSLiane Praza#   referenced in $(PKGMOG_DEFINES), and changes will therefore
541ead1f93eSLiane Praza#   trigger a rebuild for command dependency failure.  (Command
542ead1f93eSLiane Praza#   dependency checking is turned on by .KEEP_STATE: above.)
543ead1f93eSLiane Praza#
544ead1f93eSLiane Praza
545ead1f93eSLiane Praza.SUFFIXES: .mf .mog .dep .res .pub
546ead1f93eSLiane Praza
547ead1f93eSLiane Praza$(PDIR)/%.mog: manifests/%.mf
548ead1f93eSLiane Praza	@print "Processing manifest $(<F)"
549ead1f93eSLiane Praza	$(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) $(@:%.mog=%.nodepend) \
550ead1f93eSLiane Praza		$(PDIR)/$(@F:%.mog=%).metadata.*
551ead1f93eSLiane Praza	$(PKGDEBUG)eval REPO=redist PKGSTAT=current \
552ead1f93eSLiane Praza		NODEPEND=$(SUPPRESSPKGDEP) \
553ead1f93eSLiane Praza		`$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \
554ead1f93eSLiane Praza		$(PKGMOG_DEFINES:%=-D %) -O $(@) $(<) $(PM_TRANSFORMS)`; \
555ead1f93eSLiane Praza	if [ -f $(@) ]; then \
556ead1f93eSLiane Praza		if [ \( "$$NODEPEND" != "false" \) -o \
557ead1f93eSLiane Praza		     \( "$$PKGSTAT" = "noincorp" \) ]; then \
558ead1f93eSLiane Praza			 $(TOUCH) $(@:%.mog=%.nodepend); \
559ead1f93eSLiane Praza		fi; \
560ead1f93eSLiane Praza		$(LN) -s $(@F) \
561ead1f93eSLiane Praza			$(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \
562ead1f93eSLiane Praza		if [ \( "$$PKGSTAT" = "current" \) -o \
563ead1f93eSLiane Praza		     \( "$$PKGSTAT" = "renamed" \) ]; \
564ead1f93eSLiane Praza			then print $(PKGDEP_INCORP) >> $(@); \
565ead1f93eSLiane Praza		fi; \
566ead1f93eSLiane Praza	else \
567ead1f93eSLiane Praza		$(TOUCH) $(@); \
568ead1f93eSLiane Praza	fi
569ead1f93eSLiane Praza
570ead1f93eSLiane Praza$(PDIR)/%.dep: $(PDIR)/%.mog
571ead1f93eSLiane Praza	@print "Generating dependencies for $(<F)"
572ead1f93eSLiane Praza	$(PKGDEBUG)$(RM) $(@)
573ead1f93eSLiane Praza	$(PKGDEBUG)if [ ! -f $(@:%.dep=%.nodepend) ]; then \
574ead1f93eSLiane Praza		pkgdepend generate -m $(PKGDEP_TOKENS:%=-D %) $(<) \
575ead1f93eSLiane Praza			$(PKGROOT) > $(@); \
576ead1f93eSLiane Praza	else \
577ead1f93eSLiane Praza		$(CP) $(<) $(@); \
578ead1f93eSLiane Praza	fi
579ead1f93eSLiane Praza
580ead1f93eSLiane Praza#
581ead1f93eSLiane Praza# The full chain implies that there should be a .dep.res suffix rule,
582ead1f93eSLiane Praza# but dependency generation is done on a set of manifests, rather than
583ead1f93eSLiane Praza# on a per-manifest basis.  Instead, see the gendeps rule above.
584ead1f93eSLiane Praza#
585ead1f93eSLiane Praza
586ead1f93eSLiane Praza$(PDIR)/%.pub: $(PDIR)/%.res
587ead1f93eSLiane Praza	$(PKGDEBUG)m=$$(basename $(@:%.pub=%).metadata.*); \
588ead1f93eSLiane Praza	r=$${m#$(@F:%.pub=%.metadata.)+(?).}; \
589ead1f93eSLiane Praza	if [ -s $(<) ]; then \
590ead1f93eSLiane Praza		print "Publishing $(@F:%.pub=%) to $$r repository"; \
591ead1f93eSLiane Praza		pkgsend -s file://$(PKGDEST)/repo.$$r publish \
592ead1f93eSLiane Praza		    -d $(PKGROOT) -d $(TOOLSROOT) -d $(SRC)/pkg/license_files \
593ead1f93eSLiane Praza		    -d $(SRC) --fmri-in-manifest --no-index --no-catalog $(<) \
594ead1f93eSLiane Praza		    > /dev/null; \
595ead1f93eSLiane Praza	fi; \
596ead1f93eSLiane Praza	$(TOUCH) $(@);
597ead1f93eSLiane Praza
598ead1f93eSLiane Praza#
599ead1f93eSLiane Praza# rule to build the synthetic manifests
600ead1f93eSLiane Praza#
601ead1f93eSLiane Praza# This rule necessarily has PKGDEP_TYPE that changes according to
602ead1f93eSLiane Praza# the specific synthetic manifest.  Rather than escape command
603ead1f93eSLiane Praza# dependency checking for the real manifest processing, or failing to
604ead1f93eSLiane Praza# express the (indirect) dependency of synthetic manifests on real
605ead1f93eSLiane Praza# manifests, we simply split this rule out from the one above.
606ead1f93eSLiane Praza#
607ead1f93eSLiane Praza# The implementation notes from the previous rule are applicable
608ead1f93eSLiane Praza# here, too.
609ead1f93eSLiane Praza#
610ead1f93eSLiane Praza$(PROC_SYNTH_PKGS): $(PKGLISTS) $$(@F:%.mog=%.mf)
611ead1f93eSLiane Praza	@print "Processing synthetic manifest $(@F:%.mog=%.mf)"
612ead1f93eSLiane Praza	$(PKGDEBUG)$(RM) $(@) $(PDIR)/$(@F:%.mog=%).metadata.*
613ead1f93eSLiane Praza	$(PKGDEBUG)eval REPO=redist PKGSTAT=current \
614ead1f93eSLiane Praza		`$(PKGMOGRIFY) $(PKGMOG_VERBOSE) -I transforms -I $(PDIR) \
615ead1f93eSLiane Praza		$(PKGMOG_DEFINES:%=-D %) -D PKGDEP_TYPE=$(PKGDEP_TYPE) \
616ead1f93eSLiane Praza		-O $(@) $(@F:%.mog=%.mf) $(PM_TRANSFORMS) synthetic` ; \
617ead1f93eSLiane Praza	if [ -f $(@) ]; then \
618ead1f93eSLiane Praza		$(LN) -s $(@F) \
619ead1f93eSLiane Praza			$(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \
620ead1f93eSLiane Praza	else \
621ead1f93eSLiane Praza		$(TOUCH) $(@); \
622ead1f93eSLiane Praza	fi
623ead1f93eSLiane Praza
624ead1f93eSLiane Praza$(DEP_SYNTH_PKGS): $$(@:%.dep=%.mog)
625ead1f93eSLiane Praza	@print "Skipping dependency generation for $(@F:%.dep=%)"
626ead1f93eSLiane Praza	$(PKGDEBUG)$(CP) $(@:%.dep=%.mog) $(@)
627ead1f93eSLiane Praza
628ead1f93eSLiane Prazaclean:
629ead1f93eSLiane Praza
630ead1f93eSLiane Prazaclobber: clean
631ead1f93eSLiane Praza	$(RM) -r $(CLOBBERFILES)
632ead1f93eSLiane Praza
633ead1f93eSLiane Praza#
634ead1f93eSLiane Praza# This rule assumes that all links in the $PKGSTAT directories
635ead1f93eSLiane Praza# point to valid manifests, and will fail the make run if one
636ead1f93eSLiane Praza# does not contain an fmri.
637ead1f93eSLiane Praza#
638ead1f93eSLiane Praza# We do this in the BEGIN action instead of using pattern matching
639ead1f93eSLiane Praza# because we expect the fmri to be at or near the first line of each input
640ead1f93eSLiane Praza# file, and this way lets us avoid reading the rest of the file after we
641ead1f93eSLiane Praza# find what we need.
642ead1f93eSLiane Praza#
643ead1f93eSLiane Praza# We keep track of a failure to locate an fmri, so we can fail the
644ead1f93eSLiane Praza# make run, but we still attempt to process each package in the
645ead1f93eSLiane Praza# repo/pkgstat-specific subdir, in hopes of maybe giving some
646ead1f93eSLiane Praza# additional useful info.
647ead1f93eSLiane Praza#
648ead1f93eSLiane Praza# The protolist is used for bfu archive creation, which may be invoked
649ead1f93eSLiane Praza# interactively by the user.  Both protolist and PKGLISTS targets
650ead1f93eSLiane Praza# depend on $(PROC_PKGS), but protolist builds them recursively.
651ead1f93eSLiane Praza# To avoid collisions, we insert protolist into the dependency chain
652ead1f93eSLiane Praza# here.  This has two somewhat subtle benefits: it allows bfu archive
653ead1f93eSLiane Praza# creation to work correctly, even when -a was not part of NIGHTLY_OPTIONS,
654ead1f93eSLiane Praza# and it ensures that a protolist file here will always correspond to the
655ead1f93eSLiane Praza# contents of the processed manifests, which can vary depending on build
656ead1f93eSLiane Praza# environment.
657ead1f93eSLiane Praza#
658ead1f93eSLiane Praza$(PKGLISTS): $(PROC_PKGS)
659ead1f93eSLiane Praza	$(PKGDEBUG)sdotr=$(@F:packages.%=%); \
660ead1f93eSLiane Praza	r=$${sdotr%.+(?)}; s=$${sdotr#+(?).}; \
661ead1f93eSLiane Praza	print "Generating $$r $$s package list"; \
662ead1f93eSLiane Praza	$(RM) $(@); $(TOUCH) $(@); \
663ead1f93eSLiane Praza	$(NAWK) 'BEGIN { \
664ead1f93eSLiane Praza		if (ARGC < 2) { \
665ead1f93eSLiane Praza			exit; \
666ead1f93eSLiane Praza		} \
667ead1f93eSLiane Praza		retcode = 0; \
668ead1f93eSLiane Praza		for (i = 1; i < ARGC; i++) { \
669ead1f93eSLiane Praza			do { \
670ead1f93eSLiane Praza				e = getline f < ARGV[i]; \
671ead1f93eSLiane Praza			} while ((e == 1) && (f !~ /name=pkg.fmri/)); \
672ead1f93eSLiane Praza			close(ARGV[i]); \
673ead1f93eSLiane Praza			if (e == 1) { \
674ead1f93eSLiane Praza				l = split(f, a, "="); \
675ead1f93eSLiane Praza				print "depend fmri=" a[l], \
676ead1f93eSLiane Praza					"type=$$(PKGDEP_TYPE)"; \
677ead1f93eSLiane Praza			} else { \
678ead1f93eSLiane Praza				print "no fmri in " ARGV[i] >> "/dev/stderr"; \
679ead1f93eSLiane Praza				retcode = 2; \
680ead1f93eSLiane Praza			} \
681ead1f93eSLiane Praza		} \
682ead1f93eSLiane Praza		exit retcode; \
683ead1f93eSLiane Praza	}' `find $(PDIR) -type l -a \( $(PKGS:%=-name %.metadata.$$s.$$r -o) \
684ead1f93eSLiane Praza		-name NOSUCHFILE \)` >> $(@)
685ead1f93eSLiane Praza
686ead1f93eSLiane Praza#
687ead1f93eSLiane Praza# rules to validate proto area against manifests, check for safe
688ead1f93eSLiane Praza# file permission modes, and generate a faux proto list
689ead1f93eSLiane Praza#
690ead1f93eSLiane Praza# For the check targets, the dependencies on $(PROC_PKGS) is specified
691ead1f93eSLiane Praza# as a subordinate make process in order to suppress output.
692ead1f93eSLiane Praza#
693ead1f93eSLiane Prazamakesilent:
694ead1f93eSLiane Praza	@$(MAKE) -e $(PROC_PKGS) PKGMACH=$(PKGMACH) \
695ead1f93eSLiane Praza		SUPPRESSPKGDEP=$(SUPPRESSPKGDEP) > /dev/null
696ead1f93eSLiane Praza
697ead1f93eSLiane Prazaprotocmp: makesilent
698ead1f93eSLiane Praza	@validate_pkg -a $(PKGMACH) -v \
699ead1f93eSLiane Praza		$(EXCEPTIONS:%=-e $(CODEMGR_WS)/exception_lists/%) \
700ead1f93eSLiane Praza		-m $(PDIR) -p $(PKGROOT) -p $(TOOLSROOT)
701ead1f93eSLiane Praza
702ead1f93eSLiane Prazapmodes: makesilent
703ead1f93eSLiane Praza	@validate_pkg -a $(PKGMACH) -M -m $(PDIR) \
704ead1f93eSLiane Praza		-e $(CODEMGR_WS)/exception_lists/pmodes
705ead1f93eSLiane Praza
706ead1f93eSLiane Prazacheck: protocmp pmodes
707ead1f93eSLiane Praza
708ead1f93eSLiane Prazaprotolist: proto_list_$(PKGMACH)
709ead1f93eSLiane Praza
710ead1f93eSLiane Prazaproto_list_$(PKGMACH): $(PROC_PKGS)
711ead1f93eSLiane Praza	@validate_pkg -a $(PKGMACH) -L -m $(PDIR) > $(@)
712ead1f93eSLiane Praza
713ead1f93eSLiane Praza$(PROC_PKGS): $(PDIR)
714ead1f93eSLiane Praza
715ead1f93eSLiane Praza#
716ead1f93eSLiane Praza# This is a convenience target to allow package names to function as
717ead1f93eSLiane Praza# build targets.  Generally, using it is only useful when iterating on
718ead1f93eSLiane Praza# development of a manifest.
719ead1f93eSLiane Praza#
720ead1f93eSLiane Praza# When processing a manifest, use the basename (without extension) of
721ead1f93eSLiane Praza# the package.  When publishing, use the basename with a ".pub"
722ead1f93eSLiane Praza# extension.
723ead1f93eSLiane Praza#
724ead1f93eSLiane Praza# Other than during manifest development, the preferred usage is to
725ead1f93eSLiane Praza# avoid these targets and override PKGS on the make command line and
726ead1f93eSLiane Praza# use the provided all and install targets.
727ead1f93eSLiane Praza#
728ead1f93eSLiane Praza$(PKGS) $(SYNTH_PKGS): $(PDIR)/$$(@:%=%.mog)
729ead1f93eSLiane Praza
730ead1f93eSLiane Praza$(PKGS:%=%.pub) $(SYNTH_PKGS:%=%.pub): $(PDIR)/$$(@)
731ead1f93eSLiane Praza
732ead1f93eSLiane Praza#
733ead1f93eSLiane Praza# This is a convenience target to resolve dependencies without publishing
734ead1f93eSLiane Praza# packages.
735ead1f93eSLiane Praza#
736ead1f93eSLiane Prazagendeps: $(PDIR)/gendeps
737ead1f93eSLiane Praza
738ead1f93eSLiane Praza#
739ead1f93eSLiane Praza# These are convenience targets for cross-platform packaging.  If you
740ead1f93eSLiane Praza# want to build any of "the normal" targets for a different
741ead1f93eSLiane Praza# architecture, simply use "arch/target" as your build target.
742ead1f93eSLiane Praza#
743ead1f93eSLiane Praza# Since the most common use case for this is "install," the architecture
744ead1f93eSLiane Praza# specific install targets have been further abbreviated to elide "/install."
745ead1f93eSLiane Praza#
746ead1f93eSLiane Prazai386/% sparc/%:
747ead1f93eSLiane Praza	$(MAKE) -e $(@F) PKGMACH=$(@D) SUPPRESSPKGDEP=$(SUPPRESSPKGDEP)
748ead1f93eSLiane Praza
749ead1f93eSLiane Prazai386 sparc: $$(@)/install
750ead1f93eSLiane Praza
751ead1f93eSLiane PrazaFRC:
752ead1f93eSLiane Praza
753ead1f93eSLiane Praza# EXPORT DELETE START
754ead1f93eSLiane PrazaXMOD_PKGS= \
755ead1f93eSLiane Praza	BRCMbnx \
756ead1f93eSLiane Praza	BRCMbnxe \
757ead1f93eSLiane Praza	SUNWadpu320 \
758ead1f93eSLiane Praza	SUNWcryptoint \
759ead1f93eSLiane Praza	SUNWibsdpib \
760ead1f93eSLiane Praza	SUNWkdc \
761ead1f93eSLiane Praza	SUNWlsimega \
762ead1f93eSLiane Praza	SUNWspwr \
763ead1f93eSLiane Praza	SUNWsvvs \
764ead1f93eSLiane Praza	SUNWwbint \
765ead1f93eSLiane Praza	SUNWwbsup
766ead1f93eSLiane Praza
767ead1f93eSLiane PrazaEXPORT_SRC: CRYPT_SRC
768ead1f93eSLiane Praza	$(RM) $(XMOD_PKGS:%=manifests/%.mf)
769ead1f93eSLiane Praza	$(RM) Makefile+
770ead1f93eSLiane Praza	$(SED) -e "/^# EXPORT DELETE START/,/^# EXPORT DELETE END/d" \
771ead1f93eSLiane Praza		< Makefile > Makefile+
772ead1f93eSLiane Praza	$(MV) -f Makefile+ Makefile
773ead1f93eSLiane Praza	$(CHMOD) 444 Makefile
774ead1f93eSLiane Praza
775ead1f93eSLiane PrazaCRYPT_SRC:
776ead1f93eSLiane Praza	$(RM) manifests/SUNWcryptoint.mf+
777ead1f93eSLiane Praza	$(SED) -e "/^# CRYPT DELETE START/,/^# CRYPT DELETE END/d" \
778ead1f93eSLiane Praza		< manifests/SUNWcryptoint.mf > manifests/SUNWcryptoint.mf+
779ead1f93eSLiane Praza	$(MV) manifests/SUNWcryptoint.mf+ manifests/SUNWcryptoint.mf
780ead1f93eSLiane Praza	$(CHMOD) 444 manifests/SUNWcryptoint.mf
781ead1f93eSLiane Praza
782ead1f93eSLiane Praza# EXPORT DELETE END
783