This repository was archived by the owner on Sep 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmakefile
More file actions
218 lines (186 loc) · 8.99 KB
/
makefile
File metadata and controls
218 lines (186 loc) · 8.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# Version information
CROS_VERSION=49-7834
CROS_BRANCH=origin/master
CHAPS_VERSION_MAJOR=0
CHAPS_VERSION_MINOR=$(CROS_VERSION)
CHAPS_VERSION=$(CHAPS_VERSION_MAJOR).$(CHAPS_VERSION_MINOR)
DEB_REVISION=1
DEB_VERSION=$(CHAPS_VERSION)-$(DEB_REVISION)
# The following should match platform2/common-mk/BASE_VER
CHROMEBASE_VER=369476
GMOCK_VERSION=1.8.0
# Absolute location of the source tree
SRCDIR_REL=chaps-$(CHAPS_VERSION)
SRCDIR=$(CURDIR)/$(SRCDIR_REL)
# Output from Chaps build.
OUTDIR=$(SRCDIR)/out
# Package signing options
DPKGSIGN ?= --force-sign
all: version-check build
version-check: src_generate
@awk '/BASE_VER \?= / {if ($$3 != $(CHROMEBASE_VER)) {exit 1;}}' $(SRCDIR)/platform2/common-mk/common.mk
######################################
# Generate a source tree
src_generate: src_includes src_makefiles src_gmock src_chromebase src_libchromeos src_systemapi src_platform2 src_man src_debian
$(SRCDIR):
mkdir -p $@
# Copy across some include files from the build directory
src_includes: $(SRCDIR)/include/build/build_config.h $(SRCDIR)/include/trousers/scoped_tss_type.h $(SRCDIR)/include/testing/gtest/include/gtest/gtest_prod.h $(SRCDIR)/include/leveldb/memenv.h
$(SRCDIR)/include: | $(SRCDIR)
mkdir -p $@
$(SRCDIR)/include/build: | $(SRCDIR)/include
mkdir -p $@
$(SRCDIR)/include/trousers: | $(SRCDIR)/include
mkdir -p $@
$(SRCDIR)/include/leveldb: | $(SRCDIR)/include
mkdir -p $@
$(SRCDIR)/include/testing/gtest/include/gtest: | $(SRCDIR)/include
mkdir -p $@
# Build configuration file for Chromium source code build.
$(SRCDIR)/include/build/build_config.h: extrasrc/build_config.h | $(SRCDIR)/include/build
cp $< $@
# ChromiumOS's version of Trousers has an additional utility class to allow RAII use
# of TSS types. Include a local copy of this, as Chaps uses it.
$(SRCDIR)/include/trousers/scoped_tss_type.h: extrasrc/scoped_tss_type.h | $(SRCDIR)/include/trousers
cp $< $@
# Chromium includes <leveldb/memenv.h>. This requires an install of libleveldb-dev that has
# memenv support included; move this into a local leveldb/ subdirectory
$(SRCDIR)/include/leveldb/memenv.h: /usr/include/leveldb/helpers/memenv.h | $(SRCDIR)/include/leveldb
cp $< $@
# Chromium includes <include/testing/gtest/include/gtest/gtest_prod.h>, so have a local copy.
$(SRCDIR)/include/testing/gtest/include/gtest/gtest_prod.h: extrasrc/gtest_prod.h | $(SRCDIR)/include/testing/gtest/include/gtest
cp $< $@
# Copy across some build files from the build directory into source directory.
BUILDFILES=Makefile Sconstruct.libchrome Sconstruct.libchromeos
SRC_BUILDFILES=$(addprefix $(SRCDIR_REL)/, $(BUILDFILES))
src_makefiles: $(SRC_BUILDFILES)
$(SRCDIR_REL)/Makefile: extrasrc/Makefile | $(SRCDIR)
sed 's/@BASE_VER@/$(CHROMEBASE_VER)/' $< | sed 's/@GMOCK_VER@/$(GMOCK_VERSION)/' |\
sed 's/@CHAPS_VERSION_MAJOR@/$(CHAPS_VERSION_MAJOR)/' | sed s'/@CHAPS_VERSION_MINOR@/$(CHAPS_VERSION_MINOR)/' >$@
$(SRCDIR_REL)/Sconstruct.libchrome: extrasrc/Sconstruct.libchrome | $(SRCDIR)
cp $< $@
$(SRCDIR_REL)/Sconstruct.libchromeos: extrasrc/Sconstruct.libchromeos | $(SRCDIR)
cp $< $@
# Various parts of Chromium include gTest files. To ensure consistency, get a local
# copy of gMock and gTest (rather than picking up whatever version is installed).
GMOCK_URL=https://github.com/google/googletest/archive/release-$(GMOCK_VERSION).zip
GMOCK_DIR=$(SRCDIR)/googletest-release-$(GMOCK_VERSION)/googlemock
GTEST_DIR=$(SRCDIR)/googletest-release-$(GMOCK_VERSION)/googletest
src_gmock: $(GMOCK_DIR)/LICENSE
$(GMOCK_DIR)/LICENSE: | $(SRCDIR)
cd $(SRCDIR) && wget $(GMOCK_URL)
cd $(SRCDIR) && unzip -q release-$(GMOCK_VERSION).zip
rm $(SRCDIR)/release-$(GMOCK_VERSION).zip
touch $@
# Chaps relies on utility code from Chromium base libraries, at:
CHROMEBASE_GIT=https://chromium.googlesource.com/chromium/src/base.git
# The particular version of the Chromium base library required by platforms2/chaps
# is indicated by the BASE_VER value in platform2/common-mk/BASE_VER
# - http://crrev.com/$BASE_VER returns a 302-redirect to the corresponding Git commit
# in the Chromium source code at https://chromium.googlesource.com/chromium/src.
# Call this SHA_A
# - However, this is a commit-ID in the master src.git repository, which is huge.
# We're only interested in code under base/, which gets pulled into a separate
# (smaller) Git repo base.git.
# - Running `git log -n 1 $SHA_A base/` in the full src.git repo gives the SHA1
# for the last commit in src.git that affected base/ and so should also be present
# (as a copy) in base.git. Call this SHA_B.
# - Under base.git, running `git log --grep $SHA_B origin/master` gives the
# corresponding commit in the base.git tree. Call this SHA_C.
# - This $SHA_C hash value from base.git is used here.
CHROMEBASE_COMMIT=e428d62b50cf091c19750cd742c5cead7b1f55c7
src_chromebase: $(SRCDIR)/base/base64.h
$(SRCDIR)/base: | $(SRCDIR)
mkdir -p $@
$(SRCDIR)/base/base64.h: | $(SRCDIR)/base
git clone $(CHROMEBASE_GIT) $(SRCDIR)/base
cd $(SRCDIR)/base && git checkout $(CHROMEBASE_COMMIT)
# Chaps relies on utility code from libchromeos, at:
LIBCHROMEOS_GIT=https://android.googlesource.com/platform/external/libchromeos
# TODO(drysdale): figure out which commit/branch/tag of libchromeos goes with current code.
LIBCHROMEOS_COMMIT=origin/master
src_libchromeos: $(SRCDIR)/libchromeos/brillo/secure_blob.cc
$(SRCDIR)/libchromeos: | $(SRCDIR)
mkdir -p $@
$(SRCDIR)/libchromeos/brillo/secure_blob.cc: | $(SRCDIR)/libchromeos
git clone $(LIBCHROMEOS_GIT) $(SRCDIR)/libchromeos
cd $(SRCDIR)/libchromeos && git checkout $(LIBCHROMEOS_COMMIT)
# Chaps relies on .proto files from the Chromium/ChromiumOS system API at:
SYSTEMAPI_GIT=https://chromium.googlesource.com/chromiumos/platform/system_api.git
SYSTEMAPI_COMMIT=master
src_systemapi: $(SRCDIR)/system_api/dbus/chaps/ck_structs.proto
$(SRCDIR)/system_api: | $(SRCDIR)
mkdir -p $@
$(SRCDIR)/system_api/dbus/chaps/ck_structs.proto: | $(SRCDIR)/system_api
git clone $(SYSTEMAPI_GIT) $(SRCDIR)/system_api
cd $(SRCDIR)/system_api && git checkout $(SYSTEMAPI_COMMIT)
# We only need the chaps/, dbus/ and common-mk/ subdirectories from the platform2 repository from ChromiumOS.
src_platform2: $(SRCDIR)/platform2/chaps/Makefile
$(SRCDIR)/platform2:
mkdir -p $@
PLATFORM2_GIT=https://chromium.googlesource.com/chromiumos/platform2
PATCHES=$(wildcard $(CURDIR)/patches/platform2/*.patch)
$(SRCDIR)/platform2/chaps/Makefile: | $(SRCDIR)/platform2
cd $(SRCDIR)/platform2 && git init . && git remote add -f origin $(PLATFORM2_GIT)
cd $(SRCDIR)/platform2 && git config core.sparsecheckout true
cd $(SRCDIR)/platform2 && echo "chaps" > .git/info/sparse-checkout
cd $(SRCDIR)/platform2 && echo "common-mk" >> .git/info/sparse-checkout
cd $(SRCDIR)/platform2 && git pull origin master
cd $(SRCDIR)/platform2 && git checkout $(CROS_BRANCH)
cd $(SRCDIR)/platform2 && if [ ! -z "$(PATCHES)" ]; then git am $(PATCHES); fi
# Copy man pages
src_man: $(SRCDIR)/man/chapsd.8 $(SRCDIR)/man/chaps_client.8
$(SRCDIR)/man:
mkdir -p $@
$(SRCDIR)/man/%: man/% | $(SRCDIR)/man
cp $< $@
# Copy Debian packaging files
DEBIAN_MASTER_FILES=$(wildcard debian/* debian/source/*)
DEBIAN_FILES=$(addprefix $(SRCDIR)/,$(DEBIAN_MASTER_FILES))
src_debian: $(DEBIAN_FILES)
$(SRCDIR)/debian:
mkdir -p $@
$(SRCDIR)/debian/%: debian/% | $(SRCDIR)/debian
cp $< $@
$(SRCDIR)/debian/source:
mkdir -p $@
$(SRCDIR)/debian/source/%: debian/source/% | $(SRCDIR)/debian/source
cp $< $@
######################################
# Build/Clean/Test - defer to chaps-<VER>/Makefile
build: src_generate
cd $(SRCDIR) && $(MAKE)
clean: src_generate
cd $(SRCDIR) && $(MAKE) clean
test: src_generate
cd $(SRCDIR) && $(MAKE) test
######################################
# Source tarball
SRC_TARBALL=chaps-$(CHAPS_VERSION).tar.gz
dist: $(SRC_TARBALL)
$(SRC_TARBALL): src_generate clean
tar --exclude-vcs -czf $@ $(SRCDIR_REL)/base $(SRCDIR_REL)/platform2/chaps $(SRCDIR_REL)/platform2/libchromeos/chromeos $(SRCDIR_REL)/platform2/common-mk $(SRCDIR_REL)/include $(SRCDIR_REL)/gmock-$(GMOCK_VERSION) $(SRC_BUILDFILES) $(SRCDIR_REL)/man
clean_dist:
rm -f $(SRC_TARBALL)
######################################
# Debian source package: an .orig.tar.gz, a .dsc and a .debian.gz.
src-package: chaps_$(CHAPS_VERSION).orig.tar.gz
cd $(SRCDIR) && dpkg-buildpackage $(DPKGSIGN) -S
src_package: src-package
chaps_$(CHAPS_VERSION).orig.tar.gz: $(SRC_TARBALL)
cp -f $< $@
######################################
# Debian binary packages
package: chaps_$(DEB_VERSION)_amd64.deb
chaps_$(DEB_VERSION)_amd64.deb: src_generate
cd $(SRCDIR) && dpkg-buildpackage $(DPKGSIGN) -b
clean_package:
rm -f chaps_$(DEB_VERSION)_amd64.deb libchaps0_$(DEB_VERSION)_amd64.deb
######################################
# Distclean: remove source and packages
distclean:
rm -rf $(SRCDIR)
rm -f chaps_$(DEB_VERSION)_amd64.deb chaps_$(DEB_VERSION)_amd64.changes
rm -f libchaps$(CHAPS_VERSION_MAJOR)_$(DEB_VERSION)_amd64.deb libchaps$(CHAPS_VERSION_MAJOR)_$(DEB_VERSION)_amd64.changes
rm -f chaps_$(CHAPS_VERSION).orig.tar.gz chaps_$(DEB_VERSION).debian.tar.gz chaps_$(DEB_VERSION)_source.changes chaps_$(DEB_VERSION).dsc
rm -f $(SRC_TARBALL)