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