1#
2#  Copyright (c) 2016, The OpenThread Authors.
3#  All rights reserved.
4#
5#  Redistribution and use in source and binary forms, with or without
6#  modification, are permitted provided that the following conditions are met:
7#  1. Redistributions of source code must retain the above copyright
8#     notice, this list of conditions and the following disclaimer.
9#  2. Redistributions in binary form must reproduce the above copyright
10#     notice, this list of conditions and the following disclaimer in the
11#     documentation and/or other materials provided with the distribution.
12#  3. Neither the name of the copyright holder nor the
13#     names of its contributors may be used to endorse or promote products
14#     derived from this software without specific prior written permission.
15#
16#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26#  POSSIBILITY OF SUCH DAMAGE.
27#
28
29include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
30
31AM_MAKEFLAGS                        = --no-print-directory
32
33AM_DISTCHECK_CONFIGURE_FLAGS        = \
34    --enable-address-sanitizer        \
35    --enable-cli                      \
36    --enable-ftd                      \
37    --enable-mtd                      \
38    --enable-ncp                      \
39    --enable-radio-only               \
40    --with-examples=simulation        \
41    $(NULL)
42
43SUBDIRS                             = \
44    include                           \
45    third_party                       \
46    src                               \
47    examples                          \
48    tests                             \
49    tools                             \
50    doc                               \
51    $(NULL)
52
53EXTRA_DIST                          = \
54    .default-version                  \
55    bootstrap                         \
56    etc                               \
57    README.md                         \
58    NOTICE                            \
59    CONTRIBUTING.md                   \
60    LICENSE                           \
61    $(NULL)
62
63BUILT_SOURCES                       = \
64    .local-version                    \
65    $(NULL)
66
67dist_doc_DATA                       = \
68    $(NULL)
69
70DISTCLEANFILES                      = \
71    .local-version                    \
72    $(NULL)
73
74# Ignore the pseudo flash files on Posix platform during diskcheck
75distcleancheck_listfiles            = \
76    $(AM_V_at)find . -type f -name "*flash"
77
78#
79# Package version files:
80#
81# .default-version - The default package version. This file is ALWAYS checked
82#                    in and should always represent the current baseline
83#                    version of the package.
84#
85# .dist-version    - The distributed package version. This file is NEVER
86#                    checked in within the upstream repository, is auto-
87#                    generated, and is only found in the package distribution.
88#
89# .local-version   - The current source code controlled package version. This
90#                    file is NEVER checked in within the upstream repository,
91#                    is auto-generated, and can always be found in both the
92#                    build tree and distribution.
93#
94# When present, the .local-version file is preferred first, the
95# .dist-version second, and the .default-version last.
96#
97
98VERSION_FILE                      := $(if $(wildcard $(builddir)/.local-version),$(builddir)/.local-version,$(if $(wildcard $(srcdir)/.dist-version),$(srcdir)/.dist-version,$(srcdir)/.default-version))
99
100#
101# Override autotool's default notion of the package version variables.
102# This ensures that when we create a source distribution that the
103# version is always the current version, not the version when the
104# package was bootstrapped.
105#
106
107OPENTHREAD_VERSION                ?= $(shell cat $(VERSION_FILE) 2> /dev/null)
108
109PACKAGE_VERSION                    = $(OPENTHREAD_VERSION)
110VERSION                            = $(PACKAGE_VERSION)
111
112distdir = $(PACKAGE)-$(shell                                     \
113if [ "$(origin OPENTHREAD_VERSION)" != "file" ]; then            \
114    echo "$(OPENTHREAD_VERSION)" ;                               \
115else                                                             \
116    $(abs_top_nlbuild_autotools_dir)/scripts/mkversion           \
117        -b "$(OPENTHREAD_VERSION)" "$(top_srcdir)";              \
118fi )
119
120#
121# check-file-.local-version
122#
123# Speculatively regenerate .local-version and check to see if it needs
124# to be updated.
125#
126# If OPENTHREAD_VERSION has been supplied anywhere other than in this file
127# (which is implicitly the contents of .local-version), then use that;
128# otherwise, attempt to generate it from the SCM system.
129#
130# This is called from $(call check-file,.local-version).
131#
132define check-file-.local-version
133if [ "$(origin OPENTHREAD_VERSION)" != "file" ]; then \
134    echo "$(OPENTHREAD_VERSION)" > "$(2)";            \
135else                                                             \
136    $(abs_top_nlbuild_autotools_dir)/scripts/mkversion           \
137        -b "$(OPENTHREAD_VERSION)" "$(top_srcdir)"    \
138        > "$(2)";                                                \
139fi
140endef
141
142#
143# check-file-.dist-version
144#
145# Speculatively regenerate .dist-version and check to see if it needs
146# to be updated.
147#
148# This is called from $(call check-file,.dist-version).
149#
150define check-file-.dist-version
151cat "$(1)" > "$(2)"
152endef
153
154#
155# A convenience target to allow package users to easily rerun the
156# package configuration according to the current configuration.
157#
158.PHONY: reconfigure
159reconfigure: $(builddir)/config.status
160	$(AM_V_at)$(<) --recheck
161
162#
163# Version file regeneration rules.
164#
165.PHONY: force
166
167$(builddir)/.local-version: $(srcdir)/.default-version force
168
169$(distdir)/.dist-version: $(builddir)/.local-version force
170
171$(distdir)/.dist-version $(builddir)/.local-version:
172	$(call check-file,$(@F))
173
174dist distcheck: $(BUILT_SOURCES)
175
176dist-hook: $(distdir)/.dist-version
177
178#
179# Top-level convenience target for making a documentation-only
180# distribution whose results appear at the top level of the build tree
181# in the same fashion that the distribution would be for 'make dist'.
182#
183
184.PHONY: docdist
185docdist: $(BUILT_SOURCES)
186	$(MAKE) -C doc docdistdir=$(abs_builddir) $(@)
187
188include $(abs_top_nlbuild_autotools_dir)/automake/post.am
189