• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
31#----------------------------------------
32#
33# This library on the face of it, appears to be identical
34# for both the MTD and FTD variants, however ...
35#
36# The source code here includes numerous OpenThread internal headers.
37# Due to the "domino-effect" other internal headers are included.
38#
39# For example:
40#     cli.cpp includes:
41#            src/core/common/instance.hpp
42# Which Includes:
43#            src/core/therad/thread_netif.hpp
44# Which Includes:
45#            src/core/meshcop/dataset_manager.hpp
46# Which Includes:
47#            src/core/threadnetwork_data_leader.hpp
48#
49# That header (and others) is either an MTD or FTD class flavor.
50#
51# The FTD flavor has many private components (class variables).
52# The MTD flavor has no private components.
53#
54# Bottom line: The Class(structs) are thus different in the downstream
55# libs. At this level (in the CLI, and likewise in the NCP) they are
56# functionally identical.
57#
58# ORIGINALLY (historical note about how things are/where built):
59#
60#     The difference between MTD and FTD was a define..  -DOPENTHREAD_MTD
61#     There was no "FTD" define, it is/was assumed that FTD is the default.
62#
63#     Historically this library -DOPENTHREAD_MTD was not defined/set.
64#     (it is set via a commandline define in 'lib-openthread')
65#
66#     Thus, the existing(previous) way *THIS* library was compiled is
67#     exactly the FTD path. Meaning the "cli" library always sees
68#     the FTD varients of various headers/classes.
69#
70#     The same is true of the "ncp" library.
71#
72# HOWEVER there are two varients of the CLI application, CLI-MTD
73# and CLI-FTD (and likewise, two varients of the ncp application)
74# These applications link against two different OpenThread libraries.
75#
76# Which flavor, you get depends upon which library: "mtd" or "ftd" is linked.
77#
78# Which on the surface appear to link fine against the MTD/FTD library.
79#
80# In this description/example we focus on the  "nework_data_leader"
81# header file. The FTD varient has many private variables, functions
82# and other things of "FTD" (ie: full) implementation items.
83#
84# In contrast the MTD is generaly stubbed out with stub-functions
85# inlined in the header that return "error not implemented" or similar.
86#
87# Thus it works... here ... With this file and this example.
88#
89# The unknown:
90#    What about the other files?
91#    What about the other c++ classes?
92#    Is this true always? Is this robust?
93#    Or is there a hidden "got-ya" that will snag the next person?
94#
95# This also fails static analisys, checks.
96#    Application - with MTD vrs FTD class.
97#    Library #1  (cli-lib) with FTD selected.
98#    Library #2  (openthread) with two different class flavors.
99#
100# The static analisys tools will say: "NOPE" different classes!
101# Perhaps this will change if/when nothing is implemented in the 'mtd-header'
102#
103# Additionally, tools that perform "whole program optimization" will
104# throw errors becuase the data structures differ greatly.
105#
106# Hence, CLI library (and NCP) must exist in two flavors.
107#
108# Unless and until these libraries do not "accidently" suck in
109# a "flavored" header file somewhere.
110
111lib_LIBRARIES                       = $(NULL)
112
113if OPENTHREAD_ENABLE_FTD
114lib_LIBRARIES                      += libopenthread-cli-ftd.a
115endif
116
117if OPENTHREAD_ENABLE_MTD
118lib_LIBRARIES                      += libopenthread-cli-mtd.a
119endif
120
121if OPENTHREAD_ENABLE_RADIO_CLI
122lib_LIBRARIES                      += libopenthread-cli-radio.a
123endif
124
125CPPFLAGS_COMMON =                     \
126    -I$(top_srcdir)/include           \
127    -I$(top_srcdir)/src               \
128    -I$(top_srcdir)/src/core          \
129    $(OPENTHREAD_TARGET_DEFINES)      \
130    $(NULL)
131
132libopenthread_cli_ftd_a_CPPFLAGS =    \
133    -DOPENTHREAD_MTD=0                \
134    -DOPENTHREAD_FTD=1                \
135    -DOPENTHREAD_RADIO=0              \
136    $(CPPFLAGS_COMMON)                \
137    $(NULL)
138
139libopenthread_cli_mtd_a_CPPFLAGS =    \
140    -DOPENTHREAD_MTD=1                \
141    -DOPENTHREAD_FTD=0                \
142    -DOPENTHREAD_RADIO=0              \
143    $(CPPFLAGS_COMMON)                \
144    $(NULL)
145
146libopenthread_cli_radio_a_CPPFLAGS =  \
147    -DOPENTHREAD_MTD=0                \
148    -DOPENTHREAD_FTD=0                \
149    -DOPENTHREAD_RADIO=1              \
150    -DOPENTHREAD_RADIO_CLI=1          \
151    $(CPPFLAGS_COMMON)                \
152    $(NULL)
153
154SOURCES_COMMON =                      \
155    cli.cpp                           \
156    cli_coap.cpp                      \
157    cli_coap_secure.cpp               \
158    cli_commissioner.cpp              \
159    cli_dataset.cpp                   \
160    cli_history.cpp                   \
161    cli_joiner.cpp                    \
162    cli_network_data.cpp              \
163    cli_output.cpp                    \
164    cli_srp_client.cpp                \
165    cli_srp_server.cpp                \
166    cli_tcp.cpp                       \
167    cli_udp.cpp                       \
168    $(NULL)
169
170libopenthread_cli_ftd_a_SOURCES =     \
171    $(SOURCES_COMMON)                 \
172    $(NULL)
173
174libopenthread_cli_mtd_a_SOURCES =     \
175    $(SOURCES_COMMON)                 \
176    $(NULL)
177
178libopenthread_cli_radio_a_SOURCES =   \
179    cli.cpp                           \
180    cli_output.cpp                    \
181    $(NULL)
182
183noinst_HEADERS                      = \
184    cli.hpp                           \
185    cli_coap.hpp                      \
186    cli_coap_secure.hpp               \
187    cli_commissioner.hpp              \
188    cli_config.h                      \
189    cli_dataset.hpp                   \
190    cli_history.hpp                   \
191    cli_joiner.hpp                    \
192    cli_network_data.hpp              \
193    cli_output.hpp                    \
194    cli_srp_client.hpp                \
195    cli_srp_server.hpp                \
196    cli_tcp.hpp                       \
197    cli_udp.hpp                       \
198    x509_cert_key.hpp                 \
199    $(NULL)
200
201if OPENTHREAD_BUILD_COVERAGE
202CLEANFILES                          = $(wildcard *.gcda *.gcno)
203endif # OPENTHREAD_BUILD_COVERAGE
204
205include $(abs_top_nlbuild_autotools_dir)/automake/post.am
206