This section describes how to build a ChorusOS component with imake and the basic operations needed to manage your component. The information is provided in the form of a tutorial, leading you through an example which shows you how to perform each step.
The procedures below show you how to build a very simple ChorusOS component
called TEST
, containing an application that displays
a short message.
TEST
ComponentCreate a TEST directory in your /tmp directory to contain your new component.
host% cd /tmp/TEST host% mkdir TEST
Add the files listed below to the TEST directory
Makefile.bin
Makefile.src
Project.tmpl
Imakefile
src.df
Examples of these files are given below.
TEST
Component: Makefile.bin
The Makefile.bin file can contain the following information:
COMPONENT += TEST ROOT += $(TEST_DIR)/root TEST.all::
The first line in the output, which declares the component's name, is mandatory.
As the COMPONENT variable is the list of all components to be configured, use '+=', and not '='.
The ROOT variable contains a list of directories to be copied to the target root file system.
TEST
Component: Makefile.src
The Makefile.src file, can contain the following information:
all:: TEST.all TEST.all:: NUCLEUS.all OS.all DRV.all TEST.all:: $(TEST_DIR)/DONE $(TEST_DIR)/DONE: $(TEST_DIR)/Makefile sh $(DEVTOOLS_DIR)/resync TEST -f $(TEST) -s $(TEST_DIR) cd $(TEST_DIR); $(make) touch $(TEST_DIR)/DONE $(TEST_DIR)/Makefile: $(TEST)/Imakefile sh $(DEVTOOLS_DIR)/ChorusOSMkMf $(BUILD_DIR) -s $(TEST) -b $(TEST_DIR) -d $(TEST_DIR) cd $(TEST_DIR); $(make) Makefiles TEST_DIST = $(BUILD_DIR)/dist-TEST TEST.dist: TEST.all rm -rf $(TEST_DIST) cd $(TEST_DIR); $(make) DIST_DIR=$(TEST_DIST)
This file is more complex than the Makefile.bin
file as it describes how to build the component. The first lines of output
give the list of components that must be built before the TEST
component.
As your application requires operating system services, you must build
the NUCLEUS
and OS
components
before building the TEST
component.
TEST
Component: Project.tmpl
The Project.tmpl file can contain the following information:
#include "Package.rules" SRC_DIR = SourceDir BUILD_DIR = BuildDir DIST_DIR = DistDir VPATH = $(SRC_DIR)$(REL_DIR) WARN = $(WARN_ON) TEST_DIST_BIN = $(DIST_DIR)/bin/test
TEST
Component: Imakefile
The Imakefile indicates that you will have subdirectories (in this case /src).
#define IHaveSubdirs SUBDIRS = \ src DistFile(Makefile.bin,$(DIST_DIR))
TEST
Component: src.df
The src.df contains the following information:
. ../Paths VARIABLES="OS_DIR NUCLEUS_DIR" BDIR=${BUILD_DIR} SUB_DIRS=src
This file sets the parameters required for the make command to work.
You now need to create an application for the TEST
component to perform.
Create a subdirectory, src, within your /tmp/TEST directory.
host% cd /tmp/TEST host% mkdir src
Create the following two files:
This source file will say "Hello World":
#include <stdio.h> int main() { /* Print the message */ printf("Hello World\n"); return 0; }
This file provides rules to build the application:
CSRCS= bonjour.c OBJS= $(CSRCS:.c=.o) DEBUG=$(DEBUG_ON) UserActorTarget(bonjour_u,bonjour.o,) SupActorTarget(bonjour_s, bonjour.o,) DistActor(bonjour_u, $(DIST_DIR)/root/test/src) DistActor(bonjour_s, $(DIST_DIR)/root/test/src)The Imakefile file declares:
The source files to be compiled.
The libraries to be used.
The fact that you want to build the bonjour actor.
The fact that you want to copy the bonjour actor into the root/bin directory, once it is built.
Build your component in your work directory using the make command
host% make
Add the bonjour binary file to the target file system
host% make root
Once you have created the component, with its application, you must include it in the system configuration.
Run make reconfigure
Use the make reconfigure command in the directory in build_dir in which you have previously run configure to build your system image. Run make to compile your component:
host% make reconfigure='-s /tmp/TEST'
Compile the component
Type make to compile your TEST
component.
host% rm -rf build_dir/build-TEST host% make