NASD Programmer's Documentation
Adding subdirectories to NASD

Adding subdirectories

To add a subdirectory to a directory and cause it to be compiled, include the name of that directory in the SUBDIRS assignment in the Imakefile for the parent directory. If there is not already a SUBDIRS assignment (that is, this is the first subdirectory added), also add the lines: #define IHaveSubdirs True
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
to the Imakefile. When adding new top-level subdirectories, be sure to add them to all relevant SUBDIRS assignments (different platforms use different subsets).

Adding subdirectories for conditional compilation

To add a top-level subdirectory for conditional compilation (that is, only to be compiled when a specific flag is passed to itomf), first choose a name to logically represent the directory (or set of related directories, if there is more than one). In the examples in this section, we will use the name FOO. Add a conditional definition for the directories involved to the Imakefile after the line #define Toplevel
That conditional definition should look like #if BUILD_FOO > 0
#define FOO_STUFF foo_dir1 foo_dir2
#else /* BUILD_FOO > 0 */
#define FOO_STUFF
#endif /* BUILD_FOO > 0 */
Add FOO_STUFF to the SUBDIRS list for whichever platforms are appropriate. Next, choose a command-line flag for itomf to represent your subdirectory set. In this example, we will use the letter F. Add an appropriate line to the print_usage subroutine in itomf, for example: print STDERR " -F compile foo subsystem\n";
Declare a variable to hold your flag option, after the line # ------ begin main body
It should look like:
local($opt_F);
Add your flag to the invocation of getopts(). After the call to getopts(), check if it is set, and assign variable to 1 or 0 to represent it being set or not, as in: if ($opt_F) {
  $build_foo = 1;
} else {
  $build_foo = 0;
}
On each line invoking imake after the comment #
# figure out imake command
#
add a cpp define referencing your build flag, as in -DBUILD_FOO=$build_foo
Finally, add this same text to the CONFIG_IMAKE_DEFINES assignment in config/NASD.tmpl, so that future regenerations of the Makefiles will not lose track of whether or not to conditionally compile your new collection.
<--- ---> ^<br>|<br>|
Cheops overview Adding modules NASD Programmer's Documentation