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