xref: /illumos-gate/usr/src/pkg/Makefile (revision 445784c0)
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#
236f269e97SMark J. Nelson# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
241f2ca518SDan McDonald# Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
257b07063dSIgor Kozhukhov# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
260ae9a84fSAndrew Stormont# Copyright 2016 RackTop Systems.
2745ede40bSAndy Fiddaman# Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
2851396a8eSPeter Tribble# Copyright 2020 Peter Tribble
29ead1f93eSLiane Praza#
30ead1f93eSLiane Praza
31ead1f93eSLiane Prazainclude $(SRC)/Makefile.master
32ead1f93eSLiane Praza
33ead1f93eSLiane Praza#
34ead1f93eSLiane Praza# Make sure we're getting a consistent execution environment for the
35ead1f93eSLiane Praza# embedded scripts.
36ead1f93eSLiane Praza#
37ead1f93eSLiane PrazaSHELL= /usr/bin/ksh93
38ead1f93eSLiane Praza
39ead1f93eSLiane Praza#
40ead1f93eSLiane Praza# To suppress package dependency generation on any system, regardless
41ead1f93eSLiane Praza# of how it was installed, set SUPPRESSPKGDEP=true in the build
42ead1f93eSLiane Praza# environment.
43ead1f93eSLiane Praza#
44ae39239eSMark J. NelsonSUPPRESSPKGDEP= false
45ead1f93eSLiane Praza
46ead1f93eSLiane Praza#
47ead1f93eSLiane Praza# Comment this line out or set "PKGDEBUG=" in your build environment
48ead1f93eSLiane Praza# to get more verbose output from the make processes in usr/src/pkg
49ead1f93eSLiane Praza#
50ead1f93eSLiane PrazaPKGDEBUG= @
51ead1f93eSLiane Praza
52ead1f93eSLiane Praza#
53ead1f93eSLiane Praza# Cross platform packaging notes
54ead1f93eSLiane Praza#
55ead1f93eSLiane Praza# By default, we package the proto area from the same architecture as
56ead1f93eSLiane Praza# the packaging build.  In other words, if you're running nightly or
57ead1f93eSLiane Praza# bldenv on an x86 platform, it will take objects from the x86 proto
58ead1f93eSLiane Praza# area and use them to create x86 repositories.
59ead1f93eSLiane Praza#
60ead1f93eSLiane Praza# If you want to create repositories for an architecture that's
61ead1f93eSLiane Praza# different from $(uname -p), you do so by setting PKGMACH in your
62ead1f93eSLiane Praza# build environment.
63ead1f93eSLiane Praza#
64ead1f93eSLiane Praza# For this to work correctly, the following must all happen:
65ead1f93eSLiane Praza#
66ead1f93eSLiane Praza#   1. You need the desired proto area, which you can get either by
67ead1f93eSLiane Praza#      doing a gatekeeper-style build with the -U option to
68ead1f93eSLiane Praza#      nightly(1), or by using rsync.  If you don't do this, you will
69ead1f93eSLiane Praza#      get packaging failures building all packages, because pkgsend
70ead1f93eSLiane Praza#      is unable to find the required binaries.
71ead1f93eSLiane Praza#   2. You need the desired tools proto area, which you can get in the
72ead1f93eSLiane Praza#      same ways as the normal proto area.  If you don't do this, you
735084e753SMark J. Nelson#      will get packaging failures building onbld, because pkgsend is
74ead1f93eSLiane Praza#      unable to find the tools binaries.
755084e753SMark J. Nelson#   3. The remainder of this Makefile should never refer directly to
76ead1f93eSLiane Praza#      $(MACH).  Instead, $(PKGMACH) should be used whenever an
77ead1f93eSLiane Praza#      architecture-specific path or token is needed.  If this is done
78ead1f93eSLiane Praza#      incorrectly, then packaging will fail, and you will see the
79ead1f93eSLiane Praza#      value of $(uname -p) instead of the value of $(PKGMACH) in the
80ead1f93eSLiane Praza#      commands that fail.
815084e753SMark J. Nelson#   4. Each time a rule in this Makefile invokes $(MAKE), it should
82ead1f93eSLiane Praza#      pass PKGMACH=$(PKGMACH) explicitly on the command line.  If
83ead1f93eSLiane Praza#      this is done incorrectly, then packaging will fail, and you
84ead1f93eSLiane Praza#      will see the value of $(uname -p) instead of the value of
85ead1f93eSLiane Praza#      $(PKGMACH) in the commands that fail.
86ead1f93eSLiane Praza#
87ead1f93eSLiane Praza# Refer also to the convenience targets defined later in this
88ead1f93eSLiane Praza# Makefile.
89ead1f93eSLiane Praza#
90ead1f93eSLiane PrazaPKGMACH=	$(MACH)
91ead1f93eSLiane Praza
92ead1f93eSLiane Praza#
93ead1f93eSLiane Praza# ROOT, TOOLS_PROTO, and PKGARCHIVE should be set by nightly or
94ead1f93eSLiane Praza# bldenv.  These macros translate them into terms of $PKGMACH, instead
95ead1f93eSLiane Praza# of $ARCH.
96ead1f93eSLiane Praza#
97ead1f93eSLiane PrazaPKGROOT.cmd=	print $(ROOT) | sed -e s:/root_$(MACH):/root_$(PKGMACH):
98ead1f93eSLiane PrazaPKGROOT=	$(PKGROOT.cmd:sh)
99ead1f93eSLiane PrazaTOOLSROOT.cmd=	print $(TOOLS_PROTO) | sed -e s:/root_$(MACH):/root_$(PKGMACH):
100ead1f93eSLiane PrazaTOOLSROOT=	$(TOOLSROOT.cmd:sh)
101ead1f93eSLiane PrazaPKGDEST.cmd=	print $(PKGARCHIVE) | sed -e s:/$(MACH)/:/$(PKGMACH)/:
102ead1f93eSLiane PrazaPKGDEST=	$(PKGDEST.cmd:sh)
103ead1f93eSLiane Praza
104ead1f93eSLiane PrazaEXCEPTIONS= packaging
105ead1f93eSLiane Praza
106ead1f93eSLiane PrazaPKGMOGRIFY= pkgmogrify
107ead1f93eSLiane Praza
108ead1f93eSLiane Praza#
109ead1f93eSLiane Praza# Always build the redistributable repository, but only build the
110ead1f93eSLiane Praza# nonredistributable bits if we have access to closed source.
111ead1f93eSLiane Praza#
112ead1f93eSLiane Praza# Some objects that result from the closed build are still
113ead1f93eSLiane Praza# redistributable, and should be packaged as part of an open-only
114ead1f93eSLiane Praza# build.  Access to those objects is provided via the closed-bins
115ead1f93eSLiane Praza# tarball.  See usr/src/tools/scripts/bindrop.sh for details.
116ead1f93eSLiane Praza#
117ead1f93eSLiane PrazaREPOS= redist
118ead1f93eSLiane Praza
119ead1f93eSLiane Praza#
120ead1f93eSLiane Praza# The packages directory will contain the processed manifests as
121ead1f93eSLiane Praza# direct build targets and subdirectories for package metadata extracted
122ead1f93eSLiane Praza# incidentally during manifest processing.
123ead1f93eSLiane Praza#
124ead1f93eSLiane Praza# Nothing underneath $(PDIR) should ever be managed by SCM.
125ead1f93eSLiane Praza#
126ead1f93eSLiane PrazaPDIR= packages.$(PKGMACH)
127ead1f93eSLiane Praza
128ead1f93eSLiane Praza#
129ead1f93eSLiane Praza# The tools proto must be specified for dependency generation.
130ead1f93eSLiane Praza# Publication from the tools proto area is managed in the
131ead1f93eSLiane Praza# publication rule.
132ead1f93eSLiane Praza#
133d34af1a4SMark J. Nelson$(PDIR)/developer-build-onbld.dep:= PKGROOT= $(TOOLSROOT)
134ead1f93eSLiane Praza
135ead1f93eSLiane PrazaPKGPUBLISHER= $(PKGPUBLISHER_REDIST)
136ead1f93eSLiane Praza
137ead1f93eSLiane Praza#
138ead1f93eSLiane Praza# To get these defaults, manifests should simply refer to $(PKGVERS).
139ead1f93eSLiane Praza#
140ead1f93eSLiane PrazaPKGVERS_COMPONENT= 0.$(RELEASE)
141ead1f93eSLiane PrazaPKGVERS_BUILTON= $(RELEASE)
14241c859f9SRichard LowePKGVERS_BRANCH= 999999.1
143ead1f93eSLiane PrazaPKGVERS= $(PKGVERS_COMPONENT),$(PKGVERS_BUILTON)-$(PKGVERS_BRANCH)
144ead1f93eSLiane Praza
145ead1f93eSLiane Praza#
146ead1f93eSLiane Praza# The ARCH32 and ARCH64 macros are used in the manifests to express
147ead1f93eSLiane Praza# architecture-specific subdirectories in the installation paths
148ead1f93eSLiane Praza# for isaexec'd commands.
149ead1f93eSLiane Praza#
150ead1f93eSLiane Praza# We can't simply use $(MACH32) and $(MACH64) here, because they're
151ead1f93eSLiane Praza# only defined for the build architecture.  To do cross-platform
152ead1f93eSLiane Praza# packaging, we need both values.
153ead1f93eSLiane Praza#
154ead1f93eSLiane Prazai386_ARCH32= i86
155ead1f93eSLiane Prazai386_ARCH64= amd64
156ead1f93eSLiane Praza
157ead1f93eSLiane Praza#
158ead1f93eSLiane Praza# macros and transforms needed by pkgmogrify
159ead1f93eSLiane Praza#
160ead1f93eSLiane Praza# If you append to this list using target-specific assignments (:=),
161ead1f93eSLiane Praza# be very careful that the targets are of the form $(PDIR)/pkgname.  If
162ead1f93eSLiane Praza# you use a higher level target, or a package list, you'll trigger a
163ead1f93eSLiane Praza# complete reprocessing of all manifests because they'll fail command
164ead1f93eSLiane Praza# dependency checking.
165ead1f93eSLiane Praza#
166c10c16deSRichard LowePM_TRANSFORMS= common_actions publish restart_fmri facets defaults \
167c10c16deSRichard Lowe	extract_metadata
168069e6b7eSAndy FiddamanPM_FINAL_TRANSFORMS= strip_dependinfo
169c10c16deSRichard LowePM_INC= transforms manifests
170ead1f93eSLiane Praza
17167048e0fSYuri PankovJAVA_8_ONLY=
17251396a8eSPeter TribbleJAVA_11_ONLY=
17351396a8eSPeter Tribble$(BLD_JAVA_11)JAVA_8_ONLY=$(POUND_SIGN)
17451396a8eSPeter Tribble$(JAVA_8_ONLY)JAVA_11_ONLY=$(POUND_SIGN)
175cb159270SAlexander Pyhalov
176ead1f93eSLiane PrazaPKGMOG_DEFINES= \
177ead1f93eSLiane Praza	i386_ONLY=$(POUND_SIGN) \
178ead1f93eSLiane Praza	$(PKGMACH)_ONLY= \
179ead1f93eSLiane Praza	ARCH=$(PKGMACH) \
180ead1f93eSLiane Praza	ARCH32=$($(PKGMACH)_ARCH32) \
181ead1f93eSLiane Praza	ARCH64=$($(PKGMACH)_ARCH64) \
182ead1f93eSLiane Praza	PKGVERS_COMPONENT=$(PKGVERS_COMPONENT) \
183ead1f93eSLiane Praza	PKGVERS_BUILTON=$(PKGVERS_BUILTON) \
184ead1f93eSLiane Praza	PKGVERS_BRANCH=$(PKGVERS_BRANCH) \
18533392354SAlexander Pyhalov	PKGVERS=$(PKGVERS) \
1861f2ca518SDan McDonald	PERL_ARCH=$(PERL_ARCH) \
1870ae9a84fSAndrew Stormont	PERL_ARCH64=$(PERL_ARCH64) \
18833392354SAlexander Pyhalov	PERL_VERSION=$(PERL_VERSION) \
1899f923083SAlexander Pyhalov	PERL_PKGVERS=$(PERL_PKGVERS) \
1900ae9a84fSAndrew Stormont	BUILDPERL32=$(BUILDPERL32) \
1910ae9a84fSAndrew Stormont	BUILDPERL64=$(BUILDPERL64) \
192e8921a52SAndy Fiddaman	PYTHON3_VERSION=$(PYTHON3_VERSION) \
19345ede40bSAndy Fiddaman	PYTHON3b_VERSION=$(PYTHON3b_VERSION) \
194e8921a52SAndy Fiddaman	PYTHON3_PKGVERS=$(PYTHON3_PKGVERS) \
19545ede40bSAndy Fiddaman	PYTHON3b_PKGVERS=$(PYTHON3b_PKGVERS) \
19645ede40bSAndy Fiddaman	python3b_ONLY=$(BUILDPY3b) \
19751396a8eSPeter Tribble	JAVA_11_ONLY=$(JAVA_11_ONLY) \
19851396a8eSPeter Tribble	JAVA_8_ONLY=$(JAVA_8_ONLY)
199ead1f93eSLiane Praza
200ead1f93eSLiane PrazaPKGDEP_TOKENS_i386= \
201ead1f93eSLiane Praza	'PLATFORM=i86hvm' \
202ead1f93eSLiane Praza	'PLATFORM=i86pc' \
203ead1f93eSLiane Praza	'PLATFORM=i86xpv' \
204ead1f93eSLiane Praza	'ISALIST=amd64' \
205ead1f93eSLiane Praza	'ISALIST=i386'
206ead1f93eSLiane PrazaPKGDEP_TOKENS= $(PKGDEP_TOKENS_$(PKGMACH))
207ead1f93eSLiane Praza
208ead1f93eSLiane Praza#
209ead1f93eSLiane Praza# The package lists are generated with $(PKGDEP_TYPE) as their
210ead1f93eSLiane Praza# dependency types, so that they can be included by either an
211ead1f93eSLiane Praza# incorporation or a group package.
212ead1f93eSLiane Praza#
21377c29b8eSRichard Lowe$(PDIR)/osnet-redist.mog := PKGDEP_TYPE= require
214ead1f93eSLiane Praza$(PDIR)/osnet-incorporation.mog:= PKGDEP_TYPE= incorporate
215ead1f93eSLiane Praza
216ead1f93eSLiane PrazaPKGDEP_INCORP= \
217ead1f93eSLiane Praza	depend fmri=consolidation/osnet/osnet-incorporation type=require
218ead1f93eSLiane Praza
219ead1f93eSLiane Praza#
220ead1f93eSLiane Praza# All packaging build products should go into $(PDIR), so they don't
221ead1f93eSLiane Praza# need to be included separately in CLOBBERFILES.
222ead1f93eSLiane Praza#
223b6805bf7SGordon RossCLOBBERFILES= $(PDIR) proto_list_$(PKGMACH) install-$(PKGMACH).out \
224b6805bf7SGordon Ross	license-list
225ead1f93eSLiane Praza
226ead1f93eSLiane Praza#
227ead1f93eSLiane Praza# By default, PKGS will list all manifests.  To build and/or publish a
228ead1f93eSLiane Praza# subset of packages, override this on the command line or in the
229ead1f93eSLiane Praza# build environment and then reference (implicitly or explicitly) the all
230e9542cf7SAlexander Pyhalov# or install targets.
231e9542cf7SAlexander Pyhalov#
232e8921a52SAndy Fiddaman# We want some manifests to optionally build based on environment options, so
233e8921a52SAndy Fiddaman# those are excluded when generating the list of manifests and added back in if
234e8921a52SAndy Fiddaman# necessary. We also want a relatively easy way to add files to the list of
235e8921a52SAndy Fiddaman# manifests given special treatment. Add any other special ones to the
236e8921a52SAndy Fiddaman# SPECIAL_MANIFESTS variable. It can contain wildcards in regexp form, i.e.
237e8921a52SAndy Fiddaman# SUNW.* as one useful example.
238e8921a52SAndy Fiddaman#
23970143b9fSRichard LoweSPECIAL_MANIFESTS = system-library-python-libbe-3b\.p5m \
24070143b9fSRichard Lowe    system-library-python-solaris-3b\.p5m \
24170143b9fSRichard Lowe    system-library-python-zfs-3b\.p5m
24225b05a3eSAndy FiddamanLIST_MANIFESTS_CMD = (cd manifests ; /usr/bin/ls -1 *.p5m |\
243e8921a52SAndy Fiddaman	$(SED) $(SPECIAL_MANIFESTS:%=-e '/^%$$/d') )
244e8921a52SAndy FiddamanMANIFESTS = $(LIST_MANIFESTS_CMD:sh)
245e8921a52SAndy Fiddaman
24670143b9fSRichard Lowe# Conditionally add back the py3b manifests if requested
24770143b9fSRichard Lowe$(BUILDPY3b)MANIFESTS += \
24845ede40bSAndy Fiddaman	system-library-python-libbe-3b.p5m \
24945ede40bSAndy Fiddaman	system-library-python-solaris-3b.p5m \
25045ede40bSAndy Fiddaman	system-library-python-zfs-3b.p5m
251e8921a52SAndy Fiddaman
25225b05a3eSAndy FiddamanPKGS= $(MANIFESTS:%.p5m=%)
253ead1f93eSLiane PrazaDEP_PKGS= $(PKGS:%=$(PDIR)/%.dep)
254ead1f93eSLiane PrazaPROC_PKGS= $(PKGS:%=$(PDIR)/%.mog)
255069e6b7eSAndy FiddamanFIN_PKGS= $(PKGS:%=$(PDIR)/%.fin)
256ead1f93eSLiane Praza
257ead1f93eSLiane Praza#
258ead1f93eSLiane Praza# Track the synthetic manifests separately so we can properly express
259ead1f93eSLiane Praza# build rules and dependencies.  The synthetic and real packages use
260ead1f93eSLiane Praza# different sets of transforms and macros for pkgmogrify.
261ead1f93eSLiane Praza#
262ead1f93eSLiane PrazaSYNTH_PKGS= osnet-incorporation osnet-redist
263ead1f93eSLiane PrazaDEP_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.dep)
264ead1f93eSLiane PrazaPROC_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.mog)
265ead1f93eSLiane Praza
266ac823a0fSJon Tibble#
267ac823a0fSJon Tibble# Root of pkg image to use for dependency resolution
268ac823a0fSJon Tibble# Normally / on the machine used to build the binaries
269ac823a0fSJon Tibble#
270ac823a0fSJon TibblePKGDEP_RESOLVE_IMAGE = /
271ac823a0fSJon Tibble
272ead1f93eSLiane Praza#
273ead1f93eSLiane Praza# For each package, we determine the target repository based on
274ead1f93eSLiane Praza# manifest-embedded metadata.  Because we make that determination on
275ead1f93eSLiane Praza# the fly, the publication target cannot be expressed as a
276ead1f93eSLiane Praza# subdirectory inside the unknown-by-the-makefile target repository.
277ead1f93eSLiane Praza#
278ead1f93eSLiane Praza# In order to limit the target set to real files in known locations,
279ead1f93eSLiane Praza# we use a ".pub" file in $(PDIR) for each processed manifest, regardless
280ead1f93eSLiane Praza# of content or target repository.
281ead1f93eSLiane Praza#
282ead1f93eSLiane PrazaPUB_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.pub) $(PKGS:%=$(PDIR)/%.pub)
283ead1f93eSLiane Praza
284ead1f93eSLiane Praza#
285ead1f93eSLiane Praza# Any given repository- and status-specific package list may be empty,
286ead1f93eSLiane Praza# but we can only determine that dynamically, so we always generate all
287ead1f93eSLiane Praza# lists for each repository we're building.
288ead1f93eSLiane Praza#
289ead1f93eSLiane Praza# The meanings of each package status are as follows:
290ead1f93eSLiane Praza#
291e8921a52SAndy Fiddaman#	PKGSTAT		meaning
292e8921a52SAndy Fiddaman#	----------	----------------------------------------------------
293e8921a52SAndy Fiddaman#	noincorp	Do not include in incorporation or group package
294ead1f93eSLiane Praza#	obsolete	Include in incorporation, but not group package
2950ea64585SLiane Praza#	renamed		Include in incorporation, but not group package
296ead1f93eSLiane Praza#	current		Include in incorporation and group package
297ead1f93eSLiane Praza#
298ead1f93eSLiane Praza# Since the semantics of the "noincorp" package status dictate that
299ead1f93eSLiane Praza# such packages are not included in the incorporation or group packages,
300ead1f93eSLiane Praza# there is no need to build noincorp package lists.
301ead1f93eSLiane Praza#
302ead1f93eSLiane PrazaPKGLISTS= \
303ead1f93eSLiane Praza	$(REPOS:%=$(PDIR)/packages.%.current) \
304ead1f93eSLiane Praza	$(REPOS:%=$(PDIR)/packages.%.renamed) \
305ead1f93eSLiane Praza	$(REPOS:%=$(PDIR)/packages.%.obsolete)
306ead1f93eSLiane Praza
307ead1f93eSLiane Praza.KEEP_STATE:
308ead1f93eSLiane Praza
309ead1f93eSLiane Praza.PARALLEL: $(PKGS) $(PROC_PKGS) $(DEP_PKGS) \
310069e6b7eSAndy Fiddaman	$(PROC_SYNTH_PKGS) $(DEP_SYNTH_PKGS) $(FIN_PKGS) $(PUB_PKGS)
311ead1f93eSLiane Praza
312ead1f93eSLiane Praza#
313ead1f93eSLiane Praza# For a single manifest, the dependency chain looks like this:
314ead1f93eSLiane Praza#
31525b05a3eSAndy Fiddaman#	raw manifest (mypkg.p5m)
316ead1f93eSLiane Praza#		|
317ead1f93eSLiane Praza#		| use pkgmogrify to process raw manifest
318ead1f93eSLiane Praza#		|
319ead1f93eSLiane Praza#	processed manifest (mypkg.mog)
320ead1f93eSLiane Praza#		|
321ead1f93eSLiane Praza#	   *    | use pkgdepend generate to generate dependencies
322ead1f93eSLiane Praza#		|
323ead1f93eSLiane Praza#	manifest with TBD dependencies (mypkg.dep)
324ead1f93eSLiane Praza#		|
325ead1f93eSLiane Praza#	   %    | use pkgdepend resolve to resolve dependencies
326ead1f93eSLiane Praza#		|
327ead1f93eSLiane Praza#	manifest with dependencies resolved (mypkg.res)
328ead1f93eSLiane Praza#		|
329069e6b7eSAndy Fiddaman#		| use pkgmogrify to apply final cleanups
330069e6b7eSAndy Fiddaman#		|
331069e6b7eSAndy Fiddaman#	cleaned up manifest (mypkg.fin)
332069e6b7eSAndy Fiddaman#		|
333ead1f93eSLiane Praza#		| use pkgsend to publish the package
334ead1f93eSLiane Praza#		|
335ead1f93eSLiane Praza#	placeholder to indicate successful publication (mypkg.pub)
336e8921a52SAndy Fiddaman#
337ead1f93eSLiane Praza# * This may be suppressed via SUPPRESSPKGDEP.  The resulting
338ead1f93eSLiane Praza#   packages will install correctly, but care must be taken to
339ead1f93eSLiane Praza#   install all dependencies, because pkg will not have the input
340ead1f93eSLiane Praza#   it needs to determine this automatically.
341ead1f93eSLiane Praza#
342ead1f93eSLiane Praza# % This is included in this diagram to make the picture complete, but
343ead1f93eSLiane Praza#   this is a point of synchronization in the build process.
344ead1f93eSLiane Praza#   Dependency resolution is actually done once on the entire set of
345ead1f93eSLiane Praza#   manifests, not on a per-package basis.
346ead1f93eSLiane Praza#
347ead1f93eSLiane Praza# The full dependency chain for generating everything that needs to be
348ead1f93eSLiane Praza# published, without actually publishing it, looks like this:
349ead1f93eSLiane Praza#
350ead1f93eSLiane Praza#	processed synthetic packages
351ead1f93eSLiane Praza#		|		|
352ead1f93eSLiane Praza#       package lists	    synthetic package manifests
353ead1f93eSLiane Praza#		|
354ead1f93eSLiane Praza#	processed real packages
355ead1f93eSLiane Praza#	    |		|
356ead1f93eSLiane Praza#	package dir	real package manifests
357ead1f93eSLiane Praza#
358ead1f93eSLiane Praza# Here, each item is a set of real or synthetic packages.  For this
359ead1f93eSLiane Praza# portion of the build, no reference is made to the proto area.  It is
360ead1f93eSLiane Praza# therefore suitable for the "all" target, as opposed to "install."
361ead1f93eSLiane Praza#
362ead1f93eSLiane Praza# Since each of these steps is expressed explicitly, "all" need only
363ead1f93eSLiane Praza# depend on the head of the chain.
364ead1f93eSLiane Praza#
365ead1f93eSLiane Praza# From the end of manifest processing, the publication dependency
366ead1f93eSLiane Praza# chain looks like this:
367ead1f93eSLiane Praza#
368ead1f93eSLiane Praza#		repository metadata (catalogs and search indices)
369ead1f93eSLiane Praza#			|
37007b48dbeSYuri Pankov#			| pkgrepo refresh
371ead1f93eSLiane Praza#			|
372ead1f93eSLiane Praza#		published packages
373ead1f93eSLiane Praza#		 |		|
374ead1f93eSLiane Praza#		 |		| pkgsend publish
375ead1f93eSLiane Praza#		 |		|
376069e6b7eSAndy Fiddaman#	  repositories	    final manifests
377ead1f93eSLiane Praza#		 |			|
378069e6b7eSAndy Fiddaman# pkgsend	 |			| pkgmogrify final
379e8921a52SAndy Fiddaman# create-repository			|
380069e6b7eSAndy Fiddaman#		 |		resolved dependencies
381ead1f93eSLiane Praza#	 repo directories		|
382069e6b7eSAndy Fiddaman#					| pkgdepend resolve
383069e6b7eSAndy Fiddaman#					|
384069e6b7eSAndy Fiddaman#				    generated dependencies
385069e6b7eSAndy Fiddaman#					|
386ead1f93eSLiane Praza#					| pkgdepend
387ead1f93eSLiane Praza#					|
388069e6b7eSAndy Fiddaman#                                    processed manifests
3895084e753SMark J. Nelson
390e3c7c8f8SMark J. NelsonALL_TARGETS= $(PROC_SYNTH_PKGS) proto_list_$(PKGMACH)
391e3c7c8f8SMark J. Nelson
392e3c7c8f8SMark J. Nelsonall: $(ALL_TARGETS)
393ead1f93eSLiane Praza
394ead1f93eSLiane Praza#
395ead1f93eSLiane Praza# This will build the directory to contain the processed manifests
396ead1f93eSLiane Praza# and the metadata symlinks.
397ead1f93eSLiane Praza#
398ead1f93eSLiane Praza$(PDIR):
399ead1f93eSLiane Praza	@print "Creating $(@)"
400ead1f93eSLiane Praza	$(PKGDEBUG)$(INS.dir)
401ead1f93eSLiane Praza
402ead1f93eSLiane Praza#
403ead1f93eSLiane Praza# This rule resolves dependencies across all published manifests.
404ead1f93eSLiane Praza#
405ead1f93eSLiane Praza$(PDIR)/gendeps: $(DEP_SYNTH_PKGS) $(DEP_PKGS)
406069e6b7eSAndy Fiddaman	$(PKGDEBUG)if [ "$(SUPPRESSPKGDEP)" = "true" ]; then \
407ead1f93eSLiane Praza		print "Suppressing dependency resolution"; \
408ead1f93eSLiane Praza		for p in $(DEP_PKGS:%.dep=%); do \
409ead1f93eSLiane Praza			$(CP) $$p.dep $$p.res; \
410ead1f93eSLiane Praza		done; \
411ead1f93eSLiane Praza	else \
412ead1f93eSLiane Praza		print "Resolving dependencies"; \
413ac823a0fSJon Tibble		pkgdepend -R $(PKGDEP_RESOLVE_IMAGE) resolve \
414ac823a0fSJon Tibble		    -m $(DEP_SYNTH_PKGS) $(DEP_PKGS); \
415a01be845SMark J. Nelson		for p in $(DEP_SYNTH_PKGS:%.dep=%) $(DEP_PKGS:%.dep=%); do \
416d34af1a4SMark J. Nelson			if [ "$$(print $$p.metadata.*)" = \
417d34af1a4SMark J. Nelson			     "$$(print $$p.metadata.noincorp.*)" ]; \
418d34af1a4SMark J. Nelson			then \
419d34af1a4SMark J. Nelson				print "Removing dependency versions from $$p"; \
420d34af1a4SMark J. Nelson				$(PKGMOGRIFY) $(PKGMOG_VERBOSE) \
421d34af1a4SMark J. Nelson				    -O $$p.res -I transforms \
422d34af1a4SMark J. Nelson				    strip_versions $$p.dep.res; \
423d34af1a4SMark J. Nelson				$(RM) $$p.dep.res; \
424d34af1a4SMark J. Nelson			else \
425d34af1a4SMark J. Nelson				$(MV) $$p.dep.res $$p.res; \
426d34af1a4SMark J. Nelson			fi; \
427ead1f93eSLiane Praza		done; \
428ead1f93eSLiane Praza	fi
429ead1f93eSLiane Praza	$(PKGDEBUG)$(TOUCH) $(@)
430ead1f93eSLiane Praza
431e3c7c8f8SMark J. Nelsoninstall: $(ALL_TARGETS) repository-metadata
432ead1f93eSLiane Praza
433ead1f93eSLiane Prazarepository-metadata: publish_pkgs
434ead1f93eSLiane Praza	$(PKGDEBUG)for r in $(REPOS); do \
43507b48dbeSYuri Pankov		pkgrepo refresh -s $(PKGDEST)/repo.$$r; \
436ead1f93eSLiane Praza	done
437ead1f93eSLiane Praza
438ead1f93eSLiane Praza#
439ead1f93eSLiane Praza# Since we create zero-length processed manifests for a graceful abort
440ead1f93eSLiane Praza# from pkgmogrify, we need to detect that here and make no effort to
441ead1f93eSLiane Praza# publish the package.
442ead1f93eSLiane Praza#
443ead1f93eSLiane Praza# For all other packages, we publish them regardless of status.  We
444ead1f93eSLiane Praza# derive the target repository as a component of the metadata-derived
445ead1f93eSLiane Praza# symlink for each package.
446ead1f93eSLiane Praza#
447ead1f93eSLiane Prazapublish_pkgs: $(REPOS:%=$(PKGDEST)/repo.%) $(PDIR)/gendeps .WAIT $(PUB_PKGS)
448ead1f93eSLiane Praza
4495084e753SMark J. Nelson#
4505084e753SMark J. Nelson# Before publishing, we want to pull the license files from $CODEMGR_WS
4515084e753SMark J. Nelson# into the proto area.  This allows us to NOT pass $SRC (or
4525084e753SMark J. Nelson# $CODEMGR_WS) as a basedir for publication.
4535084e753SMark J. Nelson#
4545084e753SMark J. Nelson$(PUB_PKGS): stage-licenses
455ead1f93eSLiane Praza
456ead1f93eSLiane Praza#
457ead1f93eSLiane Praza# Initialize the empty on-disk repositories
458ead1f93eSLiane Praza#
459ead1f93eSLiane Praza$(REPOS:%=$(PKGDEST)/repo.%):
460ead1f93eSLiane Praza	@print "Initializing $(@F)"
461ead1f93eSLiane Praza	$(PKGDEBUG)$(INS.dir)
462ead1f93eSLiane Praza	$(PKGDEBUG)pkgsend -s file://$(@) create-repository \
463ead1f93eSLiane Praza		--set-property publisher.prefix=$(PKGPUBLISHER)
464ead1f93eSLiane Praza
465ead1f93eSLiane Praza#
466ead1f93eSLiane Praza# rule to process real manifests
467ead1f93eSLiane Praza#
468ead1f93eSLiane Praza# To allow redistributability and package status to change, we must
469ead1f93eSLiane Praza# remove not only the actual build target (the processed manifest), but
470ead1f93eSLiane Praza# also the incidental ones (the metadata-derived symlinks).
471ead1f93eSLiane Praza#
472ead1f93eSLiane Praza# If pkgmogrify exits cleanly but fails to create the specified output
473ead1f93eSLiane Praza# file, it means that it encountered an abort directive.  That means
474ead1f93eSLiane Praza# that this package should not be published for this particular build
475ead1f93eSLiane Praza# environment.  Since we can't prune such packages from $(PKGS)
476ead1f93eSLiane Praza# retroactively, we need to create an empty target file to keep make
477ead1f93eSLiane Praza# from trying to rebuild it every time.  For these empty targets, we
478ead1f93eSLiane Praza# do not create metadata symlinks.
479ead1f93eSLiane Praza#
480ead1f93eSLiane Praza# Automatic dependency resolution to files is also done at this phase of
481ead1f93eSLiane Praza# processing.  The skipped packages are skipped due to existing bugs
482ead1f93eSLiane Praza# in pkgdepend.
483ead1f93eSLiane Praza#
484ead1f93eSLiane Praza# The incorporation dependency is tricky: it needs to go into all
485ead1f93eSLiane Praza# current and renamed manifests (ie all incorporated packages), but we
486ead1f93eSLiane Praza# don't know which those are until after we run pkgmogrify.  So
487ead1f93eSLiane Praza# instead of expressing it as a transform, we tack it on ex post facto.
488ead1f93eSLiane Praza#
489ead1f93eSLiane Praza# Implementation notes:
490ead1f93eSLiane Praza#
491ead1f93eSLiane Praza# - The first $(RM) must not match other manifests, or we'll run into
492ead1f93eSLiane Praza#   race conditions with parallel manifest processing.
493ead1f93eSLiane Praza#
494ead1f93eSLiane Praza# - The make macros [ie $(MACRO)] are evaluated when the makefile is
495ead1f93eSLiane Praza#   read in, and will result in a fixed, macro-expanded rule for each
496ead1f93eSLiane Praza#   target enumerated in $(PROC_PKGS).
497ead1f93eSLiane Praza#
498ead1f93eSLiane Praza# - The shell variables (ie $$VAR) are assigned on the fly, as the rule
499ead1f93eSLiane Praza#   is executed.  The results may only be referenced in the shell in
500ead1f93eSLiane Praza#   which they are assigned, so from the perspective of make, all code
501ead1f93eSLiane Praza#   that needs these variables needs to be part of the same line of
502ead1f93eSLiane Praza#   code.  Hence the use of command separators and line continuation
503ead1f93eSLiane Praza#   characters.
504ead1f93eSLiane Praza#
505ead1f93eSLiane Praza# - The extract_metadata transforms are designed to spit out shell
506ebbab6bbSDan Price#   variable assignments to stdout.  Those are published to the
507ebbab6bbSDan Price#   .vars temporary files, and then used as input to the eval
508ebbab6bbSDan Price#   statement.  This is done in stages specifically so that pkgmogrify
509ebbab6bbSDan Price#   can signal failure if the manifest has a syntactic or other error.
510ebbab6bbSDan Price#   The eval statement should begin with the default values, and the
511ebbab6bbSDan Price#   output from pkgmogrify (if any) should be in the form of a
512ebbab6bbSDan Price#   variable assignment to override those defaults.
513ead1f93eSLiane Praza#
514ead1f93eSLiane Praza# - When this rule completes execution, it must leave an updated
515ead1f93eSLiane Praza#   target file ($@) in place, or make will reprocess the package
516ead1f93eSLiane Praza#   every time it encounters it as a dependency.  Hence the "touch"
517ead1f93eSLiane Praza#   statement to ensure that the target is created, even when
51877c29b8eSRichard Lowe#   pkgmogrify encounters an abort in the publish transforms.
519ead1f93eSLiane Praza#
520ead1f93eSLiane Praza
52125b05a3eSAndy Fiddaman.SUFFIXES: .p5m .mog .dep .res .fin .pub
522ead1f93eSLiane Praza
52325b05a3eSAndy Fiddaman$(PDIR)/%.mog: manifests/%.p5m
524ead1f93eSLiane Praza	@print "Processing manifest $(<F)"
52586d41711SAndy Fiddaman	@pkgfmt -fv2 -c $<
526ead1f93eSLiane Praza	$(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) $(@:%.mog=%.nodepend) \
5275084e753SMark J. Nelson		$(@:%.mog=%.lics) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars
528ebbab6bbSDan Price	$(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \
529ebbab6bbSDan Price		$(PKGMOG_DEFINES:%=-D %) -P $(@).vars -O $(@) \
530ebbab6bbSDan Price		$(<) $(PM_TRANSFORMS)
531ebbab6bbSDan Price	$(PKGDEBUG)eval REPO=redist PKGSTAT=current NODEPEND=$(SUPPRESSPKGDEP) \
532ebbab6bbSDan Price		`$(CAT) -s $(@).vars`; \
533ead1f93eSLiane Praza	if [ -f $(@) ]; then \
534d34af1a4SMark J. Nelson		if [ "$$NODEPEND" != "false" ]; then \
535ead1f93eSLiane Praza			 $(TOUCH) $(@:%.mog=%.nodepend); \
536ead1f93eSLiane Praza		fi; \
537ead1f93eSLiane Praza		$(LN) -s $(@F) \
538ead1f93eSLiane Praza			$(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \
539ead1f93eSLiane Praza		if [ \( "$$PKGSTAT" = "current" \) -o \
540ead1f93eSLiane Praza		     \( "$$PKGSTAT" = "renamed" \) ]; \
541ead1f93eSLiane Praza			then print $(PKGDEP_INCORP) >> $(@); \
542ead1f93eSLiane Praza		fi; \
5435084e753SMark J. Nelson		print $$LICS > $(@:%.mog=%.lics); \
544ead1f93eSLiane Praza	else \
5455084e753SMark J. Nelson		$(TOUCH) $(@) $(@:%.mog=%.lics); \
546ead1f93eSLiane Praza	fi
547ebbab6bbSDan Price	$(PKGDEBUG)$(RM) $(@).vars
548ead1f93eSLiane Praza
549ead1f93eSLiane Praza$(PDIR)/%.dep: $(PDIR)/%.mog
550ead1f93eSLiane Praza	@print "Generating dependencies for $(<F)"
551ead1f93eSLiane Praza	$(PKGDEBUG)$(RM) $(@)
552ead1f93eSLiane Praza	$(PKGDEBUG)if [ ! -f $(@:%.dep=%.nodepend) ]; then \
553ead1f93eSLiane Praza		pkgdepend generate -m $(PKGDEP_TOKENS:%=-D %) $(<) \
554ead1f93eSLiane Praza			$(PKGROOT) > $(@); \
555ead1f93eSLiane Praza	else \
556ead1f93eSLiane Praza		$(CP) $(<) $(@); \
557ead1f93eSLiane Praza	fi
558ead1f93eSLiane Praza
559ead1f93eSLiane Praza#
560ead1f93eSLiane Praza# The full chain implies that there should be a .dep.res suffix rule,
561ead1f93eSLiane Praza# but dependency generation is done on a set of manifests, rather than
562ead1f93eSLiane Praza# on a per-manifest basis.  Instead, see the gendeps rule above.
563ead1f93eSLiane Praza#
564ead1f93eSLiane Praza
565069e6b7eSAndy Fiddaman$(PDIR)/%.fin: $(PDIR)/%.res
566069e6b7eSAndy Fiddaman	$(PKGDEBUG)$(RM) $(@)
567069e6b7eSAndy Fiddaman	$(PKGDEBUG)if [ -s $(<) ]; then \
568069e6b7eSAndy Fiddaman		print "Running final transforms for $(<F)"; \
569069e6b7eSAndy Fiddaman		$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) -O $(@) \
570069e6b7eSAndy Fiddaman		    $(<) $(PM_FINAL_TRANSFORMS); \
571069e6b7eSAndy Fiddaman	else \
572069e6b7eSAndy Fiddaman		$(TOUCH) $(@); \
573069e6b7eSAndy Fiddaman	fi
574069e6b7eSAndy Fiddaman
575069e6b7eSAndy Fiddaman$(PDIR)/%.pub: $(PDIR)/%.fin
576ead1f93eSLiane Praza	$(PKGDEBUG)m=$$(basename $(@:%.pub=%).metadata.*); \
577ead1f93eSLiane Praza	r=$${m#$(@F:%.pub=%.metadata.)+(?).}; \
578ead1f93eSLiane Praza	if [ -s $(<) ]; then \
579ead1f93eSLiane Praza		print "Publishing $(@F:%.pub=%) to $$r repository"; \
580ead1f93eSLiane Praza		pkgsend -s file://$(PKGDEST)/repo.$$r publish \
5815084e753SMark J. Nelson		    -d $(PKGROOT) -d $(TOOLSROOT) \
5825084e753SMark J. Nelson		    -d license_files -d $(PKGROOT)/licenses \
5835084e753SMark J. Nelson		    --fmri-in-manifest --no-index --no-catalog $(<) \
584ead1f93eSLiane Praza		    > /dev/null; \
585ead1f93eSLiane Praza	fi; \
586ead1f93eSLiane Praza	$(TOUCH) $(@);
587ead1f93eSLiane Praza
588ead1f93eSLiane Praza#
589ead1f93eSLiane Praza# rule to build the synthetic manifests
590ead1f93eSLiane Praza#
591ead1f93eSLiane Praza# This rule necessarily has PKGDEP_TYPE that changes according to
592ead1f93eSLiane Praza# the specific synthetic manifest.  Rather than escape command
593ead1f93eSLiane Praza# dependency checking for the real manifest processing, or failing to
594ead1f93eSLiane Praza# express the (indirect) dependency of synthetic manifests on real
595ead1f93eSLiane Praza# manifests, we simply split this rule out from the one above.
596ead1f93eSLiane Praza#
597ead1f93eSLiane Praza# The implementation notes from the previous rule are applicable
598ead1f93eSLiane Praza# here, too.
599ead1f93eSLiane Praza#
60025b05a3eSAndy Fiddaman$(PROC_SYNTH_PKGS): $(PKGLISTS) $$(@F:%.mog=%.p5m)
60125b05a3eSAndy Fiddaman	@print "Processing synthetic manifest $(@F:%.mog=%.p5m)"
602ebbab6bbSDan Price	$(PKGDEBUG)$(RM) $(@) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars
603ebbab6bbSDan Price	$(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) -I transforms -I $(PDIR) \
604ead1f93eSLiane Praza		$(PKGMOG_DEFINES:%=-D %) -D PKGDEP_TYPE=$(PKGDEP_TYPE) \
60525b05a3eSAndy Fiddaman		-P $(@).vars -O $(@) $(@F:%.mog=%.p5m) \
606ebbab6bbSDan Price		$(PM_TRANSFORMS) synthetic
607ebbab6bbSDan Price	$(PKGDEBUG)eval REPO=redist PKGSTAT=current `$(CAT) -s $(@).vars`; \
608ead1f93eSLiane Praza	if [ -f $(@) ]; then \
609ead1f93eSLiane Praza		$(LN) -s $(@F) \
610ead1f93eSLiane Praza			$(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \
611ead1f93eSLiane Praza	else \
612ead1f93eSLiane Praza		$(TOUCH) $(@); \
613ead1f93eSLiane Praza	fi
614ebbab6bbSDan Price	$(PKGDEBUG)$(RM) $(@).vars
615ead1f93eSLiane Praza
616ead1f93eSLiane Praza$(DEP_SYNTH_PKGS): $$(@:%.dep=%.mog)
617ead1f93eSLiane Praza	@print "Skipping dependency generation for $(@F:%.dep=%)"
618ead1f93eSLiane Praza	$(PKGDEBUG)$(CP) $(@:%.dep=%.mog) $(@)
619ead1f93eSLiane Praza
620ead1f93eSLiane Prazaclean:
621ead1f93eSLiane Praza
622ead1f93eSLiane Prazaclobber: clean
623ead1f93eSLiane Praza	$(RM) -r $(CLOBBERFILES)
624ead1f93eSLiane Praza
625ead1f93eSLiane Praza#
626ead1f93eSLiane Praza# This rule assumes that all links in the $PKGSTAT directories
627ead1f93eSLiane Praza# point to valid manifests, and will fail the make run if one
628ead1f93eSLiane Praza# does not contain an fmri.
629ead1f93eSLiane Praza#
630ead1f93eSLiane Praza# The protolist is used for bfu archive creation, which may be invoked
631ead1f93eSLiane Praza# interactively by the user.  Both protolist and PKGLISTS targets
632ead1f93eSLiane Praza# depend on $(PROC_PKGS), but protolist builds them recursively.
633ead1f93eSLiane Praza# To avoid collisions, we insert protolist into the dependency chain
634ead1f93eSLiane Praza# here.  This has two somewhat subtle benefits: it allows bfu archive
635ead1f93eSLiane Praza# creation to work correctly, even when -a was not part of NIGHTLY_OPTIONS,
636ead1f93eSLiane Praza# and it ensures that a protolist file here will always correspond to the
637ead1f93eSLiane Praza# contents of the processed manifests, which can vary depending on build
638ead1f93eSLiane Praza# environment.
639ead1f93eSLiane Praza#
6402bd79b08SAndy Fiddaman$(PKGLISTS): scripts/pkglist.awk $(PROC_PKGS)
641ead1f93eSLiane Praza	$(PKGDEBUG)sdotr=$(@F:packages.%=%); \
642ead1f93eSLiane Praza	r=$${sdotr%.+(?)}; s=$${sdotr#+(?).}; \
643ead1f93eSLiane Praza	print "Generating $$r $$s package list"; \
644ead1f93eSLiane Praza	$(RM) $(@); $(TOUCH) $(@); \
6452bd79b08SAndy Fiddaman	$(AWK) -f scripts/pkglist.awk \
6462bd79b08SAndy Fiddaman	    `find $(PDIR) -type l -a \( $(PKGS:%=-name %.metadata.$$s.$$r -o) \
6472bd79b08SAndy Fiddaman	    -name NOSUCHFILE \)` >> $(@)
648ead1f93eSLiane Praza
649ead1f93eSLiane Praza#
650ead1f93eSLiane Praza# rules to validate proto area against manifests, check for safe
651ead1f93eSLiane Praza# file permission modes, and generate a faux proto list
652ead1f93eSLiane Praza#
653ead1f93eSLiane Praza# For the check targets, the dependencies on $(PROC_PKGS) is specified
654ead1f93eSLiane Praza# as a subordinate make process in order to suppress output.
655ead1f93eSLiane Praza#
656ead1f93eSLiane Prazamakesilent:
657ead1f93eSLiane Praza	@$(MAKE) -e $(PROC_PKGS) PKGMACH=$(PKGMACH) \
658ead1f93eSLiane Praza		SUPPRESSPKGDEP=$(SUPPRESSPKGDEP) > /dev/null
659ead1f93eSLiane Praza
6605084e753SMark J. Nelson#
6615084e753SMark J. Nelson# The .lics files were created during pkgmogrification, and list the
6625084e753SMark J. Nelson# set of licenses to pull from $SRC for each package.  Because
6635084e753SMark J. Nelson# licenses may be duplicated between packages, we uniquify them as
6645084e753SMark J. Nelson# well as aggregating them here.
6655084e753SMark J. Nelson#
6665084e753SMark J. Nelsonlicense-list: makesilent
6675084e753SMark J. Nelson	$(PKGDEBUG)( for l in `cat $(PROC_PKGS:%.mog=%.lics)`; \
6685084e753SMark J. Nelson		do print $$l; done ) | sort -u > $@
6695084e753SMark J. Nelson
6705084e753SMark J. Nelson#
6715084e753SMark J. Nelson# Staging the license and description files in the proto area allows
6725084e753SMark J. Nelson# us to do proper unreferenced file checking of both license and
6735084e753SMark J. Nelson# description files without blanket exceptions, and to pull license
6745084e753SMark J. Nelson# content without reference to $CODEMGR_WS during publication.
6755084e753SMark J. Nelson#
6765084e753SMark J. Nelsonstage-licenses: license-list FRC
6775084e753SMark J. Nelson	$(PKGDEBUG)$(MAKE) -e -f Makefile.lic \
6785084e753SMark J. Nelson		PKGDEBUG=$(PKGDEBUG) LICROOT=$(PKGROOT)/licenses \
6797b07063dSIgor Kozhukhov		`$(AWK) '{ \
6805084e753SMark J. Nelson			print "$(PKGROOT)/licenses/" $$0; \
6815084e753SMark J. Nelson			print "$(PKGROOT)/licenses/" $$0 ".descrip"; \
6825084e753SMark J. Nelson		}' license-list` > /dev/null;
6835084e753SMark J. Nelson
684ead1f93eSLiane Prazaprotocmp: makesilent
685ead1f93eSLiane Praza	@validate_pkg -a $(PKGMACH) -v \
686ead1f93eSLiane Praza		$(EXCEPTIONS:%=-e $(CODEMGR_WS)/exception_lists/%) \
687ead1f93eSLiane Praza		-m $(PDIR) -p $(PKGROOT) -p $(TOOLSROOT)
688ead1f93eSLiane Praza
689ead1f93eSLiane Prazapmodes: makesilent
690ead1f93eSLiane Praza	@validate_pkg -a $(PKGMACH) -M -m $(PDIR) \
691e8921a52SAndy Fiddaman		-e $(CODEMGR_WS)/exception_lists/pmodes
692ead1f93eSLiane Praza
693069e6b7eSAndy Fiddamanpkglint: makesilent
694069e6b7eSAndy Fiddaman	$(PKGDEBUG)$(CP) etc/pkglintrc $(PDIR)/pkglintrc
695069e6b7eSAndy Fiddaman	$(PKGDEBUG)$(GREP) pkg:/ $(CODEMGR_WS)/exception_lists/packaging.deps \
696069e6b7eSAndy Fiddaman	    | sed 's/.*/    & \\/' >> $(PDIR)/pkglintrc
697069e6b7eSAndy Fiddaman	$(PKGDEBUG)echo "    pkg:/runtime/python$(PYTHON3_PKGVERS) \\" \
698069e6b7eSAndy Fiddaman	     >> $(PDIR)/pkglintrc
699*445784c0SAndy Fiddaman	$(PKGDEBUG)$(BUILDPY3b) \
700*445784c0SAndy Fiddaman	    echo "    pkg:/runtime/python$(PYTHON3b_PKGVERS) \\" \
701*445784c0SAndy Fiddaman	     >> $(PDIR)/pkglintrc
702069e6b7eSAndy Fiddaman	$(PKGDEBUG) echo "    pkg:/runtime/perl$(PERL_PKGVERS) \\" \
703069e6b7eSAndy Fiddaman	     >> $(PDIR)/pkglintrc
704069e6b7eSAndy Fiddaman	$(PKGDEBUG)echo >> $(PDIR)/pkglintrc
705069e6b7eSAndy Fiddaman	$(PKGDEBUG)$(RM) -rf $(PKGDEST)/lint.image
706069e6b7eSAndy Fiddaman	$(PKGDEBUG)for r in $(REPOS); do \
707069e6b7eSAndy Fiddaman		pkglint \
708069e6b7eSAndy Fiddaman		    -f $(PDIR)/pkglintrc \
709069e6b7eSAndy Fiddaman		    -c $(PKGDEST)/lint.image \
710069e6b7eSAndy Fiddaman		    -r $(PKGDEST)/repo.$$r \
711069e6b7eSAndy Fiddaman		    `$(FIND) $(PDIR) -name \*.fin \! -size 0c -print`; \
712069e6b7eSAndy Fiddaman	done
713069e6b7eSAndy Fiddaman
714069e6b7eSAndy Fiddamancheck: protocmp pmodes pkglint
715ead1f93eSLiane Praza
716ead1f93eSLiane Prazaprotolist: proto_list_$(PKGMACH)
717ead1f93eSLiane Praza
718ead1f93eSLiane Prazaproto_list_$(PKGMACH): $(PROC_PKGS)
719ead1f93eSLiane Praza	@validate_pkg -a $(PKGMACH) -L -m $(PDIR) > $(@)
720ead1f93eSLiane Praza
721ead1f93eSLiane Praza$(PROC_PKGS): $(PDIR)
722ead1f93eSLiane Praza
723ead1f93eSLiane Praza#
724ead1f93eSLiane Praza# This is a convenience target to allow package names to function as
725ead1f93eSLiane Praza# build targets.  Generally, using it is only useful when iterating on
726ead1f93eSLiane Praza# development of a manifest.
727ead1f93eSLiane Praza#
728ead1f93eSLiane Praza# When processing a manifest, use the basename (without extension) of
729ead1f93eSLiane Praza# the package.  When publishing, use the basename with a ".pub"
730ead1f93eSLiane Praza# extension.
731ead1f93eSLiane Praza#
732ead1f93eSLiane Praza# Other than during manifest development, the preferred usage is to
733ead1f93eSLiane Praza# avoid these targets and override PKGS on the make command line and
734ead1f93eSLiane Praza# use the provided all and install targets.
735ead1f93eSLiane Praza#
736ead1f93eSLiane Praza$(PKGS) $(SYNTH_PKGS): $(PDIR)/$$(@:%=%.mog)
737ead1f93eSLiane Praza
738ead1f93eSLiane Praza$(PKGS:%=%.pub) $(SYNTH_PKGS:%=%.pub): $(PDIR)/$$(@)
739ead1f93eSLiane Praza
740ead1f93eSLiane Praza#
741ead1f93eSLiane Praza# This is a convenience target to resolve dependencies without publishing
742ead1f93eSLiane Praza# packages.
743ead1f93eSLiane Praza#
744ead1f93eSLiane Prazagendeps: $(PDIR)/gendeps
745ead1f93eSLiane Praza
746ead1f93eSLiane Praza#
747ead1f93eSLiane Praza# These are convenience targets for cross-platform packaging.  If you
748ead1f93eSLiane Praza# want to build any of "the normal" targets for a different
749ead1f93eSLiane Praza# architecture, simply use "arch/target" as your build target.
750ead1f93eSLiane Praza#
751ead1f93eSLiane Praza# Since the most common use case for this is "install," the architecture
752ead1f93eSLiane Praza# specific install targets have been further abbreviated to elide "/install."
753ead1f93eSLiane Praza#
754708bde8cSGarrett D'Amorei386/%:
755ead1f93eSLiane Praza	$(MAKE) -e $(@F) PKGMACH=$(@D) SUPPRESSPKGDEP=$(SUPPRESSPKGDEP)
756ead1f93eSLiane Praza
757708bde8cSGarrett D'Amorei386: $$(@)/install
758ead1f93eSLiane Praza
759ead1f93eSLiane PrazaFRC:
760