2 # Copyright (c) 2016-2018 Nest Labs Inc. All Rights Reserved.
3 # Copyright (c) 2018 Google LLC. All Rights Reserved.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 # This file is the GNU automake template for the @PACKAGE_DESCRIPTION@.
23 include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
25 AM_MAKEFLAGS = --no-print-directory
39 $(srcdir)/third_party/nlbuild-autotools \
54 # Package version files:
56 # .default-version - The default package version. This file is ALWAYS checked
57 # in and should always represent the current baseline
58 # version of the package.
60 # .dist-version - The distributed package version. This file is NEVER
61 # checked in within the upstream repository, is auto-
62 # generated, and is only found in the package distribution.
64 # .local-version - The current source code controlled package version. This
65 # file is NEVER checked in within the upstream repository,
66 # is auto-generated, and can always be found in both the
67 # build tree and distribution.
69 # When present, the .local-version file is preferred first, the
70 # .dist-version second, and the .default-version last.
73 # VERSION_FILE should be and is intentionally an immediate (:=) rather
74 # than a deferred (=) variable to ensure the value binds once and only once
75 # for a given MAKELEVEL even as .local-version and .dist-version are created
76 # during makefile execution.
78 VERSION_FILE := $(if $(wildcard $(builddir)/.local-version),$(builddir)/.local-version,$(if $(wildcard $(srcdir)/.dist-version),$(srcdir)/.dist-version,$(srcdir)/.default-version))
81 # Override autotool's default notion of the package version variables.
82 # This ensures that when we create a source distribution the
83 # version is always the current version, not the package bootstrap
86 # The two-level variables and the check against MAKELEVEL ensures that
87 # not only can the package version be overridden from the command line
88 # but also when the version is NOT overridden that we bind the version
89 # once and only once across potential sub-makes to prevent the version
90 # from flapping as VERSION_FILE changes.
93 export MAYBE_@PACKAGE_SHORT_UPPER@_VERSION := $(if $(filter 0,$(MAKELEVEL)),$(shell cat $(VERSION_FILE) 2> /dev/null),$(MAYBE_@PACKAGE_SHORT_UPPER@_VERSION))
95 @PACKAGE_SHORT_UPPER@_VERSION ?= $(MAYBE_@PACKAGE_SHORT_UPPER@_VERSION)
97 PACKAGE_VERSION = $(@PACKAGE_SHORT_UPPER@_VERSION)
98 VERSION = $(PACKAGE_VERSION)
101 # check-file-.local-version
103 # Speculatively regenerate .local-version and check to see if it needs
106 # If @PACKAGE_SHORT_UPPER@_VERSION has been supplied anywhere other than in this file
107 # (which is implicitly the contents of .local-version), then use that;
108 # otherwise, attempt to generate it from the SCM system.
110 # This is called from $(call check-file,.local-version).
112 define check-file-.local-version
113 if [ "$(origin @PACKAGE_SHORT_UPPER@_VERSION)" != "file" ]; then \
114 echo "$(@PACKAGE_SHORT_UPPER@_VERSION)" > "$(2)"; \
116 $(abs_top_nlbuild_autotools_dir)/scripts/mkversion \
117 -b "$(@PACKAGE_SHORT_UPPER@_VERSION)" "$(top_srcdir)" \
123 # check-file-.dist-version
125 # Speculatively regenerate .dist-version and check to see if it needs
128 # This is called from $(call check-file,.dist-version).
130 define check-file-.dist-version
135 # A convenience target to allow package users to easily rerun the
136 # package configuration according to the current configuration.
139 reconfigure: $(builddir)/config.status
140 $(AM_V_at)$(<) --recheck
143 # Version file regeneration rules.
147 $(builddir)/.local-version: $(srcdir)/.default-version force
149 $(distdir)/.dist-version: $(builddir)/.local-version force
151 $(distdir)/.dist-version $(builddir)/.local-version:
152 $(call check-file,$(@F))
154 # If you are synchronizing a package on which yours depends using 'repos.conf',
155 # to 'third_party', uncomment and adapt or delete this, as needed. If you choose
156 # to use this, please also take a look at Makefile.am and third_party/Makefile.am
157 # and uncomment the appropriate sections there.
160 # # When we run 'distcheck' and --with-nlunit_test defaults to 'internal',
161 # # the nlbuild-autotools infrastructure will attempt to create git paths
162 # # to manage the nlunit-test repo. Two directories need to be writable
163 # # to facilitate this.
165 # DISTCHECK_CONFIGURE_FLAGS=`chmod u+w .. ../third_party`
167 dist distcheck distdir install-headers: $(BUILT_SOURCES)
169 dist-hook: $(distdir)/.dist-version
171 # If you are synchronizing a package on which yours depends using 'repos.conf',
172 # to 'third_party', uncomment and adapt or delete this, as needed. If you choose
173 # to use this, please also take a look at Makefile.am and third_party/Makefile.am
174 # and uncomment the appropriate sections there.
177 # # Ensure any locally synchronized repositories defined by 'repos.conf'
181 # $(MAKE) -C $(srcdir) -f Makefile-bootstrap clean-repos
184 # Top-level convenience target for making a documentation-only
185 # distribution whose results appear at the top level of the build tree
186 # in the same fashion that the distribution would be for 'make dist'.
190 docdist: $(BUILT_SOURCES)
191 $(MAKE) -C doc docdistdir=$(abs_builddir) $(@)
193 include $(abs_top_nlbuild_autotools_dir)/automake/post.am