diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html
index 69d81797ce..d5003860ee 100644
--- a/Documentation/NuttxPortingGuide.html
+++ b/Documentation/NuttxPortingGuide.html
@@ -754,6 +754,9 @@
| |-- Make.defs
| `-- defconfig
| ...
+|-- scripts/
+| |-- (linker script files)
+| `-- Make.defs (optional
`-- (other board-specific configuration sub-directories)/
@@ -788,7 +791,14 @@
Each board configuration is described by two files: Make.defs
and defconfig
.
Typically, each set of configuration files is retained in a separate configuration sub-directory
(<config1-dir>, <config2-dir>, .. in the above diagram).
-
+
+
+ NOTE: That the Make.defs
file may reside in one of two locations:
+ There may be a unique Make.defs file for each configuration in the configuration directory OR
+ if that file is absent, there may be a common board Make.defs
file in the /scripts
directory.
+ The Make.defs
file in the configuration takes precedence if it is present.
+
+
The procedure for configuring NuttX is described below,
This paragraph will describe the contents of these configuration files.
diff --git a/README.txt b/README.txt
index 7344defac1..42d51047c5 100644
--- a/README.txt
+++ b/README.txt
@@ -606,10 +606,15 @@ Instantiating "Canned" Configurations
to the directory where you installed NuttX (TOPDIR):
Copy configs///Make.def to{TOPDIR}/Make.defs
+ OR
+ Copy configs//scripts/Make.def to{TOPDIR}/Make.defs
Make.defs describes the rules needed by you tool chain to compile
and link code. You may need to modify this file to match the
- specific needs of your toolchain.
+ specific needs of your toolchain. NOTE that a configuration may
+ have its own unique Make.defs file in its configuration directory or
+ it may use a common Make.defs file for the board in the scripts/
+ directory. The first takes precedence.
Copy configs///defconfig to{TOPDIR}/.config
diff --git a/configs/b-l475e-iot01a/nsh/Make.defs b/configs/b-l475e-iot01a/scripts/Make.defs
similarity index 98%
rename from configs/b-l475e-iot01a/nsh/Make.defs
rename to configs/b-l475e-iot01a/scripts/Make.defs
index 899cfeb22f..8b8d4ae4a9 100644
--- a/configs/b-l475e-iot01a/nsh/Make.defs
+++ b/configs/b-l475e-iot01a/scripts/Make.defs
@@ -1,5 +1,5 @@
############################################################################
-# configs/b-l475e-iot01a/nsh/Make.defs
+# configs/b-l475e-iot01a/scripts/Make.defs
#
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
#
@@ -115,4 +115,4 @@ HOSTLDFLAGS =
define DOWNLOAD
$(Q) echo "Download firmware $(1).bin"
$(Q) st-flash write $(1).bin 0x08000000
-endef
\ No newline at end of file
+endef
diff --git a/configs/same70-xplained/nsh/Make.defs b/configs/same70-xplained/nsh/Make.defs
deleted file mode 100644
index 2395a389c2..0000000000
--- a/configs/same70-xplained/nsh/Make.defs
+++ /dev/null
@@ -1,128 +0,0 @@
-############################################################################
-# configs/same70-xplained/nsh/Make.defs
-#
-# Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
-# Author: Gregory Nutt
-#
-# 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 NuttX 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 OWNER 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 ${TOPDIR}/.config
-include ${TOPDIR}/tools/Config.mk
-include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
-
-ifeq ($(CONFIG_ARMV7M_DTCM),y)
- LDSCRIPT = flash-dtcm.ld
-else
- LDSCRIPT = flash-sram.ld
-endif
-
-ifeq ($(WINTOOL),y)
- # Windows-native toolchains
- DIRLINK = $(TOPDIR)/tools/copydir.sh
- DIRUNLINK = $(TOPDIR)/tools/unlink.sh
- MKDEP = $(TOPDIR)/tools/mkwindeps.sh
- ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
- ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
- ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
-else
- # Linux/Cygwin-native toolchain
- MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
- ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
- ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
- ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
-endif
-
-CC = $(CROSSDEV)gcc
-CXX = $(CROSSDEV)g++
-CPP = $(CROSSDEV)gcc -E
-LD = $(CROSSDEV)ld
-AR = $(CROSSDEV)ar rcs
-NM = $(CROSSDEV)nm
-OBJCOPY = $(CROSSDEV)objcopy
-OBJDUMP = $(CROSSDEV)objdump
-
-ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
-ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
-
-ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
- ARCHOPTIMIZATION = -g
-endif
-
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
- ARCHOPTIMIZATION += $(MAXOPTIMIZATION)
-endif
-
-ARCHCFLAGS = -fno-builtin
-ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
-ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing
-ARCHWARNINGSXX = -Wall -Wshadow -Wundef
-ARCHDEFINES =
-ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
-
-CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
-CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
-CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
-CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
-CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
-AFLAGS = $(CFLAGS) -D__ASSEMBLY__
-
-NXFLATLDFLAGS1 = -r -d -warn-common
-NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
-LDNXFLATFLAGS = -e main -s 2048
-
-# Loadable module definitions
-
-CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
-
-LDMODULEFLAGS = -r -e module_initialize
-ifeq ($(WINTOOL),y)
- LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libc/modlib/gnu-elf.ld}"
-else
- LDMODULEFLAGS += -T $(TOPDIR)/libc/modlib/gnu-elf.ld
-endif
-
-ASMEXT = .S
-OBJEXT = .o
-LIBEXT = .a
-EXEEXT =
-
-ifneq ($(CROSSDEV),arm-nuttx-elf-)
- LDFLAGS += -nostartfiles -nodefaultlibs
-endif
-ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
- LDFLAGS += -g
-endif
-
-
-HOSTCC = gcc
-HOSTINCLUDES = -I.
-HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe
-HOSTLDFLAGS =
-
diff --git a/configs/same70-xplained/netnsh/Make.defs b/configs/same70-xplained/scripts/Make.defs
similarity index 99%
rename from configs/same70-xplained/netnsh/Make.defs
rename to configs/same70-xplained/scripts/Make.defs
index a1cf44caa4..8f71542ad8 100644
--- a/configs/same70-xplained/netnsh/Make.defs
+++ b/configs/same70-xplained/scripts/Make.defs
@@ -1,5 +1,5 @@
############################################################################
-# configs/same70-xplained/netnsh/Make.defs
+# configs/same70-xplained/scripts/Make.defs
#
# Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt
diff --git a/tools/configure.c b/tools/configure.c
index f27224e429..dc1f639112 100644
--- a/tools/configure.c
+++ b/tools/configure.c
@@ -92,6 +92,7 @@ static char *g_topdir = NULL; /* Full path to top-level NuttX buil
static char *g_apppath = NULL; /* Full path to the application directory */
static char *g_configtop = NULL; /* Full path to the top-level configuration directory */
static char *g_configpath = NULL; /* Full path to the configuration sub-directory */
+static char *g_scriptspath = NULL; /* Full path to the scripts sub-directory */
static char *g_verstring = "0.0"; /* Version String */
static char *g_srcdefconfig = NULL; /* Source defconfig file */
@@ -555,6 +556,16 @@ static void check_configdir(void)
}
g_configpath = strdup(g_buffer);
+
+ snprintf(g_buffer, BUFFER_SIZE, "%s%cconfigs%c%s%cscripts",
+ g_topdir, g_delim, g_delim, g_boarddir, g_delim);
+ debug("check_configdir: Checking scriptspath=%s\n", g_buffer);
+
+ g_scriptspath = NULL;
+ if (verify_optiondir(g_buffer))
+ {
+ g_scriptspath = strdup(g_buffer);
+ }
}
static void read_configfile(void)
@@ -724,14 +735,32 @@ static void check_configuration(void)
g_srcdefconfig = strdup(g_buffer);
+ /* Try the Make.defs file */
+
snprintf(g_buffer, BUFFER_SIZE, "%s%cMake.defs", g_configpath, g_delim);
debug("check_configuration: Checking %s\n", g_buffer);
if (!verify_file(g_buffer))
{
- fprintf(stderr, "ERROR: Configuration corrupted in %s\n", g_configpath);
- fprintf(stderr, " No Make.defs file found.\n");
- enumerate_configs();
- exit(EXIT_FAILURE);
+ /* An alternative location is the scripts/ directory */
+
+ if (g_scriptspath != NULL)
+ {
+ snprintf(g_buffer, BUFFER_SIZE, "%s%cMake.defs", g_scriptspath, g_delim);
+ debug("check_configuration: Checking %s\n", g_buffer);
+ if (!verify_file(g_buffer))
+ {
+ fprintf(stderr, "ERROR: No Make.defs file in %s\n", g_configpath);
+ fprintf(stderr, " No Make.defs file in %s\n", g_scriptspath);
+ enumerate_configs();
+ exit(EXIT_FAILURE);
+ }
+ }
+ else
+ {
+ fprintf(stderr, "ERROR: No Make.defs file in %s\n", g_configpath);
+ enumerate_configs();
+ exit(EXIT_FAILURE);
+ }
}
g_srcmakedefs = strdup(g_buffer);
diff --git a/tools/configure.sh b/tools/configure.sh
index e994904824..449d223697 100755
--- a/tools/configure.sh
+++ b/tools/configure.sh
@@ -140,8 +140,13 @@ src_makedefs="${configpath}/Make.defs"
dest_makedefs="${TOPDIR}/Make.defs"
if [ ! -r "${src_makedefs}" ]; then
- echo "File \"${src_makedefs}\" does not exist"
- exit 4
+ boardpath=`dirname $configpath`
+ src_makedefs="${boardpath}/scripts/Make.defs"
+
+ if [ ! -r "${src_makedefs}" ]; then
+ echo "File Make.defs could not be found"
+ exit 4
+ fi
fi
src_config="${configpath}/defconfig"