Monday, July 6, 2015

Using a Makefile to build for Arduino

When doing software development for Arduino, there is no doubt that the Arduino IDE is a nice tool for getting up and running quickly. For people with less experience in software development, it might even be the best way to code for the Arduino. However, having done C/C++ development for 25 years, I find that I miss my preferred editor. I also am comfortable with Make, so I decided to see if I could create my own makefiles for building for Arduino.

I had previously found Other Projects for using Make to build for the Arduino. Unfortunately, I don't think this project is what I'm looking for. I'd really like a small (one-page) Makefile that I can wrap my head around. The in the sudar/Arduino-Makefile project is over 1,500 lines. I'm sure it is very full featured and robust, but not something that I want to start hacking on.

I took the sketch for my Stepper Motors sketch and built it clean using the Arduino IDE. Then looked at the build commands it ran, and created a Makefile to replicate its build process. I extracted some paths and some other things to variables which could be tweaked. The resulting Makefile is short and succinct (though at 75 lines still may be a bit more than what fits on a single page).

One can run


to build the project and

    make upload

to upload it to the Arduino programmer.

No comments:

Post a Comment