imagemagick: update to 7.1.1-41
[oi-userland.git] / make-rules / ips.mk
blob40a30221f81a6ad645aef8107ab0d6bc074c2539
2 # CDDL HEADER START
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.
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.
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]
19 # CDDL HEADER END
21 # Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
22 # Copyright 2014 Andrzej Szeszo. All rights reserved.
26 # Rules and Macros for generating an IPS package manifest and publishing an
27 # IPS package to a pkg depot.
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:
33 # install: $(BUILD_DIR)/build/$(MACH32)/.installed \
34 # $(BUILD_DIR)/build/$(MACH64)/.installed
36 # This set of rules makes the "publish" target the default target for make(1)
38 .NOTPARALLEL:
40 PKGDEPEND = /usr/bin/pkgdepend
41 PKGFMT = /usr/bin/pkgfmt
42 PKGMOGRIFY = /usr/bin/pkgmogrify
43 PKGSEND = /usr/bin/pkgsend
44 ifeq ($(strip $(PKGLINT_COMPONENT)),)
45 PKGLINT = /usr/bin/python /usr/bin/pkglint
46 else
47 PKGLINT = ${WS_TOOLS}/pkglint
48 endif
49 PKGMANGLE = $(WS_TOOLS)/userland-mangler
51 WS_TRANSFORMS = $(WS_TOP)/transforms
53 GENERATE_HISTORY= $(WS_TOOLS)/generate-history
54 HISTORY= history
56 # Package headers should all pretty much follow the same format
57 METADATA_TEMPLATE = $(WS_TOP)/transforms/manifest-metadata-template
58 COPYRIGHT_TEMPLATE = $(WS_TOP)/transforms/copyright-template
60 # order is important
61 GENERATE_TRANSFORMS += $(WS_TOP)/transforms/generate-cleanup
62 ifeq ($(strip $(DROP_STATIC_LIBRARIES)),yes)
63 GENERATE_TRANSFORMS += $(WS_TOP)/transforms/archive-libraries-drop
64 endif
66 PKGMOGRIFY_TRANSFORMS += $(WS_TOP)/transforms/libtool-drop
67 PKGMOGRIFY_TRANSFORMS += $(WS_TOP)/transforms/ignore-libs
68 PKGMOGRIFY_TRANSFORMS += $(WS_TOP)/transforms/ignore-gcc-usr-lib
70 LICENSE_TRANSFORMS = $(WS_TOP)/transforms/license-changes
72 # order is important
73 PUBLISH_TRANSFORMS += $(LICENSE_TRANSFORMS)
74 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/variant-cleanup
75 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/autopyc
76 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/python
77 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/perl
78 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/defaults
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
83 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/python-3-soabi
84 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/python-3-no-32bit
85 PUBLISH_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
86 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/publish-cleanup
88 FINAL_TRANSFORMS += $(WS_TOP)/transforms/final-cleanup
90 define add-limiting-variable
91 PKG_VARS += $(1)
92 MANIFEST_LIMITING_VARS += -D $(1)="$(subst #,\#,$($(1)))"
93 endef
95 # Make all the limiting variables available to manifest processing
96 $(foreach var, $(filter PY3_%_NAMING,$(.VARIABLES)), \
97 $(eval $(call add-limiting-variable,$(var))))
99 AUTOGEN_MANIFEST_TRANSFORMS += $(WS_TOP)/transforms/drop-all
101 # For items defined as variables or that may contain whitespace, add
102 # them to a list to be expanded into PKG_OPTIONS later.
103 PKG_VARS += MACH MACH32 MACH64
104 PKG_VARS += BUILD_VERSION OS_VERSION PKG_SOLARIS_VERSION
105 PKG_VARS += GNU_TRIPLET
106 PKG_VARS += GCC_GNU_TRIPLET
107 PKG_VARS += CONSOLIDATION
108 PKG_VARS += COMPONENT_VERSION IPS_COMPONENT_VERSION HUMAN_VERSION
109 PKG_VARS += COMPONENT_ARCHIVE_URL COMPONENT_PROJECT_URL COMPONENT_NAME
110 PKG_VARS += COMPONENT_FMRI COMPONENT_LICENSE_FILE
111 PKG_VARS += COMPONENT_SUMMARY COMPONENT_DESCRIPTION COMPONENT_LICENSE
112 PKG_VARS += HG_REPO HG_REV HG_URL COMPONENT_HG_URL COMPONENT_HG_REV
113 PKG_VARS += GIT_COMMIT_ID GIT_REPO GIT_TAG
114 PKG_VARS += PUBLISHER PUBLISHER_LOCALIZABLE
115 PKG_VARS += USERLAND_GIT_REMOTE USERLAND_GIT_BRANCH USERLAND_GIT_REV
116 PKG_VARS += COMPONENT
118 # For items that need special definition, add them to PKG_MACROS.
119 # IPS_COMPONENT_VERSION suitable for use in regular expressions.
120 PKG_MACROS += IPS_COMPONENT_RE_VERSION=$(subst .,\\.,$(IPS_COMPONENT_VERSION))
121 # COMPONENT_VERSION suitable for use in regular expressions.
122 PKG_MACROS += COMPONENT_RE_VERSION=$(subst .,\\.,$(COMPONENT_VERSION))
123 # HUMAN_VERSION suitable for use in regular expressions.
124 PKG_MACROS += HUMAN_VERSION_RE=$(subst .,\\.,$(HUMAN_VERSION))
126 PKG_OPTIONS += $(PKG_MACROS:%=-D %) \
127 -D COMPONENT_CLASSIFICATION="org.opensolaris.category.2008:$(strip $(COMPONENT_CLASSIFICATION))"
129 define mach-list-generate-macros
130 ifeq ($(MACH),$(1))
131 PKG_MACROS += $(1)_ONLY=
132 PKG_MACROS += $(1)_EXCL=\#
133 else
134 PKG_MACROS += $(1)_ONLY=\#
135 PKG_MACROS += $(1)_EXCL=
136 endif
137 endef
138 $(foreach isa,$(MACH_LIST),$(eval $(call mach-list-generate-macros,$(isa))))
140 PKG_MACROS += GCCVER=$(GCC_VERSION)
141 PKG_MACROS += CLANGVER=$(CLANG_VERSION)
143 define python-generate-macros
144 PKG_MACROS += PYTHON_$(1)_ONLY=\#
145 PKG_MACROS += PYTHON_$(1)_EXCL=
146 endef
147 $(foreach ver,$(PYTHON_VERSIONS),$(eval $(call python-generate-macros,$(ver))))
149 PKG_MACROS += PYTHON_32_ONLY=
151 MANGLED_DIR = $(PROTO_DIR)/mangled
153 PKG_PROTO_DIRS += $(MANGLED_DIR) $(PROTO_DIR) $(@D) $(COMPONENT_DIR) $(COMPONENT_SRC)
155 MANIFEST_BASE = $(BUILD_DIR)/manifest-$(MACH)
157 SAMPLE_MANIFEST_DIR = $(COMPONENT_DIR)/manifests
158 SAMPLE_MANIFEST_FILE = $(SAMPLE_MANIFEST_DIR)/sample-manifest.p5m
160 CANONICAL_MANIFESTS = $(filter-out dummy.p5m %.ARCH.p5m,$(wildcard *.p5m))
161 ifneq ($(wildcard $(HISTORY)),)
162 HISTORICAL_MANIFESTS = $(shell $(NAWK) -v FUNCTION=name -f $(GENERATE_HISTORY) < $(HISTORY))
163 endif
165 # Support for arch specific manifests
166 ARCH_MANIFESTS = $(wildcard *.p5m.$(MACH))
167 GENERATED_ARCH_MANIFESTS = $(ARCH_MANIFESTS:%.p5m.$(MACH)=%.ARCH.p5m)
168 CANONICAL_MANIFESTS += $(GENERATED_ARCH_MANIFESTS)
170 %.ARCH.p5m: %.p5m.$(MACH)
171 $(CP) $< $@
173 define ips-print-depend-require-rule
174 $(shell cat $(1) $(WS_TOP)/transforms/print-depend-require |\
175 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 |\
176 sed -e '/^$$/d' -e '/^#.*$$/d' | $(SORT) -u)
177 endef
179 define ips-print-depend-require-versioned-rule
180 $(foreach v,$($(1)V_VALUES),\
181 $(shell cat $(2) $(WS_TOP)/transforms/print-pkgs |\
182 $(PKGMOGRIFY) $(PKG_OPTIONS) -D $($(1)V_FMRI_VERSION)=$(v) /dev/fd/0 |\
183 sed -e '/^$$/d' -e '/^#.*$$/d' | $(SORT) -u))
184 endef
186 define ips-print-depend-require-type-rule
187 $(foreach m,$($(1)_MANIFESTS),$(call ips-print-depend-require-versioned-rule,$(1),$(m)))
188 endef
190 define ips-print-names-rule
191 $(shell cat $(1) $(WS_TOP)/transforms/print-pkgs |\
192 $(PKGMOGRIFY) $(PKG_OPTIONS) $(call per-manifest-options,$(1:.p5m=)) /dev/fd/0 |\
193 sed -e '/^$$/d' -e '/^#.*$$/d' | $(SORT) -u)
194 endef
196 define ips-print-names-versioned-rule
197 $(foreach v,$($(1)V_VALUES),\
198 $(shell cat $(2) $(WS_TOP)/transforms/print-pkgs |\
199 $(PKGMOGRIFY) $(PKG_OPTIONS) -D $($(1)V_FMRI_VERSION)=$(v) /dev/fd/0 |\
200 sed -e '/^$$/d' -e '/^#.*$$/d' | $(SORT) -u))
201 endef
204 # In addition to the concrete per-version packages, we also need to emit the
205 # name of the generic package which pulls in the concrete packages.
207 define ips-print-names-generic-rule
208 $(shell cat $(2) $(WS_TOP)/transforms/mkgeneric $(BUILD_DIR)/mkgeneric-python \
209 $(WS_TOP)/transforms/print-pkgs |\
210 $(PKGMOGRIFY) $(PKG_OPTIONS) -D $($(1)V_FMRI_VERSION)=\#\#\# /dev/fd/0 |\
211 sed -e '/^$$/d' -e '/^#.*$$/d' | $(SORT) -u)
212 endef
214 define ips-print-names-type-rule
215 $(foreach m,$($(1)_MANIFESTS),\
216 $(call ips-print-names-versioned-rule,$(1),$(m))\
217 $(call ips-print-names-generic-rule,$(1),$(m))\
219 endef
221 VERSIONED_MANIFEST_TYPES =
222 UNVERSIONED_MANIFESTS = $(filter-out %-GENFRAG.p5m, $(CANONICAL_MANIFESTS))
224 # Look for manifests which need to be duplicated for each version of python.
225 ifeq ($(findstring -PYVER,$(CANONICAL_MANIFESTS)),-PYVER)
226 VERSIONED_MANIFEST_TYPES+= PY
227 NOPY_MANIFESTS = $(filter-out %-PYVER.p5m,$(UNVERSIONED_MANIFESTS))
228 PY_MANIFESTS = $(filter %-PYVER.p5m,$(CANONICAL_MANIFESTS))
229 PYV_VALUES = $(subst .,,$(PYTHON_VERSIONS))
230 PYV_FMRI_VERSION = PYV
231 PYV_MANIFESTS = $(foreach v,$(PYV_VALUES),$(PY_MANIFESTS:-PYVER.p5m=-$(v).p5m))
232 PYNV_MANIFESTS = $(PY_MANIFESTS:-PYVER.p5m=.p5m)
233 MKGENERIC_SCRIPTS += $(BUILD_DIR)/mkgeneric-python
234 else
235 NOPY_MANIFESTS = $(UNVERSIONED_MANIFESTS)
236 endif
238 # PYTHON_PYV_VALUES contains list of all possible PYV values we could encounter:
239 # - for all currently supported python versions (from PYTHON_VERSIONS)
240 # - for all python versions we are currently obsoleting (from PYTHON_VERSIONS_OBSOLETING)
241 # - the $(PYV) string itself
242 PYTHON_PYV_VALUES = $(subst .,,$(PYTHON_VERSIONS) $(PYTHON_VERSIONS_OBSOLETING)) $$(PYV)
243 # Convert REQUIRED_PACKAGES to PYTHON_REQUIRED_PACKAGES for runtime/python
244 REQUIRED_PACKAGES_TRANSFORM += $(foreach v,$(subst $,\$,$(PYTHON_PYV_VALUES)),-e 's|^\(.*runtime/python\)-$(v)$$|PYTHON_\1|g')
245 # Convert REQUIRED_PACKAGES to PYTHON_REQUIRED_PACKAGES for library/python/*
246 REQUIRED_PACKAGES_TRANSFORM += $(foreach v,$(subst $,\$,$(PYTHON_PYV_VALUES)),-e 's|^\(.*library/python/.*\)-$(v)$$|PYTHON_\1|g')
248 # Look for manifests which need to be duplicated for each version of perl.
249 ifeq ($(findstring -PERLVER,$(UNVERSIONED_MANIFESTS)),-PERLVER)
250 VERSIONED_MANIFEST_TYPES+= PERL
251 NOPERL_MANIFESTS = $(filter-out %-PERLVER.p5m,$(NOPY_MANIFESTS))
252 PERL_MANIFESTS = $(filter %-PERLVER.p5m,$(UNVERSIONED_MANIFESTS))
253 PERLV_VALUES = $(subst .,,$(PERL_VERSIONS))
254 PERLV_FMRI_VERSION = PLV
255 PERLV_MANIFESTS = $(foreach v,$(PERLV_VALUES),$(PERL_MANIFESTS:-PERLVER.p5m=-$(v).p5m))
256 PERLNV_MANIFESTS = $(PERL_MANIFESTS:-PERLVER.p5m=.p5m)
257 else
258 NOPERL_MANIFESTS = $(NOPY_MANIFESTS)
259 endif
261 # PERL_PLV_VALUES contains list of all possible PLV values we could encounter:
262 # - for all currently supported perl versions (from PERL_VERSIONS)
263 # - for all perl versions we are currently obsoleting (from PERL_VERSIONS_OBSOLETING)
264 # - the $(PLV) string itself
265 PERL_PLV_VALUES = $(subst .,,$(PERL_VERSIONS) $(PERL_VERSIONS_OBSOLETING)) $$(PLV)
266 # Convert REQUIRED_PACKAGES to PERL_REQUIRED_PACKAGES for runtime/perl
267 REQUIRED_PACKAGES_TRANSFORM += $(foreach v,$(subst $,\$,$(PERL_PLV_VALUES)),-e 's|^\(.*runtime/perl\)-$(v)$$|PERL_\1|g')
268 # Convert REQUIRED_PACKAGES to PERL_REQUIRED_PACKAGES for library/perl-5/*
269 REQUIRED_PACKAGES_TRANSFORM += $(foreach v,$(subst $,\$,$(PERL_PLV_VALUES)),-e 's|^\(.*library/perl-5/.*\)-$(v)$$|PERL_\1|g')
271 # Look for manifests which need to be duplicated for each version of ruby.
272 # NOPERL_MANIFESTS represents the manifests that are not Python or
273 # Perl manifests. Extract the Ruby Manifests from NOPERL_MANIFESTS.
274 # Any remaining manifests are stored in NONRUBY_MANIFESTS
275 ifeq ($(findstring -RUBYVER,$(NOPERL_MANIFESTS)),-RUBYVER)
276 VERSIONED_MANIFEST_TYPES+= RUBY
277 NORUBY_MANIFESTS = $(filter-out %-RUBYVER.p5m,$(NOPERL_MANIFESTS))
278 RUBY_MANIFESTS = $(filter %-RUBYVER.p5m,$(NOPERL_MANIFESTS))
279 RUBYV_VALUES = $(RUBY_VERSIONS)
280 RUBYV_FMRI_VERSION = RUBYV
281 RUBYV_MANIFESTS = $(foreach v,$(RUBY_VERSIONS),$(RUBY_MANIFESTS:-RUBYVER.p5m=-$(subst $(space),,$(wordlist 1,2,$(subst ., ,$(v)))).p5m))
282 RUBYNV_MANIFESTS = $(RUBY_MANIFESTS:-RUBYVER.p5m=.p5m)
283 else
284 NORUBY_MANIFESTS = $(NOPERL_MANIFESTS)
285 endif
287 NONVER_MANIFESTS = $(NORUBY_MANIFESTS)
289 VERSIONED_MANIFESTS = \
290 $(PYV_MANIFESTS) $(PYNV_MANIFESTS) \
291 $(PERLV_MANIFESTS) $(PERLNV_MANIFESTS) \
292 $(RUBYV_MANIFESTS) $(RUBYNV_MANIFESTS) \
293 $(NORUBY_MANIFESTS)
295 GENERATED = $(MANIFEST_BASE)-generated
296 COMBINED = $(MANIFEST_BASE)-combined
297 MANIFESTS = $(VERSIONED_MANIFESTS:%=$(MANIFEST_BASE)-%)
300 DEPENDED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend)
301 RESOLVED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend.res)
302 PRE_PUBLISHED=$(RESOLVED:%.depend.res=%.pre-published)
303 PUBLISHED=$(RESOLVED:%.depend.res=%.published)
305 PUBLISHED += $(HISTORICAL_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.published)
307 COPYRIGHT_FILE ?= $(COMPONENT_NAME)-$(COMPONENT_VERSION).copyright
308 IPS_COMPONENT_VERSION ?= $(COMPONENT_VERSION)
310 .DEFAULT: publish
312 .SECONDARY:
314 # allow publishing to be overridden, such as when
315 # a package is for one architecture only.
316 PRE_PUBLISH_STAMP ?= $(BUILD_DIR)/.pre-published-$(MACH)
317 PUBLISH_STAMP ?= $(BUILD_DIR)/.published-$(MACH)
319 # Do all that is needed to ensure the package is consistent for publishing,
320 # except actually pushing to a repo, separately from the push to the repo.
321 pre-publish: build install $(PRE_PUBLISH_STAMP)
322 publish: pre-publish update-metadata $(PUBLISH_STAMP)
324 sample-manifest: $(GENERATED).p5m
326 $(GENERATED).p5m: install $(GENERATE_EXTRA_DEPS)
327 $(MKDIR) $(SAMPLE_MANIFEST_DIR)
328 $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR) | \
329 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(GENERATE_TRANSFORMS) | \
330 $(GSED) -e '/^$$/d' -e '/^#.*$$/d' \
331 -e '/\.la$$/d' \
332 -e 's/$(subst .,\.,$(GNU_TRIPLET))/$$(GNU_TRIPLET)/g' | \
333 $(PKGFMT) -u | \
334 uniq | \
335 $(PKGFMT) | \
336 $(CAT) $(METADATA_TEMPLATE) - $(GENERATE_EXTRA_CMD) | \
337 $(TEE) $@ $(SAMPLE_MANIFEST_FILE) >/dev/null
339 # copy the canonical manifest(s) to the build tree
340 $(MANIFEST_BASE)-%.generate: %.p5m canonical-manifests
341 cat $(METADATA_TEMPLATE) $< >$@
343 # The text of a transform that will emit a dependency conditional on the
344 # presence of a particular version of a runtime, which will then draw in the
345 # runtime-version-specific version of the package we're operating on. $(1) is
346 # the name of the runtime package, and $(2) is the version suffix.
347 mkgeneric = \
348 echo "<transform set name=pkg.fmri value=(?:pkg:/)?(.+)-\#\#\#@(.*)" \
349 "-> emit depend nodrop=true type=conditional" \
350 "predicate=$(1)-$(2) fmri=%<1>-$(2)@%<2>>" >> $@;
352 mkgenericdep = \
353 ( echo -n "<transform set name=pkg.fmri value=(?:pkg:/)?(.+)-\#\#\#@(.*)" \
354 "-> emit depend nodrop=true type=require-any " ; \
355 for i in $(2); do echo -n "fmri=%<1>-$$i@%<2> " ; done ; \
356 echo ">" ) >> $@
358 # Define and execute a macro that generates a rule to create a manifest for a
359 # python module specific to a particular version of the python runtime.
360 define python-manifest-rule
361 $(MANIFEST_BASE)-%-$(2).mogrified: PKG_MACROS += PYTHON_$(1)_ONLY= PYTHON_$(1)_EXCL=\#
363 ifneq ($(filter $(1),$(PYTHON_64_ONLY_VERSIONS)),)
364 $(MANIFEST_BASE)-%-$(2).mogrified: PKG_MACROS += PYTHON_32_ONLY=\#
365 endif
367 $(MANIFEST_BASE)-%-$(2).p5m: %-PYVER.p5m
368 $(PKGMOGRIFY) -D PYVER=$(1) $(MANIFEST_LIMITING_VARS) -D PYV=$(2) $$< > $$@
369 endef
370 $(foreach ver,$(PYTHON_VERSIONS),$(eval $(call python-manifest-rule,$(ver),$(subst .,,$(ver)))))
372 ifeq ($(strip $(SINGLE_PYTHON_VERSION)),yes)
373 PKG_MACROS += PYVER=$(PYTHON_VERSION)
374 PKG_MACROS += PYV=$(subst .,,$(PYTHON_VERSION))
375 endif
377 # A rule to create a helper transform package for python, that will insert the
378 # appropriate conditional dependencies into a python library's
379 # runtime-version-generic package to pull in the version-specific bits when the
380 # corresponding version of python is on the system.
381 $(BUILD_DIR)/mkgeneric-python: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ) $(BUILD_DIR)
382 $(RM) $@
383 $(foreach ver,$(subst .,,$(PYTHON_VERSIONS)), \
384 $(call mkgeneric,runtime/python,$(ver)))
385 $(call mkgenericdep,runtime/python,$(subst .,,$(PYTHON_VERSIONS)))
387 # Build Python version-wrapping manifests from the generic version.
388 $(MANIFEST_BASE)-%.p5m: %-PYVER.p5m $(BUILD_DIR)/mkgeneric-python
389 $(PKGMOGRIFY) -D PYV=### $(BUILD_DIR)/mkgeneric-python \
390 $(WS_TOP)/transforms/mkgeneric $< > $@
391 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
393 # Define and execute a macro that generates a rule to create a manifest for a
394 # perl module specific to a particular version of the perl runtime.
395 define perl-manifest-rule
396 $(MANIFEST_BASE)-%-$(subst .,,$(1)).p5m: %-PERLVER.p5m
397 $(PKGMOGRIFY) -D PERLVER=$(1) -D PLV=$$(subst .,,$(1)) \
398 -D PERL_ARCH=$$(call PERL_ARCH_FUNC,$$(PERL.$(1))) $$< > $$@
399 endef
400 $(foreach ver,$(PERL_VERSIONS),$(eval $(call perl-manifest-rule,$(ver))))
402 ifeq ($(strip $(SINGLE_PERL_VERSION)),yes)
403 PKG_MACROS += PERLVER=$(PERL_VERSION)
404 PKG_MACROS += PLV=$(subst .,,$(PERL_VERSION))
405 endif
407 # A rule to create a helper transform package for perl, that will insert the
408 # appropriate conditional dependencies into a perl library's
409 # runtime-version-generic package to pull in the version-specific bits when the
410 # corresponding version of perl is on the system.
411 $(BUILD_DIR)/mkgeneric-perl: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ)
412 $(RM) $@
413 $(foreach ver,$(subst .,,$(PERL_VERSIONS)), \
414 $(call mkgeneric,runtime/perl,$(ver)))
415 $(call mkgenericdep,runtime/perl,$(subst .,,$(PERL_VERSIONS)))
417 # Build Perl version-wrapping manifests from the generic version.
418 $(MANIFEST_BASE)-%.p5m: %-PERLVER.p5m $(BUILD_DIR)/mkgeneric-perl
419 $(PKGMOGRIFY) -D PLV=### $(BUILD_DIR)/mkgeneric-perl \
420 $(WS_TOP)/transforms/mkgeneric $< > $@
421 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
423 # Rule to generate historical manifests from the $(HISTORY) file.
424 define history-manifest-rule
425 $(MANIFEST_BASE)-$(1): $(HISTORY) $(BUILD_DIR)
426 $(NAWK) -v TARGET=$(1) -v FUNCTION=manifest -f $(GENERATE_HISTORY) < \
427 $(HISTORY) > $$@
428 endef
429 $(foreach mfst,$(HISTORICAL_MANIFESTS),$(eval $(call history-manifest-rule,$(mfst))))
431 # Define and execute a macro that generates a rule to create a manifest for a
432 # ruby module specific to a particular version of the ruby runtime.
433 # Creates build/manifest-*-modulename-##.p5m file where ## is replaced with
434 # the version number.
435 define ruby-manifest-rule
436 $(MANIFEST_BASE)-%-$(subst .,,$(1)).mogrified: \
437 PKG_MACROS += RUBY_VERSION=$(1) RUBY_LIB_VERSION=$(2) \
438 RUBYV=$(subst .,,$(1))
440 $(MANIFEST_BASE)-%-$(subst .,,$(1)).p5m: %-RUBYVER.p5m
441 if [ -f $$*-$(subst .,,$(1))GENFRAG.p5m ]; then \
442 cat $$*-$(subst .,,$(1))GENFRAG.p5m >> $$@; \
444 $(PKGMOGRIFY) -D RUBY_VERSION=$(1) -D RUBY_LIB_VERSION=$(2) \
445 -D RUBYV=$(subst .,,$(1)) $$< > $$@
446 endef
447 $(foreach ver,$(RUBY_VERSIONS),\
448 $(eval $(call ruby-manifest-rule,$(subst $(space),.,$(wordlist 1,2,$(subst ., ,$(ver)))),$(ver))))
450 # A rule to create a helper transform package for ruby, that will insert the
451 # appropriate conditional dependencies into a ruby library's
452 # runtime-version-generic package to pull in the version-specific bits when the
453 # corresponding version of ruby is on the system.
454 $(BUILD_DIR)/mkgeneric-ruby: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ)
455 $(RM) $@
456 $(foreach ver,$(RUBY_VERSIONS),\
457 $(call mkgeneric,runtime/ruby,$(subst $(space),,$(wordlist 1,2,$(subst ., ,$(ver))))))
458 $(call mkgenericdep,runtime/ruby,$(subst $(space),,$(wordlist 1,2,$(subst ., ,$(RUBY_VERSIONS)))))
460 # Build Ruby version-wrapping manifests from the generic version.
461 # Creates build/manifest-*-modulename.p5m file.
463 $(MANIFEST_BASE)-%.p5m: %-RUBYVER.p5m $(BUILD_DIR)/mkgeneric-ruby
464 $(PKGMOGRIFY) -D RUBYV=### $(BUILD_DIR)/mkgeneric-ruby \
465 $(WS_TOP)/transforms/mkgeneric $< > $@
466 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
468 per-manifest-options = $(foreach var,$(PKG_VARS),$(if $($(var).$(1)),-D $(var)="$(strip $($(var).$(1)))")) \
469 $(if $(COMPONENT_CLASSIFICATION.$(1)),-D COMPONENT_CLASSIFICATION="org.opensolaris.category.2008:$(strip $(COMPONENT_CLASSIFICATION.$(1)))")
471 # mogrify non-parameterized manifests
472 $(MANIFEST_BASE)-%.mogrified: %.p5m $(BUILD_DIR) $(MAKEFILE_PREREQ)
473 $(PKGMOGRIFY) $(PKG_OPTIONS) $(call per-manifest-options,$*) $< \
474 $(PUBLISH_TRANSFORMS) | \
475 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
477 # mogrify parameterized manifests
478 $(MANIFEST_BASE)-%.mogrified: $(MANIFEST_BASE)-%.p5m $(BUILD_DIR) $(MAKEFILE_PREREQ)
479 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
480 $(PUBLISH_TRANSFORMS) | \
481 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
483 # mangle the file contents
484 $(BUILD_DIR) $(MANGLED_DIR):
485 $(MKDIR) $@
487 PKGMANGLE_OPTIONS = -D $(MANGLED_DIR) $(PKG_PROTO_DIRS:%=-d %)
488 ifeq ($(strip $(USE_CTF)),yes)
489 PKGMANGLE_OPTIONS += -c $(CTFCONVERT)
490 endif
491 $(MANIFEST_BASE)-%.mangled: $(MANIFEST_BASE)-%.mogrified $(MANGLED_DIR)
492 $(PKGMANGLE) $(PKGMANGLE_OPTIONS) -m $< >$@
494 # generate dependencies
495 PKGDEPEND_RUNPATH += '$$PKGDEPEND_RUNPATH'
496 PKGDEPEND_GENERATE_OPTIONS += -m
497 PKGDEPEND_GENERATE_OPTIONS += $(PKG_PROTO_DIRS:%=-d %)
498 PKGDEPEND_GENERATE_OPTIONS += $(PKGDEPEND_RUNPATH:%=-k %)
499 $(MANIFEST_BASE)-%.depend: $(MANIFEST_BASE)-%.mangled
500 $(PKGDEPEND) generate $(PKGDEPEND_GENERATE_OPTIONS) $< >$@
502 # pkgdepend resolve builds a map of all installed packages by default. This
503 # makes dependency resolution particularly slow. We can dramatically improve
504 # performance here by creating a file with a list of packages that we know
505 # are needed, dramatically reducing the overhead involved in creating and
506 # searching this map.
508 # Generate a resolve.deps file from the dependencies in the Makefile and
509 # fragments that it uses.
510 RESOLVE_DEPS=$(BUILD_DIR)/resolve.deps
512 $(RESOLVE_DEPS): Makefile $(BUILD_DIR) $(DEPENDED)
513 @(for pkg in $(REQUIRED_PACKAGES:%=/%) ; do \
514 echo $${pkg} ; \
515 done ; \
516 $(PKGMOGRIFY) $(WS_TRANSFORMS)/PRINT_COMPONENT_FMRIS $(DEPENDED) | \
517 $(GSED) -e '/^[\t ]*$$/d' -e '/^#/d' ;) | $(SORT) -u >$@
519 $(BUILD_DIR)/runtime-perl.p5m: $(WS_TOOLS)/runtime-perl.p5m
520 $(CP) $< $@
522 $(BUILD_DIR)/runtime-ruby.p5m: $(WS_TOOLS)/runtime-ruby.p5m
523 $(CP) $< $@
525 # resolve the dependencies all at once
526 $(BUILD_DIR)/.resolved-$(MACH): $(DEPENDED) $(RESOLVE_DEPS) $(BUILD_DIR)/runtime-perl.p5m $(BUILD_DIR)/runtime-ruby.p5m
527 $(PKGDEPEND) resolve $(RESOLVE_DEPS:%=-e %) -m $(DEPENDED) $(BUILD_DIR)/runtime-perl.p5m $(BUILD_DIR)/runtime-ruby.p5m
528 $(TOUCH) $@
530 # generate list of sed rules to filter out component's own packages from
531 # REQUIRED_PACKAGES list
532 $(BUILD_DIR)/filter-own-pkgs: $(DEPENDED)
533 $(PKGMOGRIFY) $(WS_TRANSFORMS)/PRINT_COMPONENT_FMRIS $(DEPENDED) \
534 | $(GSED) -e '/^[\t ]*$$/d' -e '/^#/d' -e 's/^\///g' -e 's/\//\\\//g' \
535 | $(SORT) -u \
536 | $(GSED) -e 's/^\(.*\)$$/\/^REQUIRED_PACKAGES += \1$$\/d/g' >$@
538 # Set REQUIRED_PACKAGES macro substitution rules
539 REQUIRED_PACKAGES_TRANSFORM += $(foreach p,$(REQUIRED_PACKAGES_SUBST), -e 's|$($(p))|$$($(p))|')
542 # Generate a set of REQUIRED_PACKAGES based on what is needed for pkgdepend to
543 # resolve properly. Automatically update the list in your Makefile for the
544 # truly lazy among us. This is only a piece of the REQUIRED_PACKAGES puzzle.
545 # You must still include packages for tools you build and test with.
547 REQUIRED_PACKAGES:: $(RESOLVED) $(REQUIRED_PACKAGES_RESOLVED) $(BUILD_DIR)/filter-own-pkgs $(REQUIRED_PACKAGES_EXTRA_DEPS)
548 $(GMAKE) RESOLVE_DEPS= $(BUILD_DIR)/.resolved-$(MACH)
549 @$(GSED) -i -e '/^# Auto-generated dependencies$$/,$$d' Makefile
550 @echo "# Auto-generated dependencies" >>Makefile
551 $(PKGMOGRIFY) $(WS_TRANSFORMS)/$@ $(RESOLVED) $(REQUIRED_PACKAGES_RESOLVED) \
552 | $(GSED) -e '/^[\t ]*$$/d' -e '/^#/d' \
553 | tr '|' '\n' \
554 | $(GSED) -e 's,pkg:/,,g' -e 's/@.*$$//g' \
555 -f $(BUILD_DIR)/filter-own-pkgs \
556 $(REQUIRED_PACKAGES_TRANSFORM) \
557 | $(SORT) -u >>Makefile
558 @echo "*** Please edit your Makefile and verify the new or updated content at the end ***"
561 # lint the manifests all at once
562 $(BUILD_DIR)/.linted-$(MACH): $(BUILD_DIR)/.resolved-$(MACH)
563 @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
564 $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)" $(COMPONENT_PKGLINT_ENV)\
565 $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
566 -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
567 $(TOUCH) $@
569 lintme: FRC
570 @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
571 $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)" $(COMPONENT_PKGLINT_ENV)\
572 $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
573 -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
575 FRC:
578 # published
579 PKGSEND_PUBLISH_OPTIONS = -s $(WS_REPO) publish --fmri-in-manifest
580 PKGSEND_PUBLISH_OPTIONS += $(PKG_PROTO_DIRS:%=-d %)
581 PKGSEND_PUBLISH_OPTIONS += -T \*.py
583 # Do all the hard work that is needed to ensure the package is consistent
584 # and ready for publishing, except actually pushing bits to a repository
585 $(MANIFEST_BASE)-%.pre-published: $(MANIFEST_BASE)-%.depend.res $(BUILD_DIR)/.linted-$(MACH)
586 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
587 $(FINAL_TRANSFORMS) | \
588 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
589 @echo "NEW PACKAGE CONTENTS ARE LOCALLY VALIDATED AND READY TO GO"
591 $(MANIFEST_BASE)-%.histogrified: $(MANIFEST_BASE)-%.p5m
592 $(PKGMOGRIFY) -D CONSOLIDATION="$(CONSOLIDATION)" $< > $@
594 # Push to the repo
595 $(MANIFEST_BASE)-%.published: $(MANIFEST_BASE)-%.pre-published
596 $(PKGSEND) $(PKGSEND_PUBLISH_OPTIONS) $<
597 $(PKGFMT) <$< >$@
599 $(MANIFEST_BASE)-%.published: $(MANIFEST_BASE)-%.histogrified
600 $(PKGSEND) -s $(PKG_REPO) publish --fmri-in-manifest --no-catalog $<
601 $(CP) $< $@
603 $(BUILD_DIR)/.pre-published-$(MACH): $(PRE_PUBLISHED)
604 $(TOUCH) $@
606 $(BUILD_DIR)/.published-$(MACH): $(PUBLISHED)
607 $(TOUCH) $@
609 print-depend-require: canonical-manifests
610 @echo $(call ips-print-depend-require-rule,$(NONVER_MANIFESTS)) \
611 $(foreach t,$(VERSIONED_MANIFEST_TYPES),$(call ips-print-depend-require-type-rule,$(t))) | tr ' ' '\n'
613 print-package-names: canonical-manifests $(MKGENERIC_SCRIPTS)
614 @echo $(foreach m,$(NONVER_MANIFESTS),\
615 $(call ips-print-names-rule,$(m))) \
616 $(foreach t,$(VERSIONED_MANIFEST_TYPES),\
617 $(call ips-print-names-type-rule,$(t))) \
618 | tr ' ' '\n' | $(SORT) -u
620 print-package-paths: canonical-manifests
621 @cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
622 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
623 sed -e '/^$$/d' -e '/^#.*$$/d' | \
624 $(SORT) -u
626 install-packages: publish
627 @if [ $(IS_GLOBAL_ZONE) = 0 -o x$(ROOT) != x ]; then \
628 cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
629 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
630 sed -e '/^$$/d' -e '/^#.*$$/d' -e 's;/;;' | \
631 $(SORT) -u | \
632 (cd $(PROTO_DIR) ; pfexec /bin/cpio -dump $(ROOT)) ; \
633 else ; \
634 echo "unsafe to install package(s) automatically" ; \
637 $(RESOLVED): install
639 canonical-manifests: $(CANONICAL_MANIFESTS) Makefile $(PATCHES)
640 ifeq ($(strip $(CANONICAL_MANIFESTS)),)
641 # If there were no canonical manifests in the workspace, nothing will
642 # be published and we should fail. A sample manifest can be generated
643 # with
644 # $ gmake sample-manifest
645 # Once created, it will need to be reviewed, edited, and added to the
646 # workspace.
647 $(error Missing canonical manifest(s))
648 endif
650 # Component variables are expanded directly to PKG_OPTIONS instead of via
651 # PKG_MACROS since the values may contain whitespace.
652 mkdefine = -D $(1)="$$(strip $(2))"
654 # Expand PKG_VARS into defines via PKG_OPTIONS.
655 $(foreach var, $(PKG_VARS), \
656 $(eval PKG_OPTIONS += $(call mkdefine,$(var),$$($(var)))) \
659 # This converts required paths to containing package names for be able to
660 # properly setup the build environment for a component.
661 required-pkgs.mk: Makefile
662 @echo "generating $@ from Makefile REQUIRED_* data"
663 @pkg search -H -l '<$(DEPENDS:%=% OR) /bin/true>' \
664 | sed -e 's/pkg:\/\(.*\)@.*/REQUIRED_PKGS += \1/g' >$@
666 pre-prep: required-pkgs.mk
669 CLEAN_PATHS += required-pkgs.mk
670 CLEAN_PATHS += $(BUILD_DIR)/mkgeneric-perl
671 CLEAN_PATHS += $(BUILD_DIR)/mkgeneric-python
672 CLEAN_PATHS += $(BUILD_DIR)/mkgeneric-ruby
673 CLEAN_PATHS += $(GENERATED_ARCH_MANIFESTS)