Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 1 | # |
Grant Erickson | f970705 | 2020-03-31 10:22:07 -0700 | [diff] [blame] | 2 | # Copyright (c) 2020 Project CHIP Authors |
Rob Walker | e812e67 | 2020-03-31 17:51:57 -0700 | [diff] [blame] | 3 | # Copyright (c) 2014-2018 Nest Labs, Inc. |
| 4 | # Copyright (c) 2018 Google LLC |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 5 | # |
| 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 | |
| 24 | include $(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 | |
| 31 | AM_MAKEFLAGS = --no-print-directory |
| 32 | |
| 33 | SUBDIRS = \ |
Martin Turon | ef904ab | 2020-04-20 18:15:33 -0700 | [diff] [blame] | 34 | examples \ |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 35 | third_party \ |
| 36 | src \ |
Martin Turon | e4c92e1 | 2020-05-13 10:36:33 -0700 | [diff] [blame] | 37 | docs \ |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 38 | $(NULL) |
| 39 | |
| 40 | PRETTY_SUBDIRS = \ |
| 41 | $(filter-out third_party,$(SUBDIRS)) \ |
| 42 | $(NULL) |
| 43 | |
| 44 | EXTRA_DIST = \ |
Martin Turon | 51a2ec7 | 2020-05-12 14:57:53 -0700 | [diff] [blame] | 45 | CODE_OF_CONDUCT.md \ |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 46 | CONTRIBUTING.md \ |
| 47 | Makefile-Android \ |
| 48 | Makefile-bootstrap \ |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 49 | Makefile-Standalone \ |
| 50 | README.md \ |
| 51 | .default-version \ |
| 52 | bootstrap \ |
| 53 | bootstrap-configure \ |
| 54 | repos.conf \ |
Rob Walker | dee9b45 | 2020-07-09 06:56:23 -0700 | [diff] [blame] | 55 | .gitmodules \ |
Grant Erickson | 73e5e0d | 2020-04-03 13:14:32 -0700 | [diff] [blame] | 56 | $(srcdir)/build/autoconf \ |
Rob Walker | 362af3f | 2020-06-02 07:03:34 -0700 | [diff] [blame] | 57 | $(srcdir)/config \ |
| 58 | $(srcdir)/config/efr32 \ |
| 59 | $(srcdir)/config/nrf5 \ |
| 60 | $(srcdir)/scripts \ |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 61 | $(NULL) |
| 62 | |
| 63 | BUILT_SOURCES = \ |
| 64 | .local-version \ |
| 65 | $(NULL) |
| 66 | |
| 67 | dist_doc_DATA = \ |
| 68 | LICENSE \ |
| 69 | $(NULL) |
| 70 | |
| 71 | DISTCLEANFILES = \ |
| 72 | .local-version \ |
Rob Walker | 362af3f | 2020-06-02 07:03:34 -0700 | [diff] [blame] | 73 | .local-version.min \ |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 74 | $(NULL) |
| 75 | |
| 76 | # There are no source files to lint or prettify in this subdirectory. |
| 77 | |
| 78 | PRETTY_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 | |
| 105 | VERSION_FILE := $(if $(wildcard $(builddir)/.local-version),$(builddir)/.local-version,$(if $(wildcard $(srcdir)/.dist-version),$(srcdir)/.dist-version,$(srcdir)/.default-version)) |
Rob Walker | 362af3f | 2020-06-02 07:03:34 -0700 | [diff] [blame] | 106 | |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 107 | # |
| 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 Walker | 362af3f | 2020-06-02 07:03:34 -0700 | [diff] [blame] | 113 | # 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 Walker | a6247bd | 2020-05-27 15:00:50 -0700 | [diff] [blame] | 118 | # 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 Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 120 | # |
Rob Walker | 362af3f | 2020-06-02 07:03:34 -0700 | [diff] [blame] | 121 | # .local-version.min sets CHIP_VERSION |
| 122 | -include .local-version.min |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 123 | |
| 124 | PACKAGE_VERSION = $(CHIP_VERSION) |
| 125 | VERSION = $(PACKAGE_VERSION) |
| 126 | |
Rob Walker | 362af3f | 2020-06-02 07:03:34 -0700 | [diff] [blame] | 127 | |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 128 | # |
| 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 | # |
| 140 | define check-file-.local-version |
Rob Walker | a6247bd | 2020-05-27 15:00:50 -0700 | [diff] [blame] | 141 | $(if $(filter-out file,$(origin CHIP_VERSION)),\ |
| 142 | echo "$(CHIP_VERSION)" > "$(2)",\ |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 143 | $(abs_top_nlbuild_autotools_dir)/scripts/mkversion \ |
| 144 | -b "$(CHIP_VERSION)" "$(top_srcdir)" \ |
Rob Walker | a6247bd | 2020-05-27 15:00:50 -0700 | [diff] [blame] | 145 | > "$(2)") |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 146 | endef |
| 147 | |
Rob Walker | 362af3f | 2020-06-02 07:03:34 -0700 | [diff] [blame] | 148 | |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 149 | # |
| 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 | # |
| 157 | define check-file-.dist-version |
| 158 | cat "$(1)" > "$(2)" |
| 159 | endef |
| 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 |
| 166 | reconfigure: $(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 Walker | 362af3f | 2020-06-02 07:03:34 -0700 | [diff] [blame] | 181 | $(builddir)/.local-version.min: $(builddir)/.local-version |
| 182 | (printf "export CHIP_VERSION=" ; cat) < "$(VERSION_FILE)" > $@ |
| 183 | |
| 184 | |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 185 | # |
| 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 | |
| 193 | DISTCHECK_CONFIGURE_FLAGS = `chmod u+w ../.. ../../third_party` |
| 194 | |
yunhanw-google | e1d448c | 2020-07-21 11:57:53 -0700 | [diff] [blame] | 195 | # |
| 196 | # BlueZ is not well set-up without patching to handle 'make distcheck'; |
| 197 | # disable it for that target. |
| 198 | # |
| 199 | |
| 200 | DISTCHECK_CONFIGURE_FLAGS += --without-bluez |
| 201 | |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 202 | all-recursive check-recursive coverage-recursive install-recursive pretty-recursive pretty-check-recursive dist distcheck distdir install-headers: $(BUILT_SOURCES) |
| 203 | |
| 204 | dist-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 | # |
| 215 | distclean-local: |
| 216 | $(MAKE) -C $(srcdir) -f Makefile-bootstrap clean-repos |
| 217 | |
| 218 | # |
Grant Erickson | c56ec54 | 2020-07-09 04:38:53 -0700 | [diff] [blame] | 219 | # Top-level convenience target for making documentation. |
| 220 | # |
| 221 | |
| 222 | .PHONY: doc |
| 223 | doc: $(BUILT_SOURCES) |
| 224 | $(MAKE) -C docs $(@) |
| 225 | |
| 226 | # |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 227 | # 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 |
| 233 | docdist: $(BUILT_SOURCES) |
Martin Turon | 104ab9c | 2020-05-12 16:03:46 -0700 | [diff] [blame] | 234 | $(MAKE) -C docs docdistdir=$(abs_builddir) $(@) |
Martin Turon | ba1a028 | 2020-03-10 19:25:02 -0700 | [diff] [blame] | 235 | |
| 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 | |
| 242 | tooldistdir ?= $(abs_builddir) |
| 243 | |
| 244 | chip_tooldist_alias = \ |
| 245 | $(PACKAGE_TARNAME)-tools |
| 246 | |
| 247 | chip_tooldist_name = \ |
| 248 | $(chip_tooldist_alias)-$(shell echo $(target) | $(SED) -e 's/[[:digit:].]*$$//g')-$(CHIP_VERSION) |
| 249 | |
| 250 | chip_tooldist_archive = \ |
| 251 | $(tooldistdir)/$(chip_tooldist_name).tar.gz |
| 252 | |
| 253 | CLEANFILES = \ |
| 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 |
| 275 | tooldist $(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 | |
| 291 | distclean-recursive: AM_MAKEFLAGS += -ik |
| 292 | |
| 293 | include $(abs_top_nlbuild_autotools_dir)/automake/post.am |