ChorusOS 5.0 Application Developer's Guide

Building Makefiles with ChorusOSMkMf

ChorusOSMkMf is a host utility that enables the creation of a Makefile from an Imakefile for an application. ChorusOSMkMf uses imake to generate the Makefile from a project template, a set of cpp macros, and the application's Imakefile. In most cases, an Imakefile contains three things:

The following procedure shows how ChorusOSMkMf is used in the development life cycle. The application in this procedure is composed of a single C source file, for example, myprog.c in the directory myprog.

Using ChorusOSMkMf

Writing an Imakefile is straightforward.

  1. Set the SRCS variable to the list of source files.

    In this example there is only one:

    SRCS = myprog.c
  2. Specify how to build the executable.

    The macro required depends on the type of binary you want. To build a user-mode binary (for example myprog_u), use the UserActorTarget() macro, as illustrated in the following example. The first argument is the name of the executable. The second argument lists the object files. The third argument enables you to specify which libraries your program depends on. In the following example there is no library, therefore, there is an empty argument (you could also pass a NullParameter).

    UserActorTarget(myprog_u,myprog.o,)

    To build a supervisor-mode binary (for example, myprog_s.r), use the SupActorTarget() macro as follows. The arguments are the same as for UserActorTarget().

    SupActorTarget(myprog_s.r,myprog.o,)
  3. Use the Depend() macro to generate the Makefile dependencies.

    Depend($(SRCS))

    The complete Imakefile is as follows:

    SRCS = myprog.c
    UserActorTarget(myprog_u,myprog.o,)
    SupActorTarget(myprog_s.r,myprog.o,)
    Depend($(SRCS))
  4. Generate the Makefile with the ChorusOSMkMf() tool.

    In the myprog directory, type:


    % ChorusOSMkMf <build_dir>
    

    Where build_dir is the directory where the ChorusOS system was built and from which the application will run.

  5. Generate the make dependencies.

    To do this, type:


    % make depend
    
  6. Compile and link the program.

    To do this type:


    % make
    

    The program is now ready to be executed.