ChorusOS 5.0 Source Delivery Guide

Makefile.src

The Makefile.src file is more complex than the Makefile.bin file, as it describes how the component is compiled using the mkmk tool.

The Makefile.src file for the KTS component is shown below, as an example. The KTS Makefile.src file provides following information:


Example 3-5 Makefile.src File for Flite

The following example shows a Makefile.src for Flite, created using mkmerge.

#****************************************************************
#
# Component = flite
#
# Synopsis  =   
#
# Copyright 1999,2001  Sun Microsystems, Inc. All rights reserved. 
#
#****************************************************************
#
# #ident  "@(#)Makefile.src 1.9     01/10/03 SMI"
#
#****************************************************************

all:: FLITE.all

FLITE.all:: $(OS_DIR)/exports.lst
FLITE.all:: $(FLITE_DIR)/DONE

$(FLITE_DIR)/exports.lst:
        rm -rf $(FLITE_DIR)
        $(DEVTOOLS_DIR)/host/bin/mkmerge -s $(FLITE) -t $(FLITE_DIR)

$(FLITE_DIR)/Makefile: $(FLITE_DIR)/exports.lst
        rm -f $(FLITE_DIR)/Makefile
        cd $(FLITE_DIR); $(DEVTOOLS_DIR)/host/bin/mkmk -t $(NUCLEUS_DIR)

$(FLITE_DIR)/DONE: $(FLITE_DIR)/Makefile
        sh $(DEVTOOLS_DIR)/resync FLITE -f $(FLITE) -s $(FLITE_DIR)
        cd $(FLITE_DIR); $(make)
        touch $(FLITE_DIR)/DONE

FLITE_DIST = $(BUILD_DIR)/dist-FLITE
FLITECP = lib
FLITE.dist: FLITE.all
        rm -rf $(FLITE_DIST)
        mkdir -p $(FLITE_DIST)
        cp $(FLITE)/Makefile.bin $(FLITE_DIST)
        cd $(FLITE_DIR); cp -pr $(FLITECP) $(FLITE_DIST)

##
$(OS_DIR)/DONE: $(FLITE_DIR)/DONE


Example 3-6 Makefile.src for the drivers

The following example shows a Makefile.src for the drivers, created with Imake.

#****************************************************************
#
# Component = drivers
#
# Synopsis  =   
#
# Copyright 1998,2001  Sun Microsystems, Inc. All rights reserved. 
# 
#
#****************************************************************
#
# #ident  "@(#)Makefile.src 1.3     01/10/03 SMI"
#
#****************************************************************

MYDRV_SRC = $(MYDRV)/src

all:: MYDRV.all 

MYDRV.all:: NUCLEUS.all
MYDRV.all:: $(MYDRV_DIR)/DONE

$(MYDRV_DIR)/DONE : $(MYDRV_DIR)/Makefile
        cd $(MYDRV_DIR); $(make)
        touch $(MYDRV_DIR)/DONE

$(MYDRV_DIR)/Makefile: $(MYDRV_SRC)/Imakefile
        sh $(DEVTOOLS_DIR)/ChorusOSMkMf $(BUILD_DIR) -s $(MYDRV_SRC) 
        -b $(MYDRV_DIR) -d $(MYDRV_DIR)
        cd $(MYDRV_DIR); $(make) Makefiles


The all Makefile Target and Component Dependency

Each component implements the component.all rule, which is defined in the component's Makefile.src file. This rule tells you what other components this component is dependent upon. The component.all rule in the Makefile.src implements the rule, building the component in its own build directory. If this first component depends on a second component, the dependency rule is expressed in the Makefile.src file of the first component, as shown below:

component1.all :: component2.all

If the dependency is valid only for the build process, the dependency rule is expressed in the Makefile.src file.

DONE

When a component is compiled correctly, its Makefile.src file creates a file called DONE in the build--COMPONENT directory. The DONE file prevents make from entering a component's build directory when there is nothing else to compile. If you run the make command, and the Makefile.src file has already created the DONE file, nothing will happen. These DONE files must be removed if a component has been modified, and the dependent components need to be re-linked.

For example, to remove the DONE file for the NUCLEUS component:

host% rm -f build-NUCLEUS/DONE

Run make now and it will enter the NUCLEUS component. Run the make command a second time and you will get no output, as the DONE file is now present.