Q: Has anyone come up with a tidy way to build NuttX with board-specific pieces outside the source tree?
There is a make target called
make export. It will build NuttX, then bundle all of the header files, libaries, startup objects, and other build components into a .zip file. You can can move that .zip file into any build environment you want. You even build NuttX under a DOS CMD window.
This make target is documented in the top level nuttx/README.txt.
You can replace the entire
apps/ directory. It is not a critical part of the OS. The
apps/ is simply provided for you to help with your application development. It should not dictate anything that that you do.
To use a different apps directory, simply execute
make menuconfig in the top-level
nuttx/ directory and redefine
CONFIG_APPS_DIR in your .config file so that it points to a different, custom application directory. Note that
CONFIG_APPS_DIR is a relative path from the top-level
You can copy any pieces that you like from the old apps/directory to your custom apps directory as necessary. This is documented in nuttx/configs/README.txt, in the NuttX Porting Guide and Build options, and in the apps/README.txt file.
If you like the random collection of stuff in the
apps/ directory but just want to expand the existing components with your own, external sub-directory then there is an easy way to that too: You just create a sympolic link in the
apps/ directory that redirects to your application sub-directory (or copy your code into a sub-directory of
In order to be incorporated into the build, the directory that you link under the apps/ directory should contain (1) a
Makefile that supports the
distclean targets (see other
Makefiles for examples), and (2) a tiny
Make.defs make file fragment that simply adds the build directories to the variable
CONFIGURED_APPS += my_directory1 my_directory2
apps/Makefile will always automatically check for the existence of subdirectories containing a
Makefile and a
Makefile will be used only to support cleaning operations. The
Make.defs file provides the set of relative pathes to directories to be built; these directories must also contain a
Makefile that can build the sources and add the object files to
apps/libapps.a archive (see other
Makefiles for examples). It should support the
apps/Makefile does not depend on any hardcoded lists of directories. Instead, it does a wildcard search to find all appropriate directories. This means that to install a new application, you simply have to copy the directory (or link it) into the
apps/ directory. If the new directory includes a
Makefile and a
Make.defs file, then it will be automatically discovered and included in the build at make time.
If the directory that you add also includes a
Kconfig file, then it will automatically be included in the NuttX configuration system as well.
apps/Makefile uses a tool at
apps/tools/mkkconfig.sh that dynamically builds the
apps/Kconfig file at pre-configuration time.
NOTE: The native Windows build is will use a corresponding tool called
You could, for example, create a script called install.sh that installs a custom application, configuration, and board specific directory:
- Add a symbolic link to
- Configure NuttX:
Use of the name
apps/external is suggested because that name is included in the .gitignore file and will save you some nuisance when working with GIT.
Suppose you would also like to support configuration variables in your external application. No problem. Thanks to Sebastien Lorquet, any external application that you install into the
apps/, whether via a symbolic link or via a directory copy, will be included into the NuttX configuration system.
Kconfig file in the
apps/ directory is automatically generated based on the contents of each
apps/ sub-directory. If your installed sub-directory contains,
Make.defs files, then it will be incorporated into the NuttX configuration system when the top-level
Kconfig file is generated.