Skip to content

Target.mk

eschul07 edited this page May 3, 2020 · 5 revisions

Purpose of this document

This document is meant to describe the purpose of and the content found within target.mk. Every supported target board has its own target.mk.

target.mk

Target.mk is a small makefile fragment found within src/main/target/<target board>. It’s main purpose is to set several variables that are used in the mainline make process.

The first variable set (at the top of the file) is the target’s group. Here, the specific target board is assigned to a “target group”. These are groups of targets categorized by their onboard microcontroller.

For example, here is the target group variable being assigned in the target.mk for SPRACINGF4EVO:

F405_TARGETS  += $(TARGET)

There are a total of six target groups: F1_TARGETS, F3_TARGETS, F4_TARGETS, F7_TARGETS, H7_TARGETS, SITL_TARGETS, and MAIXBIT_TARGETS. (In the example above, F405_TARGETS eventually gets incorporated into F4_TARGETS). The target group variable is used later in the make process by the targets.mk file. See the targets.mk document for more details.

Our capstone group has added the group MAIXBIT_TARGETS to the MAIXBIT target.mk to accommodate our Maixbit board:

MAIXBIT_TARGETS  += $(TARGET)

Other makefile variables defined in target.mk are: FEATURES, and TARGET_SRC. FEATURES defines whether on-board flash or VCP are used by the target board.

FEATURES    = VCP SDCARD_SPI

TARGET_SRC gets populated with Betaflight source files for peripheral drivers such as, acc/gyro, barometer, compass, etc.

TARGET_SRC = \
            drivers/accgyro/accgyro_mpu6500.c \
            drivers/accgyro/accgyro_spi_mpu6500.c \
            drivers/barometer/barometer_bmp280.c \
            drivers/barometer/barometer_ms5611.c \
            drivers/compass/compass_ak8975.c \
            drivers/compass/compass_hmc5883l.c \
            drivers/compass/compass_qmc5883l.c \
            drivers/compass/compass_lis3mdl.c \
            drivers/max7456.c \
            drivers/vtx_rtc6705.c

It can also be helpful to look at other board’s target.mk files to become more familiar with the contents.

Clone this wiki locally