arduino.mk (new arduino makefile, works with 1.0)

Hi guys,

I've written a new makefile for use with Arduino 1.0 software that I thought I'd share here. It has some useful features that I've not seen in other makefiles. I am intending it to be a drop-in replacement for the Arduino IDE, so that might make it easier to use for people who are newly departing from the Arduino IDE.

Version 0.5 was made available on 4th March, 2013. You can find it here: http://ed.am/dev/make/arduino-mk

Here's the "feature list" lifted verbatim from the link above:

  • Works with (and requires) Arduino software version 1.0 or later.
  • Easy configuration (documented below, reference in the makefile itself).
  • Automatic mode: drop-in replacement for the Arduino IDE.
  • Manual mode: specify all source files and build parameters manually.
  • Detects used Arduino libraries and includes them.
  • Supports local (project) libraries and Sketchbook libraries.
  • Simple (crap) detection of attached Arduino.
  • Reads board parameters from boards.txt.
  • Can upload to an Arduino.
  • Serial monitor function (like the IDE).
  • Generates dependency files.
  • Can burn the bootloader to your board.
  • Tested on GNU/Linux, OS X and (less so with) BusyBox on Android!

It is fairly well tested on Linux (Debian and some others) and OS X, and much less well on BusyBox. I can't vouch for other systems. But it would be great to get some feedback on it. I'm also open to suggestions on how to improve it.

Let me know what you think!

Edit: updated feature list (×4) and added version no.

Good work. I like the monitor target. And you do a complete parse of the boards.txt. Cool.

Some notes: - Is the definition of the ARDUINO macro missing? - Maybe you might add some additional gcc-options: -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums - the "screen" command is not installed by default. Maybe you should inform users to download this package. - I also assume, that there is no dependancy handling...

But all in all, it is the best Makefile i have seen so far.

Thanks!

Oliver

Thanks for this Makefile. It works like a charm here!

-- Francisco

excelent work, i'm also going to implement this in the visual studio plugin. well done all

update: it is not clear from your overview page if this supports multiple .ino/.pde files?? Thanks

Hi,

Thanks for your feedback guys! Sorry for the slow response...

olikraus: - Is the definition of the ARDUINO macro missing? - Maybe you might add some additional gcc-options: -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums - the "screen" command is not installed by default. Maybe you should inform users to download this package. - I also assume, that there is no dependancy handling...

  • fixed, thanks.
  • OK, my intention had been to mimic the options that the IDE uses to build the code. But these all seem like sensible options though; I'll add them.
  • done.
  • no... this would be nice, though. I wrote a very good dependency tracking system for another makefile (also available on my site). I'll look at adding this.

[quote author=Visual Micro link=topic=88989.msg682405#msg682405 date=1328683477] update: it is not clear from your overview page if this supports multiple .ino/.pde files?? Thanks [/quote]

No, it doesn't. In fact, it will give you an error if more than one is detected. I've made the overview more explicit about this - thanks!

I've updated the website with a new version (0.2) with the following changes:

  • added support for OS X
  • fixed building of included arduino libraries
  • notify the user when screen is missing
  • added some sensible compiler options
  • added ARDUINOCONST variable
  • search for build tools on AVRTOOLSPATH
  • added AVRDUDECONF variable and try to detect avrdude.conf

Known issue: the makefile should automatically detect Arduino software installed in /usr/share/arduino. This is already fixed for next time.

Feedback and suggestions very welcome!

I’ve updated the website with version 0.3 which has the following changes:

  • detect system arduino software in /usr/share/arduino
  • static library is build without risk of filename clashes
  • dependency file generation
  • added ‘size’ goal
  • ‘upload’ goal is no longer run by default
  • detect arduino on usbserial on OSX
  • other bug fixes

Feedback and suggestions very welcome!

I know this topic is quite old however I like to write something about my experiences.

I got it working on a Google Nexus 7 (rooted), I needed to make some changes to the Makefile, because of the busybox variants of the commands and some Android layout things.

I needed to add SHELL:=/system/bin/sh in the Makefile

The busybox rm command don’t know the -f param, so I deleted this (then it works).

The check for stty came up with “-f” but the system stty still wants -F

But now I can programm my Arduinos from my Nexus 7!

One thing: When changing the source (.ino) and then doing a make upload it will not recompile. Is this a wanted thing?

Also make all does not upload?

Thanks, Carsten

Hi,

Sorry for the delay in responding. I didn't notice that there was a reply to this thread!

calli: I needed to add SHELL:=/system/bin/sh in the Makefile

I'm not sure how I could add that to the makefile in a platform-agnostic way. Perhaps this is something you should be setting in the environment (or on the command line when calling make, or in a wrapper makefile that includes arduino.mk) for the Android platform, since it is a bit unusual.

The busybox rm command don’t know the -f param, so I deleted this (then it works).

Busybox 1.20.2 (on Debian and on CyanogenMod 7, 9 and 10) does support rm -f. And so does toolbox (that, for some reason, rm symlinks to on CM10). So this problem will likely go away as Android devices get newer versions of busybox anyway.

In the mean time, I'd be willing to try and fix this if I could think of a way to detect that rm doesn't support the -f switch. Any ideas? What version of busybox/toolbopx does rm symlink to on the Nexus 7?

The check for stty came up with “-f” but the system stty still wants -F

This looks like it's a bug in busybox. But I've changed the check, so it should work now. (If you would test this for me, I'd be ever so grateful!)

One thing: When changing the source (.ino) and then doing a make upload it will not recompile. Is this a wanted thing?

This is already fixed in the latest version.

Also make all does not upload?

No. It used to. But I changed it, because uploading is not always desirable when building the project. For example, I use Eclipse to write Arduino code and I have my project set up so recompile whenever I save a file, so that I can see immediately if there is a compilation error. I ended up deciding that, since uploading was a special function of the makefile and not strictly a part of the build process, it shouldn't happen as part of make all.

I've updated the website with version 0.4 which has the following changes:

  • the upload goal now depends on the target goal
  • added support the Leonardo
  • fixed boards goal on OS X
  • added (some) support for busybox
  • other bug fixes

Feedback and suggestions very welcome!

I just tried it and work flawless, it's the best makefile out there :)

thanks!

I've updated the website with version 0.5, which has the following changes:

  • added support for third-party libraries (via the configurable library path variable, LIBRARYPATH)
  • improved OS X spport
  • fixed support for .C c++ source files
  • made flags variables more easily modifiable
  • minor bug fixes
  • added support for burning bootloaders

Thanks to everyone who has contributed (see THANKS file)! Feedback and suggestions very welcome!

love this makefile

my only problem is that I just got an arduino due and "make boards" does not give this option

somebody already working on that?

I will try to figure it out, but if someone already got it, that would be great

any information on what to do, tips, infos welcome

Hi,

tex_: love this makefile

Thanks. :o)

my only problem is that I just got an arduino due and "make boards" does not give this option

As I understand it, you have to download and use the new Arduino 1.5 BETA library with the Arduino Duo. I had a quick look at it and it seems they've reorganised it quite a bit. Also, the IDE will likely use straight GCC (rather than the AVR GCC) to build sketches for it. So supporting the Duo would mean some major changes to the makefile.

I'm up for supporting it, though. The main thing stopping me is that I don't have a Duo to test with. But it's on my todo list!

sounds great ... I will see if I find some time to look into it ... will post progress here, if there is any ;-)

not much out there ... but this might be a starting point

http://code.google.com/p/u8glib/source/browse/sys/arduino/HelloWorld/Makefile.152.due?spec=svn4161b65e5f92bb4aad59d245c733b87b2f8c1371&r=4161b65e5f92bb4aad59d245c733b87b2f8c1371

That is a Makefile for an example of the u8glib libraries ... supporting 1.5.2 and due

have not tested it

Hi

The due makefile in the u8glib project is working. It took me some time to figure out all the gcc and ld options. Also note that bossac has been patched for Arduino. The normal bossac distribution will not work.

Oliver

Hi,

sounds great, I tried it, but could not get to work so far

stuck with some enum warnings ...

can you post your Makefile?

tex

But you have already refered to it. I just wanted to confirm that it works.

Oliver

Hi,

I was looking for a Makefile and found that one. I refered to it as a starting point because it seemed that some one figured out the new structure of the arduino 1.5.2

I thought it might help people here

I tried to get it to work for me, but so far no success, I still have problems with the gcc and ld options ... where did you fix that?