gstreamer: previous fix for bison 3 compilation led to crash
[unleashed-userland.git] / make-rules / ips.mk
blobcd19c83de6ac9d051740940600a094b396d00aeb
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) 2010, 2013, 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)
39 PKGDEPEND = /usr/bin/pkgdepend
40 PKGFMT = /usr/bin/pkgfmt
41 PKGMOGRIFY = /usr/bin/pkgmogrify
42 PKGSEND = /usr/bin/pkgsend
43 ifeq ($(strip $(PKGLINT_COMPONENT)),)
44 PKGLINT = /usr/bin/pkglint
45 else
46 PKGLINT = ${WS_TOOLS}/pkglint
47 endif
48 PKGMANGLE = $(WS_TOOLS)/userland-mangler
50 WS_TRANSFORMS = $(WS_TOP)/transforms
52 GENERATE_HISTORY= $(WS_TOOLS)/generate-history
53 HISTORY= history
55 # Package headers should all pretty much follow the same format
56 METADATA_TEMPLATE = $(WS_TOP)/transforms/manifest-metadata-template
57 COPYRIGHT_TEMPLATE = $(WS_TOP)/transforms/copyright-template
59 # order is important
60 GENERATE_TRANSFORMS += $(WS_TOP)/transforms/generate-cleanup
62 PKGMOGRIFY_TRANSFORMS += $(WS_TOP)/transforms/libtool-drop
63 PKGMOGRIFY_TRANSFORMS += $(WS_TOP)/transforms/ignore-libs
65 COMPARISON_TRANSFORMS += $(WS_TOP)/transforms/comparison-cleanup
66 COMPARISON_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
68 LICENSE_TRANSFORMS = $(WS_TOP)/transforms/license-changes
70 # order is important
71 PUBLISH_TRANSFORMS += $(LICENSE_TRANSFORMS)
72 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/variant-cleanup
73 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/autopyc
74 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/defaults
75 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/actuators
76 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/devel
77 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/docs
78 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/locale
79 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/python-3-soabi
80 PUBLISH_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
81 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/publish-cleanup
83 ifeq ($(strip $(COMPONENT_AUTOGEN_MANIFEST)),yes)
84 AUTOGEN_MANIFEST_TRANSFORMS += $(WS_TOP)/transforms/generate-cleanup
85 else
86 AUTOGEN_MANIFEST_TRANSFORMS += $(WS_TOP)/transforms/drop-all
87 endif
89 PKG_MACROS += MACH=$(MACH)
90 PKG_MACROS += MACH32=$(MACH32)
91 PKG_MACROS += MACH64=$(MACH64)
92 PKG_MACROS += PUBLISHER=$(PUBLISHER)
93 PKG_MACROS += PUBLISHER_LOCALIZABLE=$(PUBLISHER_LOCALIZABLE)
94 PKG_MACROS += CONSOLIDATION=$(CONSOLIDATION)
95 PKG_MACROS += BUILD_VERSION=$(BUILD_VERSION)
96 PKG_MACROS += SOLARIS_VERSION=$(SOLARIS_VERSION)
97 PKG_MACROS += OS_VERSION=$(OS_VERSION)
98 PKG_MACROS += PKG_SOLARIS_VERSION=$(PKG_SOLARIS_VERSION)
99 PKG_MACROS += HUMAN_VERSION=$(HUMAN_VERSION)
100 PKG_MACROS += IPS_COMPONENT_VERSION=$(IPS_COMPONENT_VERSION)
101 PKG_MACROS += COMPONENT_VERSION=$(COMPONENT_VERSION)
102 PKG_MACROS += COMPONENT_PROJECT_URL=$(COMPONENT_PROJECT_URL)
103 PKG_MACROS += COMPONENT_ARCHIVE_URL=$(COMPONENT_ARCHIVE_URL)
104 PKG_MACROS += COMPONENT_HG_URL=$(COMPONENT_HG_URL)
105 PKG_MACROS += COMPONENT_HG_REV=$(COMPONENT_HG_REV)
106 PKG_MACROS += COMPONENT_NAME=$(COMPONENT_NAME)
107 PKG_MACROS += COMPONENT_FMRI=$(COMPONENT_FMRI)
108 PKG_MACROS += COMPONENT_LICENSE_FILE=$(COMPONENT_LICENSE_FILE)
109 PKG_MACROS += TPNO=$(TPNO)
110 PKG_MACROS += USERLAND_GIT_REMOTE=$(USERLAND_GIT_REMOTE)
111 PKG_MACROS += USERLAND_GIT_BRANCH=$(USERLAND_GIT_BRANCH)
112 PKG_MACROS += USERLAND_GIT_REV=$(USERLAND_GIT_REV)
114 PKG_OPTIONS += $(PKG_MACROS:%=-D %) \
115 -D COMPONENT_SUMMARY="$(strip $(COMPONENT_SUMMARY))" \
116 -D COMPONENT_CLASSIFICATION="org.opensolaris.category.2008:$(strip $(COMPONENT_CLASSIFICATION))" \
117 -D COMPONENT_DESCRIPTION="$(strip $(COMPONENT_DESCRIPTION))" \
118 -D COMPONENT_LICENSE="$(strip $(COMPONENT_LICENSE))"
120 MANGLED_DIR = $(PROTO_DIR)/mangled
122 PKG_PROTO_DIRS += $(MANGLED_DIR) $(PROTO_DIR) $(@D) $(COMPONENT_DIR) $(COMPONENT_SRC)
124 MANIFEST_BASE = $(BUILD_DIR)/manifest-$(MACH)
126 SAMPLE_MANIFEST_DIR = $(COMPONENT_DIR)/manifests
127 SAMPLE_MANIFEST_FILE = $(SAMPLE_MANIFEST_DIR)/sample-manifest.p5m
129 CANONICAL_MANIFESTS = $(wildcard *.p5m)
130 ifneq ($(wildcard $(HISTORY)),)
131 HISTORICAL_MANIFESTS = $(shell $(NAWK) -v FUNCTION=name -f $(GENERATE_HISTORY) < $(HISTORY))
132 endif
134 # Look for manifests which need to be duplicated for each version of python.
135 ifeq ($(findstring -PYVER,$(CANONICAL_MANIFESTS)),-PYVER)
136 UNVERSIONED_MANIFESTS = $(filter-out %-GENFRAG.p5m,$(filter-out %-PYVER.p5m,$(CANONICAL_MANIFESTS)))
137 PY_MANIFESTS = $(filter %-PYVER.p5m,$(CANONICAL_MANIFESTS))
138 PYV_MANIFESTS = $(foreach v,$(shell echo $(PYTHON_VERSIONS) | tr -d .),$(shell echo $(PY_MANIFESTS) | sed -e 's/-PYVER.p5m/-$(v).p5m/g'))
139 PYNV_MANIFESTS = $(shell echo $(PY_MANIFESTS) | sed -e 's/-PYVER//')
140 else
141 UNVERSIONED_MANIFESTS = $(CANONICAL_MANIFESTS)
142 endif
144 # Look for manifests which need to be duplicated for each version of perl.
145 ifeq ($(findstring -PERLVER,$(UNVERSIONED_MANIFESTS)),-PERLVER)
146 NOPERL_MANIFESTS = $(filter-out %-GENFRAG.p5m,$(filter-out %-PERLVER.p5m,$(UNVERSIONED_MANIFESTS)))
147 PERL_MANIFESTS = $(filter %-PERLVER.p5m,$(UNVERSIONED_MANIFESTS))
148 PERLV_MANIFESTS = $(foreach v,$(shell echo $(PERL_VERSIONS) | tr -d .),$(shell echo $(PERL_MANIFESTS) | sed -e 's/-PERLVER.p5m/-$(v).p5m/g'))
149 PERLNV_MANIFESTS = $(shell echo $(PERL_MANIFESTS) | sed -e 's/-PERLVER//')
150 else
151 NOPERL_MANIFESTS = $(UNVERSIONED_MANIFESTS)
152 endif
154 # Look for manifests which need to be duplicated for each version of ruby.
155 # NOPERL_MANIFESTS represents the manifests that are not Python or
156 # Perl manifests. Extract the Ruby Manifests from NOPERL_MANIFESTS.
157 # Any remaining manifests are stored in NONRUBY_MANIFESTS
158 ifeq ($(findstring -RUBYVER,$(NOPERL_MANIFESTS)),-RUBYVER)
159 NORUBY_MANIFESTS = $(filter-out %GENFRAG.p5m,\
160 $(filter-out %-RUBYVER.p5m,$(NOPERL_MANIFESTS)))
161 RUBY_MANIFESTS = $(filter %-RUBYVER.p5m,$(NOPERL_MANIFESTS))
162 RUBYV_MANIFESTS = $(foreach v,$(shell echo $(RUBY_VERSIONS)),\
163 $(shell echo $(RUBY_MANIFESTS) |\
164 sed -e 's/-RUBYVER.p5m/-$(shell echo $(v) |\
165 cut -d. -f1,2 | tr -d .).p5m/g'))
166 RUBYNV_MANIFESTS = $(shell echo $(RUBY_MANIFESTS) | sed -e 's/-RUBYVER//')
167 else
168 NORUBY_MANIFESTS = $(NOPERL_MANIFESTS)
169 endif
171 VERSIONED_MANIFESTS = \
172 $(PYV_MANIFESTS) $(PYNV_MANIFESTS) \
173 $(PERLV_MANIFESTS) $(PERLNV_MANIFESTS) \
174 $(RUBYV_MANIFESTS) $(RUBYNV_MANIFESTS) \
175 $(NORUBY_MANIFESTS) $(HISTORICAL_MANIFESTS)
177 GENERATED = $(MANIFEST_BASE)-generated
178 COMBINED = $(MANIFEST_BASE)-combined
179 MANIFESTS = $(VERSIONED_MANIFESTS:%=$(MANIFEST_BASE)-%)
182 DEPENDED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend)
183 RESOLVED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend.res)
184 PRE_PUBLISHED=$(RESOLVED:%.depend.res=%.pre-published)
185 PUBLISHED=$(RESOLVED:%.depend.res=%.published)
187 COPYRIGHT_FILE ?= $(COMPONENT_NAME)-$(COMPONENT_VERSION).copyright
188 IPS_COMPONENT_VERSION ?= $(COMPONENT_VERSION)
190 .DEFAULT: publish
192 .SECONDARY:
194 # allow publishing to be overridden, such as when
195 # a package is for one architecture only.
196 PRE_PUBLISH_STAMP ?= $(BUILD_DIR)/.pre-published-$(MACH)
197 PUBLISH_STAMP ?= $(BUILD_DIR)/.published-$(MACH)
199 # Do all that is needed to ensure the package is consistent for publishing,
200 # except actually pushing to a repo, separately from the push to the repo.
201 pre-publish: build install $(PRE_PUBLISH_STAMP)
202 publish: pre-publish $(PUBLISH_STAMP)
204 sample-manifest: $(GENERATED).p5m
206 $(GENERATED).p5m: install
207 [ ! -d $(SAMPLE_MANIFEST_DIR) ] && $(MKDIR) $(SAMPLE_MANIFEST_DIR) || true
208 $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR) | \
209 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(GENERATE_TRANSFORMS) | \
210 sed -e '/^$$/d' -e '/^#.*$$/d' -e '/^dir .*$$/d' \
211 -e '/\.la$$/d' -e '/\.pyo$$/d' -e '/usr\/lib\/python[23]\..*\.pyc$$/d' \
212 -e '/.*\/__pycache__\/.*/d' | \
213 $(PKGFMT) | \
214 cat $(METADATA_TEMPLATE) - | \
215 $(TEE) $@ $(SAMPLE_MANIFEST_FILE) >/dev/null
217 # copy the canonical manifest(s) to the build tree
218 $(MANIFEST_BASE)-%.generate: %.p5m canonical-manifests
219 cat $(METADATA_TEMPLATE) $< >$@
221 # The text of a transform that will emit a dependency conditional on the
222 # presence of a particular version of a runtime, which will then draw in the
223 # runtime-version-specific version of the package we're operating on. $(1) is
224 # the name of the runtime package, and $(2) is the version suffix.
225 mkgeneric = \
226 echo "<transform set name=pkg.fmri value=(?:pkg:/)?(.+)-\#\#\#@(.*)" \
227 "-> emit depend nodrop=true type=conditional" \
228 "predicate=$(1)-$(2) fmri=%<1>-$(2)@%<2>>" >> $@;
230 # Define and execute a macro that generates a rule to create a manifest for a
231 # python module specific to a particular version of the python runtime.
232 define python-manifest-rule
233 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-PYVER.p5m
234 $(PKGMOGRIFY) -D PYVER=$(1) -D PYV=$(shell echo $(1) | tr -d .) $$< > $$@
235 endef
236 $(foreach ver,$(PYTHON_VERSIONS),$(eval $(call python-manifest-rule,$(ver))))
238 # A rule to create a helper transform package for python, that will insert the
239 # appropriate conditional dependencies into a python library's
240 # runtime-version-generic package to pull in the version-specific bits when the
241 # corresponding version of python is on the system.
242 $(BUILD_DIR)/mkgeneric-python: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ)
243 $(RM) $@
244 $(foreach ver,$(shell echo $(PYTHON_VERSIONS) | tr -d .), \
245 $(call mkgeneric,runtime/python,$(ver)))
247 # Build Python version-wrapping manifests from the generic version.
248 $(MANIFEST_BASE)-%.p5m: %-PYVER.p5m $(BUILD_DIR)/mkgeneric-python
249 $(PKGMOGRIFY) -D PYV=### $(BUILD_DIR)/mkgeneric-python \
250 $(WS_TOP)/transforms/mkgeneric $< > $@
251 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
253 # Define and execute a macro that generates a rule to create a manifest for a
254 # perl module specific to a particular version of the perl runtime.
255 define perl-manifest-rule
256 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-PERLVER.p5m
257 $(PKGMOGRIFY) -D PERLVER=$(1) -D PLV=$(shell echo $(1) | tr -d .) \
258 -D PERL_ARCH=$(call PERL_ARCH_FUNC,$(PERL.$(1))) $$< > $$@
259 endef
260 $(foreach ver,$(PERL_VERSIONS),$(eval $(call perl-manifest-rule,$(ver))))
262 # A rule to create a helper transform package for perl, that will insert the
263 # appropriate conditional dependencies into a perl library's
264 # runtime-version-generic package to pull in the version-specific bits when the
265 # corresponding version of perl is on the system.
266 $(BUILD_DIR)/mkgeneric-perl: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ)
267 $(RM) $@
268 $(foreach ver,$(shell echo $(PERL_VERSIONS) | tr -d .), \
269 $(call mkgeneric,runtime/perl,$(ver)))
271 # Build Perl version-wrapping manifests from the generic version.
272 $(MANIFEST_BASE)-%.p5m: %-PERLVER.p5m $(BUILD_DIR)/mkgeneric-perl
273 $(PKGMOGRIFY) -D PLV=### $(BUILD_DIR)/mkgeneric-perl \
274 $(WS_TOP)/transforms/mkgeneric $< > $@
275 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
277 # Rule to generate historical manifests from the $(HISTORY) file.
278 define history-manifest-rule
279 $(MANIFEST_BASE)-$(1): $(HISTORY) $(BUILD_DIR)
280 $(NAWK) -v TARGET=$(1) -v FUNCTION=manifest -f $(GENERATE_HISTORY) < \
281 $(HISTORY) > $$@
282 endef
283 $(foreach mfst,$(HISTORICAL_MANIFESTS),$(eval $(call history-manifest-rule,$(mfst))))
285 # Define and execute a macro that generates a rule to create a manifest for a
286 # ruby module specific to a particular version of the ruby runtime.
287 # Creates build/manifest-*-modulename-##.p5m file where ## is replaced with
288 # the version number.
289 define ruby-manifest-rule
290 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).mogrified: \
291 PKG_MACROS += RUBY_VERSION=$(1) RUBY_LIB_VERSION=$(2) \
292 RUBYV=$(subst .,,$(1))
294 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-RUBYVER.p5m
295 if [ -f $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m ]; then \
296 cat $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m >> $$@; \
298 $(PKGMOGRIFY) -D RUBY_VERSION=$(1) -D RUBY_LIB_VERSION=$(2) \
299 -D RUBYV=$(shell echo $(1) | tr -d .) $$< > $$@
300 endef
301 $(foreach ver,$(RUBY_VERSIONS),\
302 $(eval $(call ruby-manifest-rule,$(shell echo $(ver) | \
303 cut -d. -f1,2),$(ver))))
305 # A rule to create a helper transform package for ruby, that will insert the
306 # appropriate conditional dependencies into a ruby library's
307 # runtime-version-generic package to pull in the version-specific bits when the
308 # corresponding version of ruby is on the system.
309 $(BUILD_DIR)/mkgeneric-ruby: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ)
310 $(RM) $@
311 $(foreach ver,$(RUBY_VERSIONS),\
312 $(call mkgeneric,runtime/ruby,$(shell echo $(ver) | \
313 cut -d. -f1,2 | tr -d .)))
315 # Build Ruby version-wrapping manifests from the generic version.
316 # Creates build/manifest-*-modulename.p5m file.
318 $(MANIFEST_BASE)-%.p5m: %-RUBYVER.p5m $(BUILD_DIR)/mkgeneric-ruby
319 $(PKGMOGRIFY) -D RUBYV=### $(BUILD_DIR)/mkgeneric-ruby \
320 $(WS_TOP)/transforms/mkgeneric $< > $@
321 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
323 ifeq ($(strip $(COMPONENT_AUTOGEN_MANIFEST)),yes)
324 # auto-generate file/directory list
325 $(MANIFEST_BASE)-%.generated: %.p5m $(BUILD_DIR)
326 (cat $(METADATA_TEMPLATE); \
327 $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR)) | \
328 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(AUTOGEN_MANIFEST_TRANSFORMS) | \
329 sed -e '/^$$/d' -e '/^#.*$$/d' | $(PKGFMT) | \
330 cat $< - >$@
332 # mogrify non-parameterized manifests
333 $(MANIFEST_BASE)-%.mogrified: %.generated
334 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
335 $(PUBLISH_TRANSFORMS) | \
336 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
338 # mogrify parameterized manifests
339 $(MANIFEST_BASE)-%.mogrified: $(MANIFEST_BASE)-%.generated
340 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
341 $(PUBLISH_TRANSFORMS) | \
342 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
343 else
344 # mogrify non-parameterized manifests
345 $(MANIFEST_BASE)-%.mogrified: %.p5m $(BUILD_DIR)
346 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
347 $(PUBLISH_TRANSFORMS) | \
348 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
350 # mogrify parameterized manifests
351 $(MANIFEST_BASE)-%.mogrified: $(MANIFEST_BASE)-%.p5m $(BUILD_DIR)
352 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
353 $(PUBLISH_TRANSFORMS) | \
354 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
355 endif
357 # mangle the file contents
358 $(BUILD_DIR) $(MANGLED_DIR):
359 $(MKDIR) $@
361 PKGMANGLE_OPTIONS = -D $(MANGLED_DIR) $(PKG_PROTO_DIRS:%=-d %)
362 $(MANIFEST_BASE)-%.mangled: $(MANIFEST_BASE)-%.mogrified $(MANGLED_DIR)
363 $(PKGMANGLE) $(PKGMANGLE_OPTIONS) -m $< >$@
365 # generate dependencies
366 PKGDEPEND_GENERATE_OPTIONS = -m $(PKG_PROTO_DIRS:%=-d %)
367 $(MANIFEST_BASE)-%.depend: $(MANIFEST_BASE)-%.mangled
368 $(PKGDEPEND) generate $(PKGDEPEND_GENERATE_OPTIONS) $< >$@
370 # These files should contain a list of packages that the component is known to
371 # depend on. Using resolve.deps is not required, but significantly speeds up
372 # the "pkg resolve" step.
373 # XXX existing pkg5 is too old for that
374 #EXTDEPFILES = $(wildcard $(sort $(addsuffix ../resolve.deps, $(dir $(DEPENDED)))))
376 # This is a target that should only be run by hand, and not something that
377 # .resolved-$(MACH) should depend on.
378 sample-resolve.deps:
379 echo "<transform depend type=(require|require-any) -> print %(fmri)>" > rd-trans
380 for i in build/*.depend; do \
381 $(PKGMOGRIFY) -O /dev/null $$i rd-trans | tr " " "\n" | sort -u > m1; \
382 $(PKGMOGRIFY) -O /dev/null $$i.res rd-trans | tr " " "\n" | sort -u > m2; \
383 comm -13 m1 m2; \
384 done | sed -e 's/@[^ ]*//g' -e 's,pkg:/,,g' | sort -u > resolve.deps
385 $(RM) rd-trans m1 m2
386 if [[ ! -s resolve.deps ]]; then \
387 echo "No computed dependencies found; removing empty resolve.deps."; \
388 $(RM) resolve.deps; \
392 # resolve the dependencies all at once
393 $(BUILD_DIR)/.resolved-$(MACH): $(DEPENDED)
394 $(PKGDEPEND) resolve $(EXTDEPFILES:%=-e %) -m $(DEPENDED)
395 $(TOUCH) $@
398 # Generate a set of REQUIRED_PACKAGES based on what is needed to for pkgdepend
399 # to resolve properly. Automatically append this to your Makefile for the truly
400 # lazy among us. This is only a piece of the REQUIRED_PACKAGES puzzle.
401 # You must still include packages for tools you build and test with.
403 REQUIRED_PACKAGES:: $(RESOLVED)
404 $(GMAKE) RESOLVE_DEPS= $(BUILD_DIR)/.resolved-$(MACH)
405 @echo "# Auto-generated contents below. Please manually verify and remove this comment" >>Makefile
406 @$(PKGMOGRIFY) $(WS_TRANSFORMS)/$@ $(RESOLVED) | \
407 $(GSED) -e '/^[\t ]*$$/d' -e '/^#/d' | sort -u >>Makefile
408 @echo "*** Please edit your Makefile and verify the new content at the end ***"
411 # lint the manifests all at once
412 $(BUILD_DIR)/.linted-$(MACH): $(BUILD_DIR)/.resolved-$(MACH)
413 @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
414 $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)" $(COMPONENT_PKGLINT_ENV)\
415 $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
416 -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
417 $(TOUCH) $@
419 lintme: FRC
420 @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
421 $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)" $(COMPONENT_PKGLINT_ENV)\
422 $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
423 -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
425 FRC:
428 # published
429 PKGSEND_PUBLISH_OPTIONS = -s $(WS_REPO) publish --fmri-in-manifest
430 PKGSEND_PUBLISH_OPTIONS += $(PKG_PROTO_DIRS:%=-d %)
431 PKGSEND_PUBLISH_OPTIONS += -T \*.py
433 # Do all the hard work that is needed to ensure the package is consistent
434 # and ready for publishing, except actually pushing bits to a repository
435 $(MANIFEST_BASE)-%.pre-published: $(MANIFEST_BASE)-%.depend.res $(BUILD_DIR)/.linted-$(MACH)
436 $(CP) $< $@
437 @echo "NEW PACKAGE CONTENTS ARE LOCALLY VALIDATED AND READY TO GO"
439 # Push to the repo
440 $(MANIFEST_BASE)-%.published: $(MANIFEST_BASE)-%.pre-published
441 $(PKGSEND) $(PKGSEND_PUBLISH_OPTIONS) $<
442 $(PKGFMT) <$< >$@
444 $(BUILD_DIR)/.pre-published-$(MACH): $(PRE_PUBLISHED)
445 $(TOUCH) $@
447 $(BUILD_DIR)/.published-$(MACH): $(PUBLISHED)
448 $(TOUCH) $@
450 print-package-names: canonical-manifests
451 @cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-pkgs | \
452 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
453 sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
455 print-package-paths: canonical-manifests
456 @cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
457 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
458 sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
460 install-packages: publish
461 @if [ $(IS_GLOBAL_ZONE) = 0 -o x$(ROOT) != x ]; then \
462 cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
463 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
464 sed -e '/^$$/d' -e '/^#.*$$/d' -e 's;/;;' | sort -u | \
465 (cd $(PROTO_DIR) ; pfexec /bin/cpio -dump $(ROOT)) ; \
466 else ; \
467 echo "unsafe to install package(s) automatically" ; \
470 $(RESOLVED): install
472 canonical-manifests: $(CANONICAL_MANIFESTS) Makefile $(PATCHES)
473 ifeq ($(strip $(CANONICAL_MANIFESTS)),)
474 # If there were no canonical manifests in the workspace, nothing will
475 # be published and we should fail. A sample manifest can be generated
476 # with
477 # $ gmake sample-manifest
478 # Once created, it will need to be reviewed, edited, and added to the
479 # workspace.
480 $(error Missing canonical manifest(s))
481 endif
483 # This converts required paths to containing package names for be able to
484 # properly setup the build environment for a component.
485 required-pkgs.mk: Makefile
486 @echo "generating $@ from Makefile REQUIRED_* data"
487 @pkg search -H -l '<$(DEPENDS:%=% OR) /bin/true>' \
488 | sed -e 's/pkg:\/\(.*\)@.*/REQUIRED_PKGS += \1/g' >$@
490 pre-prep: required-pkgs.mk
493 CLEAN_PATHS += required-pkgs.mk
494 CLEAN_PATHS += $(BUILD_DIR)/mkgeneric-perl
495 CLEAN_PATHS += $(BUILD_DIR)/mkgeneric-python
496 CLEAN_PATHS += $(BUILD_DIR)/mkgeneric-ruby