unleashed-userland README
[unleashed-userland.git] / components / Makefile
blob29ccf5831bffd2264b26171fc97a6eb240475104
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.
24 -include ../make-rules/shared-macros.mk
26 # for now, the assumption is we build any directory with a Makefile. This may
27 # not always be the case. If we build a new make-like tool to drive the upper
28 # level build, it may make different decisions and will need to include
29 # appropriate dependency information.
31 # components.mk is auto-generated by the build tools. It populates the
32 # COMPONENT_DIRS macro with a list of all directories in the workspace that
33 # contain a component.
34 $(WS_TOP)/components/$(ENCUMBERED)components.mk: components.whitelist
35 @echo "Generating component list..."
36 @$(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
37 | sed -e 's;^$(shell pwd)/;;' \
38 | /usr/bin/grep -f components.whitelist \
39 | sed -f components.ignore \
40 | sed -e 's;^;COMPONENT_DIRS += ;g' >$@
42 -include $(WS_TOP)/components/$(ENCUMBERED)components.mk
44 # depends.mk is auto-generated by concatenating 'depend.mk' files in each
45 # component directory.
46 $(WS_TOP)/components/$(ENCUMBERED)depends.mk: $(WS_TOP)/components/$(ENCUMBERED)components.mk
47 @echo "Generating component dependencies..."
48 @cat /dev/null $(shell $(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
49 | sed -e 's;^$(shell pwd)/;;g' \
50 | sed -f components.ignore \
51 | sed -e 's;$$;/depend.mk;g') >$@ \
52 2>/dev/null
54 -include $(WS_TOP)/components/$(ENCUMBERED)depends.mk
57 download: TARGET = download
58 prep: TARGET = prep
59 build: TARGET = build
60 install: TARGET = install
61 pre-publish: TARGET = pre-publish
62 publish: TARGET = publish
63 clean: TARGET = clean
64 clobber: TARGET = clobber
65 test: TARGET = test
66 component-hook: TARGET = component-hook
67 prep build install pre-publish publish test: TEMPLATE_ZONE=$(ZONE)
68 prep build install pre-publish publish test: LOG = >$(WS_LOGS)/$(@F).$(TARGET).log 2>&1
70 # turn off pkglint for the individual component builds.
71 ifeq ($(strip $(PKGLINT_COMPONENT)),)
72 publish: MAKEFLAGS += PKGLINT=/bin/true
73 endif
75 .DEFAULT: publish
77 build install pre-publish publish test: $(COMPONENT_DIRS)
79 COMPONENT_DIRS.nosetup = $(COMPONENT_DIRS:%=%.nosetup)
81 download prep: $(COMPONENT_DIRS.nosetup)
83 component-hook: $(COMPONENT_DIRS.nosetup)
85 clean: $(COMPONENT_DIRS.nosetup)
86 $(RM) $(WS_TOP)/components/$(ENCUMBERED)components.mk $(WS_TOP)/components/$(ENCUMBERED)depends.mk .profile
88 clobber: $(COMPONENT_DIRS.nosetup) clean
89 @cd $(WS_TOP)/tools ; echo "clobbering tools..." ; $(GMAKE) clobber
90 $(RM) -r $(WS_REPO) $(WS_LOGS) $(WS_LINT_CACHE)
93 setup: $(WS_LOGS) $(WS_REPO) tools $(WS_LINT_CACHE)
95 $(WS_LOGS):
96 $(MKDIR) $@
98 $(WS_REPO):
99 $(PKGREPO) create $(PKG_REPO)
100 $(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER)
101 $(PKGREPO) rebuild -s $(PKG_REPO)
102 # Not required for OI
103 # $(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER_LOCALIZABLE)
105 DUMMYPKG = "set name=fmri value=pkg:/dummy@0,$(BUILD_VERSION)\n"
106 DUMMYPKG += "set pkg.summary=dummy\n"
107 DUMMYPKG += "set org.opensolaris.consolidation=userland\n"
108 DUMMYPKG += "set info.classification=org.opensolaris.category.2008:System/Core"
110 $(WS_LINT_CACHE): $(WS_LOGS) tools
111 ifdef CANONICAL_REPO
112 @echo "Generating pkglint(1) cache from $(CANONICAL_REPO)..."
113 @(echo $(DUMMYPKG) | $(PKGLINT) \
114 -c $(WS_LINT_CACHE) -r $(CANONICAL_REPO) /dev/fd/0 \
115 >$(WS_LOGS)/naughty-canonical-repo-actions 2>&1 ; exit 0)
116 else
117 $(MKDIR) $(WS_LINT_CACHE)
118 endif
120 tools:
121 @cd $(WS_TOP)/tools ; echo "building tools..." ; $(GMAKE) clean setup
123 # $(WS_COMPONENTS) is the home directory for the zone user, so create a profile
124 # to pass a few things on to zone based builds
125 .profile:
126 echo "PATH=$(PATH)" >>$@
127 echo "WS_TOP=$(WS_TOP)" >>$@
128 echo "export PATH WS_TOP" >>$@
130 $(COMPONENT_DIRS): $(WS_LOGS) setup FORCE
131 @cd $@ && echo "$(TARGET) $@" && \
132 $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
133 $(@:%=--component %) --make $(TARGET) $(LOG)
135 incorporation:
136 $(eval COMPONENT_REVISION := $(shell git rev-list HEAD --count))
137 $(WS_TOOLS)/userland-incorporator --repository $(PKG_REPO) \
138 --version=0.$(OS_VERSION),$(BUILD_VERSION) -p $(PUBLISHER) \
139 -c $(CONSOLIDATION) --destdir=$(WS_MACH) $(INCORPORATE_WERROR)
140 for incorporation in $(WS_MACH)/*.p5m ; do \
141 $(PKGSEND) -s $(PKG_REPO) publish --fmri-in-manifest \
142 $${incorporation} ; \
143 done
146 publish:
147 $(PKGREPO) refresh -s $(PKG_REPO)
148 ifdef CANONICAL_REPO
149 @echo 'pkglinting all package manifests...'
150 @$(ENV) PYTHONPATH=$(WS_TOOLS)/python $(PKGLINT) \
151 -c $(WS_LINT_CACHE) -f $(WS_TOOLS)/pkglintrc \
152 $(shell find . -name 'manifest-*.published')
153 endif
155 $(COMPONENT_DIRS.nosetup): $(WS_LOGS) FORCE
156 @cd $(@:%.nosetup=%) && echo "$(TARGET) $(@:%.nosetup=%)" && \
157 $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
158 $(@:%.nosetup=--component %) --make $(TARGET) $(LOG)
160 FORCE: