==Make Variables The GCC4MBED project uses various makefile variables to configure and customize the binaries being built. This page describes these make variables. ===PROJECT The **PROJECT** variable is used in an application's makefile to indicate the name of the project being built. The output binaries with .elf, .bin, and .hex extensions will be given this as a name. The application's makefile must specify a value for this variable. ===SRC The **SRC** variable is used in an application's makefile to specify the root directory of the sources for this project. If not explicitly set by the application's makefile then it defaults to the directory in which the makefile is located. However it can be set to a different directory name if it happens that the project's source code is found in a different directory than the makefile. ===GCC4MBED_DIR The **GCC4MBED_DIR** variable is used in an application's makefile to specify the root directory location of the GCC4MBED project. This directory will be the directory which contained the GCC4MBED install scripts such as win_install.cmd, linux_install, and mac_install. The application's makefile must specify a value for this variable. ===INCDIRS The **INCDIRS** variable can be used by an application's makefile to prepend a list of directories to the INCLUDE path used by the compiler for finding #included header files. This list should be space separated. ===LIBS_PREFIX **LIBS_PREFIX** is an optional variable that an application's makefile can use to specify a list of libraries that should be linked into its final binary **before** it links in the mbed SDK libraries. ===LIBS_SUFFIX **LIBS_SUFFIX** is an optional variable that an application's makefile can use to specify a list of libraries that should be linked into its final binary **after** it links in the mbed SDK libraries. ===GCC4MBED_TYPE The **GCC4MBED_TYPE** variable is used to specify the type of build to produce. It would typically be set as an environment variable but it can also be set in the application's makefile. The allowed values are: * **Debug** - Build for debugging. Disables optimizations and links in debug MRI runtime. Best debugging experience. * **Release** - Build for release with no debug support and optimizations enabled. * **Checked** - Release build with debug support. Due to optimizations, debug experience won't be as good as Debug but might be needed when bugs don't reproduce in Debug builds. \\The default value is Release. ===OPTIMIZATION **OPTIMIZATION** is an optional variable that an application's makefile can use to override the default optimization level used by the compiler in Release/Checked builds (Debug builds always use an optimization level of 0). It defaults to 2 for Checked/Release builds. ===MRI Debugging Related Variables ====MRI_BREAK_ON_INIT The **MRI_BREAK_ON_INIT** variable can be set in an application's makefile to a non-zero value to indicate that the MRI debugger should halt and wait for GDB to attach before executing the global constructors and the main() function. This allows the developer to set breakpoints in areas of interest before the main code starts executing. The default value for this variable is 1 for Checked and Debug builds while it defaults to 0 for Release builds. ====MRI_SEMIHOST_STDIO The **MRI_SEMIHOST_STDIO** variable can be set in an application's makefile to a non-zero value to allow the debug monitor to use semi-host calls to redirect stdin/stdout/stderr to GDB's console. It defaults to 1 for Debug/Checked builds and 0 for Release builds. ====MRI_UART The **MRI_UART** is an optional variable that can be set in an application's makefile to configure the device's UART being used for communicating between GDB and MRI. You can select any of the 4 available UARTs on the mbed device: | MRI_UART_MBED_USB | | MRI_UART_MBED_P9_P10 | | MRI_UART_MBED_P13_P14 | | MRI_UART_MBED_P28_P27 | It defaults to MRI_UART_MBED_USB if not explicitly set in the application's makefile. By default the auto-baud functionality is used to allow the device to automatically detect the baud rate used by GDB when it first connects. However it is possible to configure a fixed baud rate by appending a MRI_UART_BAUD=baudRate specifier to the MRI_UART variable string. An example: {{{ MRI_UART="MRI_UART_MBED_USB MRI_UART_BAUD=115200" }}} ===Example Makefile {{{ PROJECT=HelloWorld GCC4MBED_DIR=../.. LIBS_PREFIX= LIBS_SUFFIX= include ../../build/gcc4mbed.mk }}}