Makesystem

From Arctic Core - the open source AUTOSAR embedded platform

Jump to: navigation, search

Contents

General

Build system execution path schematic: Image:Build System schematic.png

The makesystem is of recuresive decent style. Files involved (building from separate project):

<anydir>                               - Your project
|--- config
|    |--- [config files]               - Overrides default module configurations
|    '--- <board>
|         '--- [config files]          - Overrides all other module configurations
|
|--- makefile
|--- [build_config.mk]  
'--- obj-<arch>
<Arctic Core>
|--- makefile
|--- boards
|    '--- <board>
|         |--- [config files]          - Default module configurations
|         '--- build_config.mk         - Configuration for the board
|
'--- scrips
     |--- config.mk
     |--- rules.mk
     '--- cc_gcc.mk

Files involved (building example from within Arctic Core tree):

<Arctic Core>
|--- makefile
|--- boards
|    '--- <board>
|         |--- [config files]          - Default module configurations
|         '--- build_config.mk         - Configuration for the board
|
|--- <anydir>
|    |--- config
|    |    |--- [config files]          - Overrides default module configurations
|    |    '--- <board>
|    |          '--- [config files]    - Overrides all other module configurations
|    |
|    |--- makefile
|    |--- [build_config.mk]  
|    '--- obj-<arch>
|
'--- scrips
     |--- config.mk
     |--- rules.mk
     '--- cc_gcc.mk

To get help from the makesystem type:

 >make help

The makesystem need to know what to build and that is specified in the BDIR environment variable. Issuing

 >make BOARDDIR=mpc5516it BDIR=<anydir>,<anydir> all

where <anydir> is any directory with a makefile for example your project directory. Other examples of <anydir> are: system/kernel,examples/simple. This first builds the kernel and then an example called simple.

When building from Arctic Studio you initiate the build in your own project, but the setting Build directory in C/C++ Build points to the Arctic Core source tree, where make is executed. A BDIR is automatically supplied which points back to your project directory.

Makefile Call Order

The top makefile will call /scripts/rules.mk but changes directory to <anydir>/obj_<arch>. rules.mk also includes the following makefiles in this order:

  1. The configuration makefile for the board, ie $(ROOTDIR)/boards/$(BOARDDIR)/build_config.mk
  2. The <anydir>/build_config.mk file.
  3. Compiler support target : $(ROOTDIR)/$(ARCH_PATH-y)/scripts/gcc.mk
  4. Compiler support generic: $(ROOTDIR)/scripts/cc_$(COMPILER).mk
  5. The makefile in <anydir>

This means that all object files (unless specified differently) will end up in the <anydir>/obj_<arch> directory.

build_config.mk under <board>

An example for a <board>/build_config.mk file

# ARCH defines
ARCH=mpc55xx
ARCH_FAM=ppc
ARCH_MCU=mpc5516
 
# CFG (y/n) macros
CFG=PPC BOOKE E200Z1 MPC55XX MPC5516 BRD_MPC551XSIM 

# What buildable modules does this board have, 
# default or private
MOD_AVAIL=KERNEL MCU GPT LIN CAN 
 
# Needed by us
MOD_USE=KERNEL MCU

build_config.mk under examples

The build_config.mk (not located in under the <board>) states what modules this example uses. Note! MOD_AVAIL is only to be used by the <board>/build_config.mk file. For an example see examples/simple/board_config.mk.

MOD_USE=KERNEL MCU GPT

Adding defines to the build is also done here:

MOD_USE+=KERNEL MCU
def-y += HEAPSIZE=400

How is AVAIL, USE and CFG expanded?

MOD_AVAIL=FOO is expanded as

MOD_FOO=y

MOD_USE=FOO is expanded as

USE_FOO=y
def-y += USE_FOO

CFG=FOO is expanded as

CFG_FOO=y
def-y += CFG_FOO

In C code CFG and MOD_USE should use

#if defined(CFG_FOO) 
#endif
#if defined(USE_FOO)
#endif

The is also the SELECT_XX=YY variables. These are currently not expanded in the makesystem. In C code SELECT should be used as

  #if (SELECT_CONSOLE & TTY_T32)
  #endif

Build variables

Build variables
Name Description
$(build-lib-y) Builds a library.
$(build-exe-y) Builds an elf file
$(def-y) Define something. E.g. def-y += HEAPSIZE=1000
$(inc-y) Include directories.
$(obj-y) Objects to build. Should end with .o
MOD_AVAIL List of modules that can that is supported by this board
MOD_USE List of modules used by this config. A subset of MOD_AVAIL.

TODO: Lots more here

Configuring

There are a lot of defines to control the behaviour of Arctic Core. Since some of the defines used in the code also defines how and what to build it was best to unify this in some way. For now variables are "generated" by the makefile using eval() (3.80+ make feature).


Prefixes
Name Description
CFG_ Tweaking of a component in some way
USE_ If we are to use a component or not

Example of how variables are created by rules.mk.

Mapping
Input Translation
CFG=HEJ HOPP CFG_HEJ=y CFG_HOPP=y def-y+=CFG_HEJ def-y += CFG_HOPP
MOD_AVAIL N/A
MOD_USE=HEJ HOPP USE_HEJ=y USE_HOPP=y def-y+=USE_HEJ def-y += USE_HOPP


Generic
Name Description
ARCH_DIR The architecture directory
CFG_BRD_ The board to use
USE_SIMULATOR Use the instruction set similator. Used by ISS targets