[Tinyos-devel] Include paths

R. Steve McKown rsmckown at yahoo.com
Sat Sep 23 20:17:11 PDT 2006


Hi Sean,

I know I'm replying to an old post, but I recently completed building a new 
platform definition in TinyOS and thought it might be useful to document what 
I learned for others.  These comments apply to TinyOS 2.x; I am unsure if 
they apply for the 1.x series.

On Friday 15 September 2006 06:49 am, Sean Walton wrote:
> Can anyone tell me how nesC determines which files to include when
> compiling a file.  It appears that tos.h is included by default; are
> there other files included by default?

The nesC compiler (ncc) builds, or compiles into, a single .c file (app.c) the 
union of the .nc files required to satisfy all components referenced 
recursively from the root component, defined in a project's Makefile as 
COMPONENT.  #include statements in the .nc files are passed through to the 
app.c result generated by ncc.  The include paths used by ncc are passed 
through to to the C compiler (gcc) so it can find the referenced .h files.

nesC source files (.nc) are located by searching the list of include paths.  
There are various places where ncc can get paths to add to its list of 
include paths:

1. From the project makefile, such as "PFLAGS += -Isomedir".

2. In the <platform>.target file, based upon the platform for which you are 
building (aka "make micaz").  Target files are searched for in the paths 
listed in the TOSMAKE_PATH var, which includes TOSROOT/support/make by 
default.

3. In .platform files for included platforms.  The target file will include 
one or more platforms via the TOSMake_include_platform macro.  Each included 
platform should have a .platform file locatable in a dir on the search path 
whose last directory component is the name of the platform.  Standard 
platform dirs are found in $TOSDIR/tos/platforms.  The include paths listed 
in included .platform files don't show up, BTW, in makefile output.  Note 
that %T in these files is set to the current TOSDIR.

4. In .extra files that might be included as part of your command line.

5. There is a sensorboard feature, but I haven't looked at this yet.  This 
functionality must also add to the list of include paths.

I'm sure it's been said before, but the build system in TinyOS 2 is a 
phenomenally powerful tool, yet surprisingly easy to get one's head around.  
Compared to other build systems I've used (and written...!) in the past, I 
most appreciate its layered encapsulation and intuitive behavior, which 
allows a programmer not interested in underlying details to be able to 
effectively ignore them.  Yet at the same time, someone wanting to get into 
the details -- such as for creating a new platform specification -- can do so 
easily and without much heartache.


More information about the Tinyos-devel mailing list