Pages: [1] 2   Go Down
Author Topic: arduino.mk (new arduino makefile, works with 1.0)  (Read 10193 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: March 17, 2013, 04:14:58 am by edam » Logged

Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1443
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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



 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

-- Francisco
Logged

Offline Offline
Full Member
***
Karma: 11
Posts: 162
IDE for Microsoft Visual Studio and Atmel Studio 6.1, optional USB Debugger
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: February 08, 2012, 05:51:50 am by visualmicro » Logged

Arduino for Microsoft Visual Studio Pro and Atmel Studio 6.1 http://www.visualmicro.com
Arduino Debugger http://www.visualmicro.com/post/2012/05/05/Debug-Arduino-Overview.aspx

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

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

- 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.

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

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!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Berlin
Offline Offline
Full Member
***
Karma: 0
Posts: 112
3D Monkey
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

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

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.

Quote
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?

Quote
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!)

Quote
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.

Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Ensenada, Mexico
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

thanks!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

love this makefile

Thanks.  :o)

Quote
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!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1] 2   Go Up
Jump to: