blob: cf3079b0b99c610236ef04275991ef7a3dd295d2 [file] [log] [blame]
Martin Turonba1a0282020-03-10 19:25:02 -07001#
Grant Ericksonf9707052020-03-31 10:22:07 -07002# Copyright (c) 2020 Project CHIP Authors
Rob Walkere812e672020-03-31 17:51:57 -07003# Copyright (c) 2014-2018 Nest Labs, Inc.
4# Copyright (c) 2018 Google LLC
Martin Turonba1a0282020-03-10 19:25:02 -07005#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19#
20# Description:
21# This file is the GNU automake template for the CHIP SDK.
22#
23
24include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
25
26# To ensure that the .local-version file and subsequent rechecks work
27# correctly, don't allow this top-level makefile to run in parallel.
28
29.NOTPARALLEL:
30
31AM_MAKEFLAGS = --no-print-directory
32
33SUBDIRS = \
Martin Turonef904ab2020-04-20 18:15:33 -070034 examples \
Martin Turonba1a0282020-03-10 19:25:02 -070035 third_party \
36 src \
Martin Turone4c92e12020-05-13 10:36:33 -070037 docs \
Martin Turonba1a0282020-03-10 19:25:02 -070038 $(NULL)
39
40PRETTY_SUBDIRS = \
41 $(filter-out third_party,$(SUBDIRS)) \
42 $(NULL)
43
44EXTRA_DIST = \
Martin Turon51a2ec72020-05-12 14:57:53 -070045 CODE_OF_CONDUCT.md \
Martin Turonba1a0282020-03-10 19:25:02 -070046 CONTRIBUTING.md \
47 Makefile-Android \
48 Makefile-bootstrap \
Martin Turonba1a0282020-03-10 19:25:02 -070049 Makefile-Standalone \
50 README.md \
51 .default-version \
52 bootstrap \
53 bootstrap-configure \
54 repos.conf \
Rob Walkerdee9b452020-07-09 06:56:23 -070055 .gitmodules \
Grant Erickson73e5e0d2020-04-03 13:14:32 -070056 $(srcdir)/build/autoconf \
Rob Walker362af3f2020-06-02 07:03:34 -070057 $(srcdir)/config \
58 $(srcdir)/config/efr32 \
59 $(srcdir)/config/nrf5 \
60 $(srcdir)/scripts \
Martin Turonba1a0282020-03-10 19:25:02 -070061 $(NULL)
62
63BUILT_SOURCES = \
64 .local-version \
65 $(NULL)
66
67dist_doc_DATA = \
68 LICENSE \
69 $(NULL)
70
71DISTCLEANFILES = \
72 .local-version \
Rob Walker362af3f2020-06-02 07:03:34 -070073 .local-version.min \
Martin Turonba1a0282020-03-10 19:25:02 -070074 $(NULL)
75
76# There are no source files to lint or prettify in this subdirectory.
77
78PRETTY_FILES := $(NULL)
79
80#
81# Package version files:
82#
83# .default-version - The default package version. This file is ALWAYS checked
84# in and should always represent the current baseline
85# version of the package.
86#
87# .dist-version - The distributed package version. This file is NEVER
88# checked in within the upstream repository, is auto-
89# generated, and is only found in the package distribution.
90#
91# .local-version - The current source code controlled package version. This
92# file is NEVER checked in within the upstream repository,
93# is auto-generated, and can always be found in both the
94# build tree and distribution.
95#
96# When present, the .local-version file is preferred first, the
97# .dist-version second, and the .default-version last.
98#
99
100# VERSION_FILE should be and is intentionally an immediate (:=) rather
101# than a deferred (=) variable to ensure the value binds once and only once
102# for a given MAKELEVEL even as .local-version and .dist-version are created
103# during makefile execution.
104
105VERSION_FILE := $(if $(wildcard $(builddir)/.local-version),$(builddir)/.local-version,$(if $(wildcard $(srcdir)/.dist-version),$(srcdir)/.dist-version,$(srcdir)/.default-version))
Rob Walker362af3f2020-06-02 07:03:34 -0700106
Martin Turonba1a0282020-03-10 19:25:02 -0700107#
108# Override autotool's default notion of the package version variables.
109# This ensures that when we create a source distribution the
110# version is always the current version, not the package bootstrap
111# version.
112#
Rob Walker362af3f2020-06-02 07:03:34 -0700113# The include ensures that we update CHIP_VERSION and VERSION once
114# we've built .local-version (the source of truth unless CHIP_VERSION
115# is specified on the make command line).
116#
117# CHIP_VERSION can be overridden from the command line, but when the version is NOT
Rob Walkera6247bd2020-05-27 15:00:50 -0700118# overridden that we bind the version once and only once across potential
119# sub-makes to prevent the version from flapping as VERSION_FILE changes.
Martin Turonba1a0282020-03-10 19:25:02 -0700120#
Rob Walker362af3f2020-06-02 07:03:34 -0700121# .local-version.min sets CHIP_VERSION
122-include .local-version.min
Martin Turonba1a0282020-03-10 19:25:02 -0700123
124PACKAGE_VERSION = $(CHIP_VERSION)
125VERSION = $(PACKAGE_VERSION)
126
Rob Walker362af3f2020-06-02 07:03:34 -0700127
Martin Turonba1a0282020-03-10 19:25:02 -0700128#
129# check-file-.local-version
130#
131# Speculatively regenerate .local-version and check to see if it needs
132# to be updated.
133#
134# If CHIP_VERSION has been supplied anywhere other than in this file
135# (which is implicitly the contents of .local-version), then use that;
136# otherwise, attempt to generate it from the SCM system.
137#
138# This is called from $(call check-file,.local-version).
139#
140define check-file-.local-version
Rob Walkera6247bd2020-05-27 15:00:50 -0700141$(if $(filter-out file,$(origin CHIP_VERSION)),\
142 echo "$(CHIP_VERSION)" > "$(2)",\
Martin Turonba1a0282020-03-10 19:25:02 -0700143 $(abs_top_nlbuild_autotools_dir)/scripts/mkversion \
144 -b "$(CHIP_VERSION)" "$(top_srcdir)" \
Rob Walkera6247bd2020-05-27 15:00:50 -0700145 > "$(2)")
Martin Turonba1a0282020-03-10 19:25:02 -0700146endef
147
Rob Walker362af3f2020-06-02 07:03:34 -0700148
Martin Turonba1a0282020-03-10 19:25:02 -0700149#
150# check-file-.dist-version
151#
152# Speculatively regenerate .dist-version and check to see if it needs
153# to be updated.
154#
155# This is called from $(call check-file,.dist-version).
156#
157define check-file-.dist-version
158cat "$(1)" > "$(2)"
159endef
160
161#
162# A convenience target to allow package users to easily rerun the
163# package configuration according to the current configuration.
164#
165.PHONY: reconfigure
166reconfigure: $(builddir)/config.status
167 $(AM_V_at)$(<) --recheck
168
169#
170# Version file regeneration rules.
171#
172.PHONY: force
173
174$(builddir)/.local-version: $(srcdir)/.default-version force
175
176$(distdir)/.dist-version: $(builddir)/.local-version force
177
178$(distdir)/.dist-version $(builddir)/.local-version:
179 $(call check-file,$(@F))
180
Rob Walker362af3f2020-06-02 07:03:34 -0700181$(builddir)/.local-version.min: $(builddir)/.local-version
182 (printf "export CHIP_VERSION=" ; cat) < "$(VERSION_FILE)" > $@
183
184
Martin Turonba1a0282020-03-10 19:25:02 -0700185#
186# When we run 'distcheck' and --with-<any of the third-party packages
187# listed in repos.conf>, default to 'internal', the nlbuild-autotools
188# infrastructure will attempt to create git paths to manage the
189# package repo. Two directories need to be writable to facilitate
190# this.
191#
192
193DISTCHECK_CONFIGURE_FLAGS = `chmod u+w ../.. ../../third_party`
194
yunhanw-googlee1d448c2020-07-21 11:57:53 -0700195#
196# BlueZ is not well set-up without patching to handle 'make distcheck';
197# disable it for that target.
198#
199
200DISTCHECK_CONFIGURE_FLAGS += --without-bluez
201
Martin Turonba1a0282020-03-10 19:25:02 -0700202all-recursive check-recursive coverage-recursive install-recursive pretty-recursive pretty-check-recursive dist distcheck distdir install-headers: $(BUILT_SOURCES)
203
204dist-hook: $(distdir)/.dist-version
205
206# If you are synchronizing a package on which yours depends using 'repos.conf',
207# to 'third_party', uncomment and adapt or delete this, as needed. If you choose
208# to use this, please also take a look at Makefile.am and third_party/Makefile.am
209# and uncomment the appropriate sections there.
210
211#
212# Ensure any locally synchronized repositories defined by 'repos.conf'
213# are cleaned up.
214#
215distclean-local:
216 $(MAKE) -C $(srcdir) -f Makefile-bootstrap clean-repos
217
218#
Grant Ericksonc56ec542020-07-09 04:38:53 -0700219# Top-level convenience target for making documentation.
220#
221
222.PHONY: doc
223doc: $(BUILT_SOURCES)
224 $(MAKE) -C docs $(@)
225
226#
Martin Turonba1a0282020-03-10 19:25:02 -0700227# Top-level convenience target for making a documentation-only
228# distribution whose results appear at the top level of the build tree
229# in the same fashion that the distribution would be for 'make dist'.
230#
231
232.PHONY: docdist
233docdist: $(BUILT_SOURCES)
Martin Turon104ab9c2020-05-12 16:03:46 -0700234 $(MAKE) -C docs docdistdir=$(abs_builddir) $(@)
Martin Turonba1a0282020-03-10 19:25:02 -0700235
236#
237# Top-level convenience target for making a tools-only distribution
238# whose resuls appear at the top level of the build tree in the same
239# fashion that the distribution would be for 'make dist'.
240#
241
242tooldistdir ?= $(abs_builddir)
243
244chip_tooldist_alias = \
245 $(PACKAGE_TARNAME)-tools
246
247chip_tooldist_name = \
248 $(chip_tooldist_alias)-$(shell echo $(target) | $(SED) -e 's/[[:digit:].]*$$//g')-$(CHIP_VERSION)
249
250chip_tooldist_archive = \
251 $(tooldistdir)/$(chip_tooldist_name).tar.gz
252
253CLEANFILES = \
254 $(chip_tooldist_archive) \
255 $(NULL)
256
257$(chip_tooldist_name):
258 $(AM_V_at)rm -f -r "$(@)"
259 $(call create-directory)
260 $(MAKE) DESTDIR=$(tooldistdir)/$(chip_tooldist_name) install
261 $(AM_V_at)rm -f -r \
262 "$(@)/include" \
263 "$(@)/lib/engines" \
264 "$(@)/lib/libcrypto.a" \
265 "$(@)/lib/libssl.a" \
266 "$(@)/lib/pkgconfig" \
267 "$(@)/openssl" \
268 "$(@)/share/java"
269
270$(chip_tooldist_archive): $(chip_tooldist_name)
271 $(AM_V_at)echo " TAR $(@)"
272 $(AM_V_at)tardir="$(<)" && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c > "$(@)" && rm -rf "$(<)"
273
274.PHONY: tooldist
275tooldist $(chip_tooldist_alias): $(chip_tooldist_archive)
276
277#
278# By virtue of the way we allow for the creation of both libChip and
279# libInetLayer, using the same makefile fragment included in the
280# Makefile.am of each of those libraries, running 'make distclean'
281# will fail in src/lib after running in src/inet because the
282# dependencies for the latter have already been cleaned for the
283# former.
284#
285# In general, we don't really care about this specifically or if a
286# particular step of distclean fails generally, so propagate the
287# --ignore-errors and --keep-going flags for make on recursive
288# distclean to avoid this.
289#
290
291distclean-recursive: AM_MAKEFLAGS += -ik
292
293include $(abs_top_nlbuild_autotools_dir)/automake/post.am