Go Down

Topic: A "simple" makefile for Arduino (Read 25612 times) previous topic - next topic


Thanks for all the replies. Not good news for me as I intended to do some work on borrowed sketches in VC++. Just for the context sensitivity of the IDE. I use it like that with makefiles but the Arduino files is a bit of a challenge. I might still try one more thing and that is to make a local copy of the core and the libraries that are used by the sketches.
Rather people think you to be a fool than you open your mouth and confirm it.


Hello guys,
yes, there are a lot of Makefiles there -- some work, some don't, some with limitations.
I think we should stop adapting and posting a lot of Makefiles with a lot of characteristics so I decided to create a comprehensive list of these Makefiles and try to create the most simple Makefile for Arduino ever -- that works!
For now we can compile sketches only that use standard functions and libraries (sketches with "#include" won't work, but I'm working on this).

If you want to contribute, please visit:
Blog pt_BR: http://blog.justen.eng.br/
Curso de Arduino (Arduino Course, in Brazil) - http://www.CursoDeArduino.com.br/


Thanks for that Justen. Please keep us posted here.
Rather people think you to be a fool than you open your mouth and confirm it.


Hi, just to chime in here...I also prefer Make to using the IDE.  Related to my post here: http://arduino.cc/forum/index.php/topic,69016.0.html -- I also built a simple Make build system for Arduino sketches that was based off a number of sample Makefiles I found, and my own tweaks.

I describe the build process for our stuff here: http://daisyworks.com/docs.html#tutorials -- and the Makefiles, etc. are all online at the github repo if you want to take them, hack them, modify them or whatever, feel free:  https://github.com/davisford/dw-firmwares

I didn't spend a LOT of time on this, and I'm sure it can be improved -- happy to hear any suggestions.


Before I go off and test another makefile, does it work for Windows?
Rather people think you to be a fool than you open your mouth and confirm it.


Nope, sorry.  I didn't bother trying to port it to Windows.  Why not just grab a free Linux virtual machine and use one of those?  VMWare has a ton -- you can download them and be up and running in minutes.

Anyway, it wouldn't be that hard to port the Makefile to Windows, but I probably am not going to get to that myself.


I have got Cygwin installed. Does that help any? I will have a look at the VM route.

I had a look at your makefile and I have the feeling it might just be doable in Windows. I will give it a try.
Rather people think you to be a fool than you open your mouth and confirm it.


Yes, cygwin will definitely help.  Trying to build it for native Windows cmd env. would really be a pain.  If you need any help or have questions about it, shoot me a mail @ davis 'at' daisyworks.com -- and if you do get it to work on Windows, maybe we can post a copy back to github so other people can grab it.

FYI: If you get the free vmware player: http://downloads.vmware.com/d/info/desktop_downloads/vmware_player/3_0

...then you could grab one of these: http://www.vmware.com/appliances/directory/cat/508?k=ubuntu+11&c=508

I use Ubuntu b/c it is stable and works well and it has a large repository of software.  You could get a Linux VM that has XWindows or one that doesn't.  Either way, you could turn your Windows PC into full-screen Linux in a few minutes, and hardly notice the difference, and be able to switch back and forth with ALT+TAB.  Just another option to consider.


Thanks for the links, i am on it already. Is there a context sensitive IDE for Ubuntu?

I will let you know about the windows version once I gave it a bash.
Rather people think you to be a fool than you open your mouth and confirm it.


Can you be more specific about the Ubuntu version. I don't want to download the wrong thing again. It is rather large as well. I am looking at the Gnome version 11.04 . Is this OK?
Rather people think you to be a fool than you open your mouth and confirm it.


Gnome means you're going to have a UI front end -- i.e. windowing system for it -- similar to windows.  It will probably be easier for you to deal with coming from windows, but strictly speaking, a windowing system isn't necessary for doing Linux builds of arduino projects.  You could even have VMware create a shared folder between your host (windows) and guest -- and do all your editing in windows, and then switch over to linux to run the makefile on the cmd line.

Or you could use Gnome on Linux and edit your projects in something like gedit (gnome's more capable version of notepad -- trust me, it's much better). 

So, if you do go with an X-Windows system, you have two main choices: Gnome or KDE -- it probably doesn't matter which you choose at this point...gnome is a little more popular I think.  There are other variants, as well, but this reply is already too long winded.  Using an X-windows system on your VM will definitely make your image size blow up.  You can download very simple little ubuntu VMs that have no X-Windows installed for a couple hundred meg.

The nice thing about VMs is that if you don't like it or you screw it up, you can just delete the 700MB file, and start over or get another one.  You also need some reasonable hardware to make them run ok -- your PC should have at least 2GB RAM, and a decent processor or multi-core.

One of the things I look for is to see if they have VMWare Tools installed.  This is kind of important b/c it allows you to do things like drag/drop files between the host/guest, and has better mouse/keyboard support.  I usually just create my own VMs -- so I'm not sure which one to pick exactly.  The VMWare site isn't the only place to find them.  You can google for them, or find them on torrent sites.

This is an older Ubuntu distro, but it has VMWare Tools installed: http://www.visoracle.com/vm/ubuntu810/
I take it you are looking at this one: http://www.trendsigma.net/vmware/ubuntu1104.html  -- the latter will probably be fine, but it doesn't look like it has tools installed, and AFAIK, you can't install them with VMWare Player. 

I'd suggest just experimenting with one or two, and see what fits for you.  If you have any questions, you can ping me direct at davis at daisyworks dot com, and I'll do my best to help out -- not sure if the forums here care so much about virtual machines.


Thanks a lot for putting things into perspective for me. I have installed the VM Player already so I will be looking at the OS that you suggested. This is all starting to make some sense to me as I recall having done something like this some many years ago.
Rather people think you to be a fool than you open your mouth and confirm it.



I posted a Makefile that works great with Xcode (building and uploading) at


except that #include libraries aren't taken into account.

Any idea?


I don't want to take this too much further far off track with respect to the original topic, but
for those folks looking for a linux with a more "windows" like feel, IMHO Ubuntu 11.04 should be avoided.
If you want Ubuntu, stick with 10.10
Ubuntu 11.04 has the new controversial "Unity" user interface which is nothing like a normal windows
experience. Many existing long time Ubuntu users are not happy with it.
Canonical is attempting to drive a new user interface model that is unlike what any OS has today
It is not like windows, not like MAC *and* not like any previous versions of Ubuntu.
What makes it even more painful is that it really can't
be completely disabled easily and there are many bugs when you attempt to run in the old
"classical" mode, the most serious being you can easily completely lose your window manager
if you play with or tweak compiz effects and nothing simple like logging out or rebooting will fix it.
As an alternative there is Linux Mint which is based on Ubuntu but then attempts to make
it more friendly and easier to use. IMHO linux mint is what Ubuntu should be.
It is much closer to having a MSFT Windows experience on top of linux than Ubuntu.
Windows users will be much more comfortable with Linux mint than Ubuntu especially
when looking at the latest 11.04 version of Ubuntu.

But keep in mind that since Linux mint is based on Ubuntu it can suffer from Ubuntu issues.
So Linux Mint 11 has GUI issues as well. While the Mint guys tossed some of the Ubuntu stuff
from 11.04,  since it is based on Ubuntu there are still some GUI issues.

For a trouble free easy to use somewhat Windows like experience linux, I'd use Linux Mint 10.
Mint 11 is also really good, has newer tools and is much faster at booting,
but I would recommend that you first downgrade the compiz package to avoid compiz GUI issues
if you intend to modify any of the compiz settings.

--- bill


I've been using CMake.  Below are samples of CMake build files.  They should be more or less correct.



I compile the Arduino code into separate static libraries.  Then for any program I want to upload to the board, I just link against whatever library I use.

None of the code deals with uploading to the board.  I think that should be separate from compilation.

Main makefile.

Arduino-core library.

Sample CmakeLists file.

These scripts work on Gentoo Linux, and they should work on any other Linux distro.  On Mac OS X, I remember CMake trying to link against one of the SDk's and didn't work.

Go Up