Adam Števko
2017-03-02 313ffddffcc6d7fecc774ae4eef08f05a3fe7c6a
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 #
7bf47e 21 # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
9c75c0 22 #
NJ 23
6185b3 24 -include ../make-rules/shared-macros.mk
9c75c0 25
5ea840 26 # for now, the assumption is we build any directory with a Makefile.  This may
NJ 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.
30
a325d4 31 # components.mk is auto-generated by the build tools.  It populates the
NJ 32 # COMPONENT_DIRS macro with a list of all directories in the workspace that
33 # contain a component.
8de8f7 34 $(WS_TOP)/components/$(ENCUMBERED)components.mk:    # Makefile # $(WS_TOP)/components
a325d4 35     @echo "Generating component list..."
79b849 36     @$(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
499a59 37         | sed -e 's;^$(shell pwd)/;;' \
AS 38         | sed -f components.ignore \
39         | sed -e 's;^;COMPONENT_DIRS += ;g' >$@
a325d4 40
6185b3 41 -include $(WS_TOP)/components/$(ENCUMBERED)components.mk
a325d4 42
35879a 43 # depends.mk is auto-generated by concatenating 'depend.mk' files in each
SS 44 # component directory.
8de8f7 45 $(WS_TOP)/components/$(ENCUMBERED)depends.mk:     $(WS_TOP)/components/$(ENCUMBERED)components.mk
35879a 46     @echo "Generating component dependencies..."
8de8f7 47     @cat /dev/null $(shell $(BASS_O_MATIC) --workspace=$(WS_TOP) --components=paths \
499a59 48         | sed -e 's;^$(shell pwd)/;;g' \
AS 49         | sed -f components.ignore \
50         | sed -e 's;$$;/depend.mk;g') >$@ \
35879a 51         2>/dev/null
SS 52  
6185b3 53 -include $(WS_TOP)/components/$(ENCUMBERED)depends.mk
35879a 54
9c75c0 55
3dc823 56 download:        TARGET = download
NJ 57 prep:            TARGET = prep
58 build:            TARGET = build
59 install:        TARGET = install
b5b9c7 60 pre-publish:        TARGET = pre-publish
3dc823 61 publish:        TARGET = publish
NJ 62 clean:            TARGET = clean
63 clobber:        TARGET = clobber
874137 64 test:            TARGET = test
764663 65 component-hook:        TARGET = component-hook
b5b9c7 66 prep build install pre-publish publish test:    TEMPLATE_ZONE=$(ZONE)
AP 67 prep build install pre-publish publish test:    LOG = >$(WS_LOGS)/$(@F).$(TARGET).log 2>&1
9c75c0 68
a81d46 69 # turn off pkglint for the individual component builds.
048c87 70 ifeq   ($(strip $(PKGLINT_COMPONENT)),)
a81d46 71 publish:        MAKEFLAGS += PKGLINT=/bin/true
048c87 72 endif
a81d46 73
9c75c0 74 .DEFAULT:    publish
NJ 75
b5b9c7 76 build install pre-publish publish test: $(COMPONENT_DIRS)
9c75c0 77
79b849 78 COMPONENT_DIRS.nosetup =    $(COMPONENT_DIRS:%=%.nosetup)
9c75c0 79
b2b154 80 download prep:    $(COMPONENT_DIRS.nosetup)
b643a2 81
764663 82 component-hook:    $(COMPONENT_DIRS.nosetup)
NJ 83
b643a2 84 clean:        $(COMPONENT_DIRS.nosetup)
8de8f7 85     $(RM) $(WS_TOP)/components/$(ENCUMBERED)components.mk $(WS_TOP)/components/$(ENCUMBERED)depends.mk .profile
9c75c0 86
b643a2 87 clobber:    $(COMPONENT_DIRS.nosetup) clean
6185b3 88     @cd $(WS_TOP)/tools ; echo "clobbering tools..." ; $(GMAKE) clobber
70eebe 89     $(RM) -r $(WS_REPO) $(WS_LOGS) $(WS_LINT_CACHE)
7999b2 90
79b849 91
d08673 92 setup:    $(WS_LOGS) $(WS_REPO) tools $(WS_LINT_CACHE)
9c75c0 93
NJ 94 $(WS_LOGS):
95     $(MKDIR) $@
96
d08673 97 $(WS_REPO):
dd0336 98     $(PKGREPO) create $(PKG_REPO)
DD 99     $(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER)
313ffd 100     $(PKGREPO) rebuild -s $(PKG_REPO)
499a59 101 # Not required for OI
AS 102 #    $(PKGREPO) add-publisher -s $(PKG_REPO) $(PUBLISHER_LOCALIZABLE)
9c75c0 103
048c87 104 DUMMYPKG =  "set name=fmri value=pkg:/dummy@0,$(BUILD_VERSION)\n"
MS 105 DUMMYPKG += "set pkg.summary=dummy\n"
106 DUMMYPKG += "set org.opensolaris.consolidation=userland\n"
107 DUMMYPKG += "set info.classification=org.opensolaris.category.2008:System/Core"
108
7bf47e 109 $(WS_LINT_CACHE):    $(WS_LOGS) tools
d08673 110 ifdef CANONICAL_REPO
NJ 111     @echo "Generating pkglint(1) cache from $(CANONICAL_REPO)..."
048c87 112     @(echo $(DUMMYPKG) | $(PKGLINT) \
d08673 113         -c $(WS_LINT_CACHE) -r $(CANONICAL_REPO) /dev/fd/0 \
NJ 114         >$(WS_LOGS)/naughty-canonical-repo-actions 2>&1 ; exit 0)
115 else
116     $(MKDIR) $(WS_LINT_CACHE)
117 endif
118
80b1b4 119 tools:
6185b3 120     @cd $(WS_TOP)/tools ; echo "building tools..." ; $(GMAKE) clean setup
80b1b4 121
79b849 122 # $(WS_COMPONENTS) is the home directory for the zone user, so create a profile
NJ 123 # to pass a few things on to zone based builds
124 .profile:
125     echo "PATH=$(PATH)" >>$@
126     echo "WS_TOP=$(WS_TOP)" >>$@
127     echo "export PATH WS_TOP" >>$@
128
b643a2 129 $(COMPONENT_DIRS):    $(WS_LOGS) setup FORCE
3dc823 130     @cd $@ && echo "$(TARGET) $@" && \
79b849 131      $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
3dc823 132              $(@:%=--component %) --make $(TARGET) $(LOG)
79b849 133
10a7de 134 incorporation:
0838fd 135     $(eval COMPONENT_REVISION := $(shell git rev-list HEAD --count))
10a7de 136     $(WS_TOOLS)/userland-incorporator --repository $(PKG_REPO) \
AP 137       --version=0.$(OS_VERSION),$(BUILD_VERSION) -p $(PUBLISHER) \
138       -c $(CONSOLIDATION) --destdir=$(WS_MACH) $(INCORPORATE_WERROR)
139     for incorporation in $(WS_MACH)/*.p5m ; do \
140         $(PKGSEND) -s $(PKG_REPO) publish --fmri-in-manifest \
141                    $${incorporation} ; \
142     done
143
144
a81d46 145 publish:
10a7de 146     $(PKGREPO) refresh -s $(PKG_REPO)
a81d46 147 ifdef CANONICAL_REPO
NJ 148     @echo 'pkglinting all package manifests...'
149     @$(ENV) PYTHONPATH=$(WS_TOOLS)/python $(PKGLINT) \
150             -c $(WS_LINT_CACHE) -f $(WS_TOOLS)/pkglintrc \
151             $(shell find . -name 'manifest-*.published')
152 endif
153
b643a2 154 $(COMPONENT_DIRS.nosetup):    $(WS_LOGS) FORCE
3dc823 155     @cd $(@:%.nosetup=%) && echo "$(TARGET) $(@:%.nosetup=%)" && \
79b849 156      $(BASS_O_MATIC) $(TEMPLATE_ZONE:%=--template-zone %) \
3dc823 157              $(@:%.nosetup=--component %) --make $(TARGET) $(LOG)
9c75c0 158
NJ 159 FORCE: