Alexander Pyhalov
2018-09-06 44f1c2ebd9a7a3036f44c216d9fcf4b228cd5432
commit | author | age
9c75c0 1 #
NJ 2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
4505fe 21 # Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
b31a41 22 # Copyright 2014 Andrzej Szeszo. All rights reserved.
9c75c0 23 #
NJ 24
25 #
26 # Rules and Macros for generating an IPS package manifest and publishing an
27 # IPS package to a pkg depot.
28 #
29 # To use these rules, include ../make-rules/ips.mk in your Makefile
30 # and define an "install" target appropriate to building your component.
31 # Ex:
32 #
74300c 33 #    install:    $(BUILD_DIR)/build/$(MACH32)/.installed \
NJ 34 #             $(BUILD_DIR)/build/$(MACH64)/.installed
9c75c0 35 #
NJ 36 # This set of rules makes the "publish" target the default target for make(1)
37 #
38
39 PKGDEPEND =    /usr/bin/pkgdepend
6514ee 40 PKGFMT =    /usr/bin/pkgfmt
NJ 41 PKGMOGRIFY =    /usr/bin/pkgmogrify
42 PKGSEND =    /usr/bin/pkgsend
7bf47e 43 ifeq   ($(strip $(PKGLINT_COMPONENT)),)
3dc823 44 PKGLINT =    /usr/bin/pkglint
7bf47e 45 else
MS 46 PKGLINT =    ${WS_TOOLS}/pkglint
47 endif
4158c0 48 PKGMANGLE =    $(WS_TOOLS)/userland-mangler
9c75c0 49
d180f2 50 WS_TRANSFORMS =    $(WS_TOP)/transforms
51
94deda 52 GENERATE_HISTORY= $(WS_TOOLS)/generate-history
AP 53 HISTORY=    history
54
6514ee 55 # Package headers should all pretty much follow the same format
NJ 56 METADATA_TEMPLATE =        $(WS_TOP)/transforms/manifest-metadata-template
57 COPYRIGHT_TEMPLATE =        $(WS_TOP)/transforms/copyright-template
9c75c0 58
6514ee 59 # order is important
NJ 60 GENERATE_TRANSFORMS +=        $(WS_TOP)/transforms/generate-cleanup
5d461f 61
cf4b61 62 PKGMOGRIFY_TRANSFORMS +=    $(WS_TOP)/transforms/libtool-drop
7fd1f9 63 PKGMOGRIFY_TRANSFORMS +=    $(WS_TOP)/transforms/ignore-libs
cf4b61 64
90207d 65 ifneq ($(GCC_ROOT), /usr/gcc/4.9)
AP 66 PKGMOGRIFY_TRANSFORMS +=    $(WS_TOP)/transforms/ignore-gcc-usr-lib
67 endif
68
6514ee 69 COMPARISON_TRANSFORMS +=    $(WS_TOP)/transforms/comparison-cleanup
NJ 70 COMPARISON_TRANSFORMS +=    $(PKGMOGRIFY_TRANSFORMS)
9c75c0 71
8c2f8f 72 LICENSE_TRANSFORMS =        $(WS_TOP)/transforms/license-changes
RB 73
6514ee 74 # order is important
8c2f8f 75 PUBLISH_TRANSFORMS +=    $(LICENSE_TRANSFORMS)
9dfd18 76 PUBLISH_TRANSFORMS +=    $(WS_TOP)/transforms/variant-cleanup
3cec7d 77 PUBLISH_TRANSFORMS +=    $(WS_TOP)/transforms/autopyc
6514ee 78 PUBLISH_TRANSFORMS +=    $(WS_TOP)/transforms/defaults
NJ 79 PUBLISH_TRANSFORMS +=    $(WS_TOP)/transforms/actuators
80 PUBLISH_TRANSFORMS +=    $(WS_TOP)/transforms/devel
81 PUBLISH_TRANSFORMS +=    $(WS_TOP)/transforms/docs
82 PUBLISH_TRANSFORMS +=    $(WS_TOP)/transforms/locale
a60de4 83 PUBLISH_TRANSFORMS +=    $(WS_TOP)/transforms/python-3-soabi
44f1c2 84 PUBLISH_TRANSFORMS +=    $(WS_TOP)/transforms/python-3-no-32bit
6514ee 85 PUBLISH_TRANSFORMS +=    $(PKGMOGRIFY_TRANSFORMS)
NJ 86 PUBLISH_TRANSFORMS +=    $(WS_TOP)/transforms/publish-cleanup
87
280925 88 ifeq   ($(strip $(COMPONENT_AUTOGEN_MANIFEST)),yes)
AS 89 AUTOGEN_MANIFEST_TRANSFORMS +=        $(WS_TOP)/transforms/generate-cleanup
90 else
91 AUTOGEN_MANIFEST_TRANSFORMS +=        $(WS_TOP)/transforms/drop-all
92 endif
93
6514ee 94 PKG_MACROS +=        MACH=$(MACH)
NJ 95 PKG_MACROS +=        MACH32=$(MACH32)
96 PKG_MACROS +=        MACH64=$(MACH64)
97 PKG_MACROS +=        PUBLISHER=$(PUBLISHER)
c4768d 98 PKG_MACROS +=        PUBLISHER_LOCALIZABLE=$(PUBLISHER_LOCALIZABLE)
6514ee 99 PKG_MACROS +=        CONSOLIDATION=$(CONSOLIDATION)
NJ 100 PKG_MACROS +=        BUILD_VERSION=$(BUILD_VERSION)
101 PKG_MACROS +=        SOLARIS_VERSION=$(SOLARIS_VERSION)
102 PKG_MACROS +=        OS_VERSION=$(OS_VERSION)
097eb5 103 PKG_MACROS +=        PKG_SOLARIS_VERSION=$(PKG_SOLARIS_VERSION)
adb83a 104 PKG_MACROS +=        HUMAN_VERSION=$(HUMAN_VERSION)
6514ee 105 PKG_MACROS +=        IPS_COMPONENT_VERSION=$(IPS_COMPONENT_VERSION)
3f36e3 106 PKG_MACROS +=        COMPONENT_VERSION=$(COMPONENT_VERSION)
3a19d0 107 PKG_MACROS +=        COMPONENT_PROJECT_URL=$(COMPONENT_PROJECT_URL)
6514ee 108 PKG_MACROS +=        COMPONENT_ARCHIVE_URL=$(COMPONENT_ARCHIVE_URL)
dc18f2 109 PKG_MACROS +=        COMPONENT_HG_URL=$(COMPONENT_HG_URL)
DD 110 PKG_MACROS +=        COMPONENT_HG_REV=$(COMPONENT_HG_REV)
8c2f8f 111 PKG_MACROS +=        COMPONENT_NAME=$(COMPONENT_NAME)
280925 112 PKG_MACROS +=        COMPONENT_FMRI=$(COMPONENT_FMRI)
AS 113 PKG_MACROS +=        COMPONENT_LICENSE_FILE=$(COMPONENT_LICENSE_FILE)
8c2f8f 114 PKG_MACROS +=        TPNO=$(TPNO)
b31a41 115 PKG_MACROS +=        USERLAND_GIT_REMOTE=$(USERLAND_GIT_REMOTE)
AS 116 PKG_MACROS +=        USERLAND_GIT_BRANCH=$(USERLAND_GIT_BRANCH)
117 PKG_MACROS +=        USERLAND_GIT_REV=$(USERLAND_GIT_REV)
6514ee 118
cce78d 119 PKG_OPTIONS +=        $(PKG_MACROS:%=-D %) \
JK 120                     -D COMPONENT_SUMMARY="$(strip $(COMPONENT_SUMMARY))" \
121                     -D COMPONENT_CLASSIFICATION="org.opensolaris.category.2008:$(strip $(COMPONENT_CLASSIFICATION))" \
122                     -D COMPONENT_DESCRIPTION="$(strip $(COMPONENT_DESCRIPTION))" \
123                     -D COMPONENT_LICENSE="$(strip $(COMPONENT_LICENSE))"
6514ee 124
bd5c30 125 PKG_MACROS +=           PYTHON_2.7_ONLY=\#
AP 126 PKG_MACROS +=           PYTHON_3.4_ONLY=\#
44f1c2 127 PKG_MACROS +=           PYTHON_3.5_ONLY=\#
AP 128 PKG_MACROS +=           PYTHON_32_ONLY=
bd5c30 129
4158c0 130 MANGLED_DIR =    $(PROTO_DIR)/mangled
NJ 131
132 PKG_PROTO_DIRS += $(MANGLED_DIR) $(PROTO_DIR) $(@D) $(COMPONENT_DIR) $(COMPONENT_SRC)
35a012 133
74300c 134 MANIFEST_BASE =        $(BUILD_DIR)/manifest-$(MACH)
6514ee 135
5b9db7 136 SAMPLE_MANIFEST_DIR =     $(COMPONENT_DIR)/manifests
137 SAMPLE_MANIFEST_FILE =    $(SAMPLE_MANIFEST_DIR)/sample-manifest.p5m
138
ff17eb 139 CANONICAL_MANIFESTS =    $(wildcard *.p5m)
94deda 140 ifneq ($(wildcard $(HISTORY)),)
AP 141 HISTORICAL_MANIFESTS = $(shell $(NAWK) -v FUNCTION=name -f $(GENERATE_HISTORY) < $(HISTORY))
142 endif
5ada66 143
DD 144 # Look for manifests which need to be duplicated for each version of python.
145 ifeq ($(findstring -PYVER,$(CANONICAL_MANIFESTS)),-PYVER)
146 UNVERSIONED_MANIFESTS = $(filter-out %-GENFRAG.p5m,$(filter-out %-PYVER.p5m,$(CANONICAL_MANIFESTS)))
147 PY_MANIFESTS = $(filter %-PYVER.p5m,$(CANONICAL_MANIFESTS))
148 PYV_MANIFESTS = $(foreach v,$(shell echo $(PYTHON_VERSIONS) | tr -d .),$(shell echo $(PY_MANIFESTS) | sed -e 's/-PYVER.p5m/-$(v).p5m/g'))
149 PYNV_MANIFESTS = $(shell echo $(PY_MANIFESTS) | sed -e 's/-PYVER//')
150 else
151 UNVERSIONED_MANIFESTS = $(CANONICAL_MANIFESTS)
152 endif
153
154 # Look for manifests which need to be duplicated for each version of perl.
155 ifeq ($(findstring -PERLVER,$(UNVERSIONED_MANIFESTS)),-PERLVER)
156 NOPERL_MANIFESTS = $(filter-out %-GENFRAG.p5m,$(filter-out %-PERLVER.p5m,$(UNVERSIONED_MANIFESTS)))
157 PERL_MANIFESTS = $(filter %-PERLVER.p5m,$(UNVERSIONED_MANIFESTS))
158 PERLV_MANIFESTS = $(foreach v,$(shell echo $(PERL_VERSIONS) | tr -d .),$(shell echo $(PERL_MANIFESTS) | sed -e 's/-PERLVER.p5m/-$(v).p5m/g'))
159 PERLNV_MANIFESTS = $(shell echo $(PERL_MANIFESTS) | sed -e 's/-PERLVER//')
160 else
161 NOPERL_MANIFESTS = $(UNVERSIONED_MANIFESTS)
162 endif
163
18b823 164 # Look for manifests which need to be duplicated for each version of ruby.
AP 165 # NOPERL_MANIFESTS represents the manifests that are not Python or
166 # Perl manifests.  Extract the Ruby Manifests from NOPERL_MANIFESTS.
167 # Any remaining manifests are stored in NONRUBY_MANIFESTS
168 ifeq ($(findstring -RUBYVER,$(NOPERL_MANIFESTS)),-RUBYVER)
169 NORUBY_MANIFESTS = $(filter-out %GENFRAG.p5m,\
170                       $(filter-out %-RUBYVER.p5m,$(NOPERL_MANIFESTS)))
171 RUBY_MANIFESTS = $(filter %-RUBYVER.p5m,$(NOPERL_MANIFESTS))
172 RUBYV_MANIFESTS = $(foreach v,$(shell echo $(RUBY_VERSIONS)),\
173                       $(shell echo $(RUBY_MANIFESTS) |\
174                       sed -e 's/-RUBYVER.p5m/-$(shell echo $(v) |\
175                       cut -d. -f1,2 | tr -d .).p5m/g'))
176 RUBYNV_MANIFESTS = $(shell echo $(RUBY_MANIFESTS) | sed -e 's/-RUBYVER//')
177 else
178 NORUBY_MANIFESTS = $(NOPERL_MANIFESTS)
179 endif
180
5ada66 181 VERSIONED_MANIFESTS = \
DD 182     $(PYV_MANIFESTS) $(PYNV_MANIFESTS) \
183     $(PERLV_MANIFESTS) $(PERLNV_MANIFESTS) \
18b823 184     $(RUBYV_MANIFESTS) $(RUBYNV_MANIFESTS) \
94deda 185     $(NORUBY_MANIFESTS) $(HISTORICAL_MANIFESTS)
5ada66 186
6514ee 187 GENERATED =        $(MANIFEST_BASE)-generated
NJ 188 COMBINED =        $(MANIFEST_BASE)-combined
5ada66 189 MANIFESTS =        $(VERSIONED_MANIFESTS:%=$(MANIFEST_BASE)-%)
6514ee 190
NJ 191
5ada66 192 DEPENDED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend)
DD 193 RESOLVED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend.res)
4221e1 194 PRE_PUBLISHED=$(RESOLVED:%.depend.res=%.pre-published)
93b18c 195 PUBLISHED=$(RESOLVED:%.depend.res=%.published)
9c75c0 196
7e871a 197 COPYRIGHT_FILE ?=    $(COMPONENT_NAME)-$(COMPONENT_VERSION).copyright
d05a6f 198 IPS_COMPONENT_VERSION ?=    $(COMPONENT_VERSION)
153732 199
6514ee 200 .DEFAULT:        publish
153732 201
3dc823 202 .SECONDARY:
9c75c0 203
2ae1af 204 # allow publishing to be overridden, such as when
MS 205 # a package is for one architecture only.
4221e1 206 PRE_PUBLISH_STAMP ?= $(BUILD_DIR)/.pre-published-$(MACH)
2ae1af 207 PUBLISH_STAMP ?= $(BUILD_DIR)/.published-$(MACH)
MS 208
4221e1 209 # Do all that is needed to ensure the package is consistent for publishing,
JK 210 # except actually pushing to a repo, separately from the push to the repo.
86e587 211 pre-publish:    build install $(PRE_PUBLISH_STAMP)
4221e1 212 publish:        pre-publish $(PUBLISH_STAMP)
9c75c0 213
ff17eb 214 sample-manifest:    $(GENERATED).p5m
9c75c0 215
86e587 216 $(GENERATED).p5m:    install
5b9db7 217     [ ! -d $(SAMPLE_MANIFEST_DIR) ] && $(MKDIR) $(SAMPLE_MANIFEST_DIR) || true
ade6bb 218     $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR) | \
NJ 219     $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(GENERATE_TRANSFORMS) | \
940107 220         sed -e '/^$$/d' -e '/^#.*$$/d' -e '/^dir .*$$/d' \
5b9db7 221         -e '/\.la$$/d' -e '/\.pyo$$/d' -e '/usr\/lib\/python[23]\..*\.pyc$$/d' \
222         -e '/.*\/__pycache__\/.*/d'  | \
940107 223         $(PKGFMT) | \
5b9db7 224         cat $(METADATA_TEMPLATE) - | \
225         $(TEE) $@ $(SAMPLE_MANIFEST_FILE) >/dev/null
6514ee 226
ade6bb 227 # copy the canonical manifest(s) to the build tree
86e587 228 $(MANIFEST_BASE)-%.generate:    %.p5m canonical-manifests
ade6bb 229     cat $(METADATA_TEMPLATE) $< >$@
6514ee 230
5ada66 231 # The text of a transform that will emit a dependency conditional on the
DD 232 # presence of a particular version of a runtime, which will then draw in the
233 # runtime-version-specific version of the package we're operating on.  $(1) is
234 # the name of the runtime package, and $(2) is the version suffix.
235 mkgeneric = \
236     echo "<transform set name=pkg.fmri value=(?:pkg:/)?(.+)-\#\#\#@(.*)" \
237         "-> emit depend nodrop=true type=conditional" \
238         "predicate=$(1)-$(2) fmri=%<1>-$(2)@%<2>>" >> $@;
239
240 # Define and execute a macro that generates a rule to create a manifest for a
241 # python module specific to a particular version of the python runtime.
242 define python-manifest-rule
bd5c30 243 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).mogrified: PKG_MACROS += PYTHON_$(1)_ONLY=
AP 244
44f1c2 245 ifneq ($(filter $(1),$(PYTHON_64_ONLY_VERSIONS)),)
AP 246 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).mogrified: PKG_MACROS += PYTHON_32_ONLY=\#
247 endif
248
5ada66 249 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-PYVER.p5m
DD 250     $(PKGMOGRIFY) -D PYVER=$(1) -D PYV=$(shell echo $(1) | tr -d .) $$< > $$@
251 endef
252 $(foreach ver,$(PYTHON_VERSIONS),$(eval $(call python-manifest-rule,$(ver))))
253
254 # A rule to create a helper transform package for python, that will insert the
255 # appropriate conditional dependencies into a python library's
256 # runtime-version-generic package to pull in the version-specific bits when the
257 # corresponding version of python is on the system.
525ed1 258 $(BUILD_DIR)/mkgeneric-python: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ)
5ada66 259     $(RM) $@
DD 260     $(foreach ver,$(shell echo $(PYTHON_VERSIONS) | tr -d .), \
261         $(call mkgeneric,runtime/python,$(ver)))
262
263 # Build Python version-wrapping manifests from the generic version.
86e587 264 $(MANIFEST_BASE)-%.p5m: %-PYVER.p5m $(BUILD_DIR)/mkgeneric-python
525ed1 265     $(PKGMOGRIFY) -D PYV=### $(BUILD_DIR)/mkgeneric-python \
5ada66 266         $(WS_TOP)/transforms/mkgeneric $< > $@
DD 267     if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
268
9581d1 269 # Define and execute a macro that generates a rule to create a manifest for a
CM 270 # perl module specific to a particular version of the perl runtime.
271 define perl-manifest-rule
272 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-PERLVER.p5m
273     $(PKGMOGRIFY) -D PERLVER=$(1) -D PLV=$(shell echo $(1) | tr -d .) \
274         -D PERL_ARCH=$(call PERL_ARCH_FUNC,$(PERL.$(1))) $$< > $$@
275 endef
276 $(foreach ver,$(PERL_VERSIONS),$(eval $(call perl-manifest-rule,$(ver))))
277
5ada66 278 # A rule to create a helper transform package for perl, that will insert the
DD 279 # appropriate conditional dependencies into a perl library's
280 # runtime-version-generic package to pull in the version-specific bits when the
281 # corresponding version of perl is on the system.
525ed1 282 $(BUILD_DIR)/mkgeneric-perl: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ)
5ada66 283     $(RM) $@
DD 284     $(foreach ver,$(shell echo $(PERL_VERSIONS) | tr -d .), \
285         $(call mkgeneric,runtime/perl,$(ver)))
286
287 # Build Perl version-wrapping manifests from the generic version.
86e587 288 $(MANIFEST_BASE)-%.p5m: %-PERLVER.p5m $(BUILD_DIR)/mkgeneric-perl
525ed1 289     $(PKGMOGRIFY) -D PLV=### $(BUILD_DIR)/mkgeneric-perl \
5ada66 290         $(WS_TOP)/transforms/mkgeneric $< > $@
DD 291     if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
292
94deda 293 # Rule to generate historical manifests from the $(HISTORY) file.
AP 294 define history-manifest-rule
295 $(MANIFEST_BASE)-$(1): $(HISTORY) $(BUILD_DIR)
296     $(NAWK) -v TARGET=$(1) -v FUNCTION=manifest -f $(GENERATE_HISTORY) < \
297         $(HISTORY) > $$@
298 endef
299 $(foreach mfst,$(HISTORICAL_MANIFESTS),$(eval $(call history-manifest-rule,$(mfst))))
300
18b823 301 # Define and execute a macro that generates a rule to create a manifest for a
AP 302 # ruby module specific to a particular version of the ruby runtime.
303 # Creates build/manifest-*-modulename-##.p5m file where ## is replaced with
304 # the version number.
305 define ruby-manifest-rule
306 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).mogrified: \
307         PKG_MACROS += RUBY_VERSION=$(1) RUBY_LIB_VERSION=$(2) \
308             RUBYV=$(subst .,,$(1))
309
86e587 310 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-RUBYVER.p5m
18b823 311     if [ -f $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m ]; then \
AP 312             cat $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m >> $$@; \
313     fi
314     $(PKGMOGRIFY) -D RUBY_VERSION=$(1) -D RUBY_LIB_VERSION=$(2) \
315         -D RUBYV=$(shell echo $(1) | tr -d .) $$< > $$@
316 endef
317 $(foreach ver,$(RUBY_VERSIONS),\
318         $(eval $(call ruby-manifest-rule,$(shell echo $(ver) | \
319             cut -d. -f1,2),$(ver))))
320
321 # A rule to create a helper transform package for ruby, that will insert the
322 # appropriate conditional dependencies into a ruby library's
323 # runtime-version-generic package to pull in the version-specific bits when the
324 # corresponding version of ruby is on the system.
525ed1 325 $(BUILD_DIR)/mkgeneric-ruby: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ)
18b823 326     $(RM) $@
AP 327     $(foreach ver,$(RUBY_VERSIONS),\
328             $(call mkgeneric,runtime/ruby,$(shell echo $(ver) | \
329                 cut -d. -f1,2 | tr -d .)))
330
331 # Build Ruby version-wrapping manifests from the generic version.
332 # Creates build/manifest-*-modulename.p5m file.
333 #
86e587 334 $(MANIFEST_BASE)-%.p5m: %-RUBYVER.p5m $(BUILD_DIR)/mkgeneric-ruby
18b823 335     $(PKGMOGRIFY) -D RUBYV=### $(BUILD_DIR)/mkgeneric-ruby \
AP 336             $(WS_TOP)/transforms/mkgeneric $< > $@
337     if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
338
9928c1 339 ifeq   ($(strip $(COMPONENT_AUTOGEN_MANIFEST)),yes)
280925 340 # auto-generate file/directory list
86e587 341 $(MANIFEST_BASE)-%.generated:    %.p5m $(BUILD_DIR)
280925 342     (cat $(METADATA_TEMPLATE); \
AS 343     $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR)) | \
344     $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(AUTOGEN_MANIFEST_TRANSFORMS) | \
345         sed -e '/^$$/d' -e '/^#.*$$/d' | $(PKGFMT) | \
346         cat $< - >$@
347
5ada66 348 # mogrify non-parameterized manifests
280925 349 $(MANIFEST_BASE)-%.mogrified:    %.generated
cf5bf1 350     $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
AP 351         $(PUBLISH_TRANSFORMS) | \
352         sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
353
354 # mogrify parameterized manifests
355 $(MANIFEST_BASE)-%.mogrified:    $(MANIFEST_BASE)-%.generated
356     $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
357         $(PUBLISH_TRANSFORMS) | \
358         sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
359 else
360 # mogrify non-parameterized manifests
86e587 361 $(MANIFEST_BASE)-%.mogrified:    %.p5m $(BUILD_DIR)
5ada66 362     $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
DD 363         $(PUBLISH_TRANSFORMS) | \
364         sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
365
366 # mogrify parameterized manifests
e90173 367 $(MANIFEST_BASE)-%.mogrified:    $(MANIFEST_BASE)-%.p5m $(BUILD_DIR)
70eebe 368     $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
ade6bb 369         $(PUBLISH_TRANSFORMS) | \
NJ 370         sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
cf5bf1 371 endif
6514ee 372
4158c0 373 # mangle the file contents
c2319a 374 $(BUILD_DIR) $(MANGLED_DIR):
4158c0 375     $(MKDIR) $@
NJ 376
377 PKGMANGLE_OPTIONS = -D $(MANGLED_DIR) $(PKG_PROTO_DIRS:%=-d %)
378 $(MANIFEST_BASE)-%.mangled:    $(MANIFEST_BASE)-%.mogrified $(MANGLED_DIR)
379     $(PKGMANGLE) $(PKGMANGLE_OPTIONS) -m $< >$@
380
1aa2da 381 # generate dependencies
35a012 382 PKGDEPEND_GENERATE_OPTIONS = -m $(PKG_PROTO_DIRS:%=-d %)
4158c0 383 $(MANIFEST_BASE)-%.depend:    $(MANIFEST_BASE)-%.mangled
35a012 384     $(PKGDEPEND) generate $(PKGDEPEND_GENERATE_OPTIONS) $< >$@
6514ee 385
4505fe 386 # pkgdepend resolve builds a map of all installed packages by default.  This
RL 387 # makes dependency resolution particularly slow.  We can dramatically improve
388 # performance here by creating a file with a list of packages that we know
389 # are needed, dramatically reducing the overhead involved in creating and
390 # searching this map.
391 #
392 # Generate a resolve.deps file from the dependencies in the Makefile and
393 # fragments that it uses.
394 RESOLVE_DEPS=$(BUILD_DIR)/resolve.deps
9f160e 395
c0099a 396 $(RESOLVE_DEPS):    Makefile $(BUILD_DIR) $(DEPENDED)
AP 397     @(for pkg in $(REQUIRED_PACKAGES:%=/%) ; do \
4505fe 398         echo $${pkg} ; \
c0099a 399     done ; \
AP 400     $(PKGMOGRIFY) $(WS_TRANSFORMS)/PRINT_COMPONENT_FMRIS $(DEPENDED) | \
401         $(GSED) -e '/^[\t ]*$$/d' -e '/^#/d' ;) | sort -u >$@
9f160e 402
93b18c 403 # resolve the dependencies all at once
4505fe 404 $(BUILD_DIR)/.resolved-$(MACH):    $(DEPENDED) $(RESOLVE_DEPS)
RL 405     $(PKGDEPEND) resolve $(RESOLVE_DEPS:%=-e %) -m $(DEPENDED)
d05a6f 406     $(TOUCH) $@
NJ 407
e6ade5 408 # Set REQUIRED_PACKAGES macro substitution rules
AL 409 REQUIRED_PACKAGES_TRANSFORM=$(foreach p,$(REQUIRED_PACKAGES_SUBST), -e 's|$($(p))|$$($(p))|')
410
d180f2 411 #
412 # Generate a set of REQUIRED_PACKAGES based on what is needed to for pkgdepend
413 # to resolve properly.  Automatically append this to your Makefile for the truly
414 # lazy among us.  This is only a piece of the REQUIRED_PACKAGES puzzle.
415 # You must still include packages for tools you build and test with.
416 #
417 REQUIRED_PACKAGES::     $(RESOLVED)
4d720d 418     $(GMAKE) RESOLVE_DEPS= $(BUILD_DIR)/.resolved-$(MACH)
b80d3d 419     @echo "# Auto-generated dependencies" >>Makefile
4d720d 420     @$(PKGMOGRIFY) $(WS_TRANSFORMS)/$@ $(RESOLVED) | \
e6ade5 421         $(GSED) -e '/^[\t ]*$$/d' -e '/^#/d' $(REQUIRED_PACKAGES_TRANSFORM) \
AL 422             | sort -u >>Makefile
4d720d 423     @echo "*** Please edit your Makefile and verify the new content at the end ***"
d180f2 424
425
d05a6f 426 # lint the manifests all at once
NJ 427 $(BUILD_DIR)/.linted-$(MACH):    $(BUILD_DIR)/.resolved-$(MACH)
428     @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
6185b3 429     $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)" $(COMPONENT_PKGLINT_ENV)\
694ef3 430         $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
d05a6f 431             -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
NJ 432     $(TOUCH) $@
433
0f1b63 434 lintme: FRC
AC 435     @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
6185b3 436     $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)" $(COMPONENT_PKGLINT_ENV)\
0f1b63 437         $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
AC 438             -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
439
440 FRC:
441
3dc823 442
ade6bb 443 # published
69d0f5 444 PKGSEND_PUBLISH_OPTIONS = -s $(WS_REPO) publish --fmri-in-manifest
35a012 445 PKGSEND_PUBLISH_OPTIONS += $(PKG_PROTO_DIRS:%=-d %)
abb76c 446 PKGSEND_PUBLISH_OPTIONS += -T \*.py
4221e1 447
JK 448 # Do all the hard work that is needed to ensure the package is consistent
449 # and ready for publishing, except actually pushing bits to a repository
450 $(MANIFEST_BASE)-%.pre-published:    $(MANIFEST_BASE)-%.depend.res $(BUILD_DIR)/.linted-$(MACH)
451     $(CP) $< $@
452     @echo "NEW PACKAGE CONTENTS ARE LOCALLY VALIDATED AND READY TO GO"
453
454 # Push to the repo
455 $(MANIFEST_BASE)-%.published:    $(MANIFEST_BASE)-%.pre-published
35a012 456     $(PKGSEND) $(PKGSEND_PUBLISH_OPTIONS) $<
ade6bb 457     $(PKGFMT) <$< >$@
4221e1 458
JK 459 $(BUILD_DIR)/.pre-published-$(MACH):    $(PRE_PUBLISHED)
460     $(TOUCH) $@
6514ee 461
d05a6f 462 $(BUILD_DIR)/.published-$(MACH):    $(PUBLISHED)
6514ee 463     $(TOUCH) $@
NJ 464
a325d4 465 print-package-names:    canonical-manifests
5ada66 466     @cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-pkgs | \
a325d4 467         $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
4221e1 468         sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
a325d4 469
NJ 470 print-package-paths:    canonical-manifests
5ada66 471     @cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
a325d4 472         $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
4221e1 473         sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
a325d4 474
3dc823 475 install-packages:    publish
NJ 476     @if [ $(IS_GLOBAL_ZONE) = 0 -o x$(ROOT) != x ]; then \
5ada66 477         cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
4221e1 478         $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
JK 479         sed -e '/^$$/d' -e '/^#.*$$/d' -e 's;/;;' | sort -u | \
480         (cd $(PROTO_DIR) ; pfexec /bin/cpio -dump $(ROOT)) ; \
481      else ; \
3dc823 482         echo "unsafe to install package(s) automatically" ; \
4221e1 483      fi
3dc823 484
86e587 485 $(RESOLVED):    install
3dc823 486
NJ 487 canonical-manifests:    $(CANONICAL_MANIFESTS) Makefile $(PATCHES)
6514ee 488 ifeq    ($(strip $(CANONICAL_MANIFESTS)),)
NJ 489     # If there were no canonical manifests in the workspace, nothing will
490     # be published and we should fail.  A sample manifest can be generated
491     # with
492     #   $ gmake sample-manifest
493     # Once created, it will need to be reviewed, edited, and added to the
494     # workspace.
495     $(error Missing canonical manifest(s))
496 endif
a325d4 497
NJ 498 # This converts required paths to containing package names for be able to
499 # properly setup the build environment for a component.
500 required-pkgs.mk:    Makefile
501     @echo "generating $@ from Makefile REQUIRED_* data"
502     @pkg search -H -l '<$(DEPENDS:%=% OR) /bin/true>' \
503         | sed -e 's/pkg:\/\(.*\)@.*/REQUIRED_PKGS += \1/g' >$@
504
3dc823 505 pre-prep:    required-pkgs.mk
NJ 506
507
a325d4 508 CLEAN_PATHS +=    required-pkgs.mk
525ed1 509 CLEAN_PATHS +=    $(BUILD_DIR)/mkgeneric-perl
AP 510 CLEAN_PATHS +=    $(BUILD_DIR)/mkgeneric-python
511 CLEAN_PATHS +=    $(BUILD_DIR)/mkgeneric-ruby