# Building in Mac OS X Building in Mac OS X can be accomplished in just a few steps: * Install general development tools (clang, make, git) * Install ARM GCC 4.8 series compiler * Checkout Cleanflight sourcecode through git * Build the code ## Install general development tools (clang, make, git) Open up a terminal and run `make`. If it is installed already, you should see a message like this, which means that you already have the required development tools installed: ``` make: *** No targets specified and no makefile found. Stop. ``` If it isn't installed yet, you might get a popup like this. If so, click the "install" button to install the commandline developer tools: ![Prompt to install developer tools](assets/mac-prompt-tools-install.png) If you just get an error like this instead of a helpful popup prompt: ``` -bash: make: command not found ``` Try running `xcode-select --install` instead to trigger the popup. If that doesn't work, you'll need to install the XCode development environment [from the App Store][]. After installation, open up XCode and enter its preferences menu. Go to the "downloads" tab and install the "command line tools" package. [from the App Store]: https://itunes.apple.com/us/app/xcode/id497799835 ## Install ARM GCC 4.8 series compiler Cleanflight is built using the 4.8 series GCC compiler provided by the [GNU Tools for ARM Embedded Processors project][]. The newest "4.9" series compiler produces builds that don't boot on CC3D and Sparky targets (and perhaps others), so it's better to use the older 4.8 compiler for the moment. Hit the "all downloads" link on the right side of the GNU Tools for ARM page to view [the older releases][]. Grab the Mac installation tarball for the latest version in the 4.8 series (e.g. 4.8-2014-q3-update). Move it somewhere useful such as a `~/development` folder (in your home directory) and double click it to unpack it. You should end up with a folder called `~/development/gcc-arm-none-eabi-4_8-2014q3/`. Now you just need to add the `bin/` directory from inside the GCC directory to your system's path. Run `nano ~/.profile`. Add a new line at the end of the file which adds the path for the `bin/` folder to your path, like so: ``` export PATH=$PATH:~/development/gcc-arm-none-eabi-4_8-2014q3/bin ``` Press CTRL+X to exit nano, and answer "y" when prompted to save your changes. Now *close this terminal window* and open a new one. Try running: ``` arm-none-eabi-gcc --version ``` You should get output similar to: ``` arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.4 20140725 (release) [ARM/embedded-4_8-branch revision 213147] Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ``` If `arm-none-eabi-gcc` couldn't be found, go back and check that you entered the correct path in your `~/.profile` file. [GNU Tools for ARM Embedded Processors project]: https://launchpad.net/gcc-arm-embedded [the older releases]: https://launchpad.net/gcc-arm-embedded/+download ## Checkout CleanFlight sourcecode through git Enter your development directory and clone the [Cleanflight repository][] using the "HTTPS clone URL" which is shown on the right side of the Cleanflight GitHub page, like so: ``` git clone https://github.com/cleanflight/cleanflight.git ``` This will download the entire Cleanflight repository for you into a new folder called "cleanflight". [CleanFlight repository]: https://github.com/cleanflight/cleanflight ## Build the code Enter the cleanflight directory and run `make TARGET=NAZE` to build firmware for the Naze32. When the build completes, the .hex firmware should be available as `obj/cleanflight_NAZE.hex` for you to flash using the Cleanflight Configurator. ## Updating to the latest source If you want to erase your local changes and update to the latest version of the Cleanflight source, enter your cleanflight directory and run these commands to first erase your local changes, fetch and merge the latest changes from the repository, then rebuild the firmware: ``` git reset --hard git pull make clean TARGET=NAZE make TARGET=NAZE ``` Or in the case of CC3D in need of a `obj/cleanflight_CC3D.bin` ``` make clean TARGET=CC3D make TARGET=CC3D OPBL=yes ```