Skeletal Makefile for Arduino.

For some reason the Makefiles I looked at that came with the Arduino IDE didn't work properly and there was way too much cruft in the files for me to bother debugging them.  I was probably looking at the wrong Makefile as well -- probably some outdated example.  So I wrote my own minimalist Makefile to just have a quick way of compiling and uploading code to my Arduino Mega.

If you need a skeletal Makefile for hacking the Arduino I've made it available here:  minimalist Makefile for Arduino.  Note that any dependencies you have to the Arduino libraries you have to copy into the project and update the OBJECTS section in the Makefile accordingly.

I wanted to make a skeleton that was a bit more complete so that you can just drop "sketches" and this Makefile into a directory and have things built, but it was late and I  just wanted to quickly be able to hack some code in Emacs and have it uploaded to my Arduino.

A good idea might be to hack a script that extracts paths and such from the Arduino IDE installation (for figuring out the parameters to avrdude, the device type, device speed, patchs to the AVR-related toolchain etc (or gives you the choice to use the AVR tools you have installed on your computer instead so you don't need the IDE installed to build) and then use that to generate settings for the Makefile.

I also thought about creating a skeleton that just comes with its own copy of Wiring and the Arduino libs, but I am not sure this is a brilliant idea.  Again, if I hacked a script that just extracts the pertinent parts from an Arduino IDE installation that might be better.

In any case, the Makefile that comes with the Arduino should be cleaned up.  It is way more complicated than it needs to be and there should never be code in a Makefile.  Write small external scripts or programs instead of cluttering Makefiles with sed-snippets etc.

No comments:

Post a Comment