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
121CPPFLAGS_COMMON =                     \
122    -I$(top_srcdir)/include           \
123    -I$(top_srcdir)/src               \
124    -I$(top_srcdir)/src/core          \
125    $(OPENTHREAD_TARGET_DEFINES)      \
126    $(NULL)
127
128libopenthread_cli_mtd_a_CPPFLAGS =    \
129    -DOPENTHREAD_MTD=1                \
130    -DOPENTHREAD_FTD=0                \
131    -DOPENTHREAD_RADIO=0              \
132    $(CPPFLAGS_COMMON)                \
133    $(NULL)
134
135libopenthread_cli_ftd_a_CPPFLAGS =    \
136    -DOPENTHREAD_MTD=0                \
137    -DOPENTHREAD_FTD=1                \
138    -DOPENTHREAD_RADIO=0              \
139    $(CPPFLAGS_COMMON)                \
140    $(NULL)
141
142SOURCES_COMMON =                      \
143    cli.cpp                           \
144    cli_coap.cpp                      \
145    cli_coap_secure.cpp               \
146    cli_commissioner.cpp              \
147    cli_dataset.cpp                   \
148    cli_history.cpp                   \
149    cli_joiner.cpp                    \
150    cli_network_data.cpp              \
151    cli_srp_client.cpp                \
152    cli_srp_server.cpp                \
153    cli_tcp.cpp                       \
154    cli_udp.cpp                       \
155    $(NULL)
156
157libopenthread_cli_ftd_a_SOURCES =     \
158    $(SOURCES_COMMON)                 \
159    $(NULL)
160
161libopenthread_cli_mtd_a_SOURCES =     \
162    $(SOURCES_COMMON)                 \
163    $(NULL)
164
165noinst_HEADERS                      = \
166    cli.hpp                           \
167    cli_coap.hpp                      \
168    cli_coap_secure.hpp               \
169    cli_commissioner.hpp              \
170    cli_config.h                      \
171    cli_dataset.hpp                   \
172    cli_history.hpp                   \
173    cli_joiner.hpp                    \
174    cli_network_data.hpp              \
175    cli_srp_client.hpp                \
176    cli_srp_server.hpp                \
177    cli_tcp.hpp                       \
178    cli_udp.hpp                       \
179    x509_cert_key.hpp                 \
180    $(NULL)
181
182if OPENTHREAD_BUILD_COVERAGE
183CLEANFILES                          = $(wildcard *.gcda *.gcno)
184endif # OPENTHREAD_BUILD_COVERAGE
185
186include $(abs_top_nlbuild_autotools_dir)/automake/post.am
187