Make basics

Make basics

LibrePilot build environment uses the make utility, it reads the top level Makefile and build the targets specified in command line.

Examples

Some examples of make use :

# Build all revolution firmware make all_revolution # Build all firmware and prepare archive to be packed with GCS binary make fw_resource # Erase all firmware build make all_fw_clean # Build installer package : Output a dmg (OSX), exe (Windows) or Gnu/Linux deb or rpm packages make package # Build the GCS software make gcs # Erase all previous builds make all_clean # Install ccache, build faster make ccache_install # Print all available targets make help
This Makefile is known to work on Linux and Mac in a standard shell environment. It also works on Windows by following the instructions given on this wiki page: Windows+Building+and+Packaging Here is a summary of the available targets: [Source tree preparation] prepare - Install GIT commit message template [Tool Installers] arm_sdk_install - Install the GNU ARM gcc toolchain qt_sdk_install - Install the QT development tools nsis_install - Install the NSIS Unicode (Windows only) sdl_install - Install the SDL library (Windows only) mesawin_install - Install the OpenGL32 DLL (Windows only) openssl_install - Install the OpenSSL libraries (Windows only) uncrustify_install - Install the Uncrustify source code beautifier doxygen_install - Install the Doxygen documentation generator gtest_install - Install the GoogleTest framework ccache_install - Install ccache These targets are not updated yet and are probably broken: openocd_install - Install the OpenOCD JTAG daemon stm32flash_install - Install the stm32flash tool for unbricking F1-based boards dfuutil_install - Install the dfu-util tool for unbricking F4-based boards Install all available tools: all_sdk_install - Install all of above (platform-dependent) build_sdk_install - Install only essential for build tools (platform-dependent) Other tool options are: <tool>_version - Display <tool> version <tool>_clean - Remove installed <tool> <tool>_distclean - Remove downloaded <tool> distribution file(s) [Big Hammer] all - Generate UAVObjects, build LibrePilot firmware and gcs all_flight - Build all firmware, bootloaders and bootloader updaters all_fw - Build only firmware for all boards all_bl - Build only bootloaders for all boards all_bu - Build only bootloader updaters for all boards all_clean - Remove your build directory (/home/laurent/Modelisme/LibrePilot/LibrePilot_next/build) all_flight_clean - Remove all firmware, bootloaders and bootloader updaters all_fw_clean - Remove firmware for all boards all_bl_clean - Remove bootloaders for all boards all_bu_clean - Remove bootloader updaters for all boards all_<board> - Build all available images for <board> all_<board>_clean - Remove all available images for <board> all_ut - Build all unit tests all_ut_tap - Run all unit tests and capture all TAP output to files all_ut_run - Run all unit tests and dump TAP output to console [Firmware] <board> - Build firmware for <board> Supported boards are (coptercontrol oplinkmini revolution osd revoproto simposix discoveryf4bare gpsplatinum revonano) fw_<board> - Build firmware for <board> Supported boards are (coptercontrol oplinkmini revolution osd revoproto simposix discoveryf4bare gpsplatinum revonano) fw_<board>_clean - Remove firmware for <board> fw_<board>_program - Use OpenOCD + JTAG to write firmware to <board> [Bootloader] bl_<board> - Build bootloader for <board> Supported boards are (coptercontrol oplinkmini revolution osd revoproto discoveryf4bare gpsplatinum revonano) bl_<board>_clean - Remove bootloader for <board> bl_<board>_program - Use OpenOCD + JTAG to write bootloader to <board> [Entire Flash] ef_<board> - Build entire flash image for <board> Supported boards are (coptercontrol oplinkmini revolution osd revoproto discoveryf4bare gpsplatinum revonano) ef_<board>_clean - Remove entire flash image for <board> ef_<board>_program - Use OpenOCD + JTAG to write entire flash image to <board> [Bootloader Updater] bu_<board> - Build bootloader updater for <board> Supported boards are (coptercontrol oplinkmini revolution osd revoproto discoveryf4bare revonano) bu_<board>_clean - Remove bootloader updater for <board> [Unbrick a board] unbrick_<board> - Use the STM32's built in boot ROM to write a bootloader to <board> Supported boards are (coptercontrol oplinkmini revolution osd revoproto discoveryf4bare gpsplatinum revonano) [Unittests] ut_<test> - Build unit test <test> ut_<test>_xml - Run test and capture XML output into a file ut_<test>_run - Run test and dump output to console [Simulation] sim_osx - Build LibrePilot simulation firmware for OSX sim_osx_clean - Delete all build output for the osx simulation sim_win32 - Build LibrePilot simulation firmware for Windows using mingw and msys sim_win32_clean - Delete all build output for the win32 simulation [GCS] gcs - Build the Ground Control System (GCS) application (debug|release) Compile specific directory: MAKE_DIR=<dir> Example: make gcs MAKE_DIR=src/plugins/coreplugin gcs_qmake - Run qmake for the Ground Control System (GCS) application (debug|release) gcs_clean - Remove the Ground Control System (GCS) application (debug|release) Supported build configurations: GCS_BUILD_CONF=debug|release (default is release) [Uploader Tool] uploader - Build the serial uploader tool (debug|release) uploader_qmake - Run qmake for the serial uploader tool (debug|release) uploader_clean - Remove the serial uploader tool (debug|release) Supported build configurations: GCS_BUILD_CONF=debug|release (default is release) [UAVObjects] uavobjects - Generate source files from the UAVObject definition XML files uavobjects_test - Parse xml-files - check for valid, duplicate ObjId's, ... uavobjects_<group> - Generate source files from a subset of the UAVObject definition XML files Supported groups are (gcs flight python matlab java wireshark) [Packaging] package - Build and package the platform-dependent package (no clean) fw_resource - Generate resources to embed firmware binaries into the GCS dist - Generate source archive for distribution fw_dist - Generate archive of firmware install - Install GCS to "DESTDIR" with prefix "prefix" (Linux only) [Code Formatting] uncrustify_<source> - Reformat <source> code according to the project's standards Supported sources are (flight ground) uncrustify_all - Reformat all source code [Code Documentation] docs_<source> - Generate HTML documentation for <source> Supported sources are (flight ground uavobjects) docs_all - Generate HTML documentation for all docs_<source>_clean - Delete generated documentation for <source> docs_all_clean - Delete all generated documentation [Configuration] config_new - Place your make arguments in the config file config_append - Place your make arguments in the config file but append config_clean - Removes the config file Hint: Add V=1 to your command line to see verbose build output. Notes: All tool distribution files will be downloaded into ./downloads All tools will be installed into ./tools All build output will be placed in ./build Tool download and install directories can be changed using environment variables: DL_DIR full path to downloads directory [downloads if not set] TOOLS_DIR full path to installed tools directory [tools if not set] More info: https://librepilot.atlassian.net/wiki/display/LPDOC/LibrePilot+Build+System+Overview

Parallel builds

If your system has a multicore CPU and supports parallel builds, you can load all cores of your system with command like this:

make -j4 gcs

This means make start and run four tasks at same time.

 

Wondering how much time your build takes? Try to add the time command before make:

time make -j4 package

 

If you need more verbose output while make is running, you can add V=1 to command line:

 make -j8 V=1 all_flight

 

A typical command line for GCS build and start:

 make -j2 fw_resource && make -j2 gcs && ./build/librepilot-gcs_release/bin/librepilot-gcs

 

 

Comments