From e8769287a718d5b8761237f2def9a1042ad18630 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Wed, 30 Nov 2016 22:20:12 -0800 Subject: [PATCH] Clean up makefiles. (#1021) --- configure.ac | 1 + examples/platforms/Makefile.am | 12 ++++--- examples/platforms/cc2538/Makefile.am | 13 ++------ examples/platforms/posix/Makefile.am | 16 ++++------ examples/platforms/utils/Makefile.am | 46 +++++++++++++++++++++++++++ examples/platforms/utils/settings.cpp | 7 ++-- 6 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 examples/platforms/utils/Makefile.am diff --git a/configure.ac b/configure.ac index e6cc6e021..46cf4535c 100644 --- a/configure.ac +++ b/configure.ac @@ -989,6 +989,7 @@ examples/apps/ncp/Makefile examples/platforms/Makefile examples/platforms/cc2538/Makefile examples/platforms/posix/Makefile +examples/platforms/utils/Makefile tools/Makefile tools/harness-automation/Makefile tools/harness-thci/Makefile diff --git a/examples/platforms/Makefile.am b/examples/platforms/Makefile.am index 3cce7f202..929be50af 100644 --- a/examples/platforms/Makefile.am +++ b/examples/platforms/Makefile.am @@ -33,20 +33,21 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am DIST_SUBDIRS = \ cc2538 \ posix \ - $(NULL) - -EXTRA_DIST = \ utils \ $(NULL) # Always build (e.g. for 'make all') these subdirectories. +SUBDIRS = \ + utils \ + $(NULL) + if OPENTHREAD_EXAMPLES_POSIX -SUBDIRS = posix +SUBDIRS += posix endif if OPENTHREAD_EXAMPLES_CC2538 -SUBDIRS = cc2538 +SUBDIRS += cc2538 endif # Always pretty (e.g. for 'make pretty') these subdirectories. @@ -54,6 +55,7 @@ endif PRETTY_SUBDIRS = \ cc2538 \ posix \ + utils \ $(NULL) include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/examples/platforms/cc2538/Makefile.am b/examples/platforms/cc2538/Makefile.am index af246f597..6e11d9cd8 100644 --- a/examples/platforms/cc2538/Makefile.am +++ b/examples/platforms/cc2538/Makefile.am @@ -36,12 +36,6 @@ libopenthread_cc2538_a_CPPFLAGS = \ -I$(top_srcdir)/src/core \ $(NULL) - -libopenthread_cc2538_settings.cpp: $(srcdir)/../utils/settings.cpp - cp $? $@ - -CLEANFILES = libopenthread_cc2538_settings.cpp - libopenthread_cc2538_a_SOURCES = \ alarm.c \ flash.c \ @@ -52,7 +46,6 @@ libopenthread_cc2538_a_SOURCES = \ random.c \ startup-gcc.c \ uart.c \ - libopenthread_cc2538_settings.cpp \ $(NULL) if OPENTHREAD_ENABLE_DIAG @@ -67,8 +60,8 @@ noinst_HEADERS = \ rom-utility.h \ $(NULL) -if OPENTHREAD_BUILD_COVERAGE -CLEANFILES += $(wildcard *.gcda *.gcno) -endif # OPENTHREAD_BUILD_COVERAGE +Dash = - +libopenthread_cc2538_a_LIBADD = \ + $(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/examples/platforms/posix/Makefile.am b/examples/platforms/posix/Makefile.am index ba91bfc7c..2bd4b9fa7 100644 --- a/examples/platforms/posix/Makefile.am +++ b/examples/platforms/posix/Makefile.am @@ -37,11 +37,6 @@ libopenthread_posix_a_CPPFLAGS = \ -D_GNU_SOURCE \ $(NULL) -libopenthread_posix_settings.cpp: $(srcdir)/../utils/settings.cpp - cp $? $@ - -CLEANFILES = libopenthread_posix_settings.cpp - libopenthread_posix_a_SOURCES = \ alarm.c \ misc.c \ @@ -51,7 +46,6 @@ libopenthread_posix_a_SOURCES = \ random.c \ uart-posix.c \ flash.c \ - libopenthread_posix_settings.cpp \ $(NULL) if OPENTHREAD_ENABLE_DIAG @@ -61,8 +55,8 @@ libopenthread_posix_a_SOURCES += \ endif if OPENTHREAD_ENABLE_NCP_SPI -libopenthread_posix_a_SOURCES += \ - spi-stubs.c \ +libopenthread_posix_a_SOURCES += \ + spi-stubs.c \ $(NULL) endif @@ -70,8 +64,12 @@ noinst_HEADERS = \ platform-posix.h \ $(NULL) +Dash = - +libopenthread_posix_a_LIBADD = \ + $(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") + if OPENTHREAD_BUILD_COVERAGE -CLEANFILES += $(wildcard *.gcda *.gcno) +CLEANFILES = $(wildcard *.gcda *.gcno) endif # OPENTHREAD_BUILD_COVERAGE include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/examples/platforms/utils/Makefile.am b/examples/platforms/utils/Makefile.am new file mode 100644 index 000000000..d4881c383 --- /dev/null +++ b/examples/platforms/utils/Makefile.am @@ -0,0 +1,46 @@ +# +# Copyright (c) 2016, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include $(abs_top_nlbuild_autotools_dir)/automake/pre.am + +lib_LIBRARIES = libopenthread-platform-utils.a + +libopenthread_platform_utils_a_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/src/core \ + $(NULL) + +libopenthread_platform_utils_a_SOURCES = \ + settings.cpp \ + $(NULL) + +noinst_HEADERS = \ + flash.h \ + $(NULL) + +include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/examples/platforms/utils/settings.cpp b/examples/platforms/utils/settings.cpp index f68f69045..d2c49949e 100644 --- a/examples/platforms/utils/settings.cpp +++ b/examples/platforms/utils/settings.cpp @@ -42,7 +42,8 @@ #include #include -#include + +#include "flash.h" #ifdef __cplusplus extern "C" { @@ -150,8 +151,8 @@ static uint32_t swapSettingsBlock(otInstance *aInstance) VerifyOrExit(pageNum > 1, ;); sSettingsBaseAddress = (swapAddress == SETTINGS_CONFIG_BASE_ADDRESS) ? - (swapAddress + settingsSize) : - SETTINGS_CONFIG_BASE_ADDRESS; + (swapAddress + settingsSize) : + SETTINGS_CONFIG_BASE_ADDRESS; initSettings(sSettingsBaseAddress, static_cast(kSettingsInSwap)); sSettingsUsedSize = kSettingsFlagSize;