The application in this example is composed of a single C source file, for example myprog.c in the directory myprog. Writing an Imakefile is quite straightforward. First, you must set the SRCS variable to the list of source files (in this case only one).
SRCS = myprog.c
Then, you must specify how to build the executable. The macro you use depends on the type of binary you want. If you want to build a user-mode binary (for example myprog_u), use the UserActorTarget() macro, as illustrated below. The first argument is the name of the executable. The second argument lists the object files. The third argument allows you to specify which libraries your program depends on. In this example there is no library, hence the empty argument (you could also pass NullParameter).
If you want to build a supervisor-mode binary (for example, myprog_s.r), use the SupActorTarget() as shown below. The arguments are the same as for UserActorTarget().
Finally, use the Depend() macro to generate the Makefile dependencies.
The Imakefile is complete. It looks like this:
SRCS = myprog.c UserActorTarget(myprog_u,myprog.o,) SupActorTarget(myprog_s.r,myprog.o,) Depend($(SRCS))
Next, generate the Makefile with the ChorusOSMkMf tool (see the ChorusOSMkMf(1CC) manpage for details). In the myprog directory, type:
% ChorusOSMkMf build_dir
Where build_dir is the directory where you have built a ChorusOS system image on which your application will run.
Next, generate the make dependencies by typing the following command:
% make depend
Finally, compile and link the program by typing:
The program is now ready to be executed, and can be run on your target by following the steps in "Running the "Hello World" Example".
If an application used source files located in several subdirectories, you need to create a root Imakefile in the root directory, containing only the following:
#define IHaveSubdirs SUBDIRS = subdir1 subdir2 ...
where subdir1, subdir2, ... are the subdirectories containing the source files (or other intermediate root Imakefile files). Next, create an Imakefile in each subdirectory containing source files. To generate the first Makefile, go to the root directory and type:
% ChorusOSMkMf build_dir
Next, populate the tree with Makefile files, generate dependencies and finally compile the programs by typing the make Makefiles, make depend, and then make commands.
% make Makefiles % make depend % make
The program is now ready to be executed.
Examples of Imakefiles which you can modify and use to build your own applications are provided in /opt/SUNWconn/SEW/4.0/chorus-<target>/src/opt/examples.