Arduino 1.0 Makefile

Hi guys,

I just modified the makefile for Arduino 018 so that it works with Arduino 1.0 now. This means that you can use your favorite IDE to develop Arduino (in my case it is the NetBeans). The latest makefile can be found at my website:

And here is my original post on how to use NetBeans to write Arduino projects.

Since I use Linux, this makefile is only tested under Ubuntu 10.04 (64bit) but it should work on all Linux systems with little or no modifications. For windows users, I think you will have to change things a little bit (for instance I am not sure what the /dev/ttyUSB0 equivalent port would be on Windows).

Hello there,

First things first: Great job AlphaZeta. I was tired fixing arduino makefile included in arduino-core package, so I used my uncle Google and tadam, here is your post.

I modified your makefile to be more generic since I wanted to have one makefile for all my sketches and just to copy it to proper dir and NOT to have to modify it.

Here are listed my modifications:

$(ARDUINO)/Tone.cpp \
$(ARDUINO)/WMath.cpp \
$(ARDUINO)/Print.cpp \
$(ARDUINO)/HardwareSerial.cpp \
$(ARDUINO)/CDC.cpp \
$(ARDUINO)/HID.cpp \
$(ARDUINO)/IPAddress.cpp \
$(ARDUINO)/new.cpp \
$(ARDUINO)/Stream.cpp \
$(ARDUINO)/USBCore.cpp \
$(ARDUINO)/WMath.cpp \
$(ARDUINO)/WString.cpp \
$(ARDUINO)/main.cpp \

CXX_MODULES += $(shell find $(ARDUINO_LIB)  -maxdepth 2 -mindepth 2 -type f -name *.cpp -exec /bin/echo -n " {}" \;)

The last line adds all .cpp files in libraries directory to compile list so I don’t have to add them when using another library in my sketch


CINCS += $(shell find $(ARDUINO_LIB) -mindepth 1 -maxdepth 2 -type d ! -name examples -exec /bin/echo -n " -I{} " \;)
CXXINCS += $(shell find $(ABDUINO_LIB) -mindepth 1 -maxdepth 2 -type d ! -name examples -exec /bin/echo -n " -I{} " \;)

Similarly, two bottom lines add all dirs in arduino’s library path to include path.

        test -d applet || mkdir applet
        echo '#include "Arduino.h"' > applet/main.cpp
        cat $(TARGET).pde >> applet/main.cpp
        cat $(ARDUINO)/main.cxx >> applet/main.cpp
        $(CXX) -c $(ALL_CXXFLAGS) applet/main.cpp -o applet/main.o

Minor bugfix, inspired by Makefile included in stock Debian testing Arduino package.

To avoid /usr/share/arduino/libraries/Firmata/Boards.h:8:25: error: floating constant in preprocessor expression i changed
VERSION=1.00 into VERSION=100

I use it on Debian Wheezy (amd64) with installed both arduino and arduino-core packages.

I’m open to anny sugesstions, I know it’s not perfect (it compiles also unneeded and unused libraries). Hope it helps anybody

Makefile (8.43 KB)

Some marks

I have Duemilanove board with stock atmega168, sotck bootloader. Had to make these changes for make upload work:


And some notice: I didn't write it earlier, my purpose was to program Arduino connected via USB to my NSLU2 with installed Debian (An ARM based, USB-capable single-board-computer, more info at And it with AlphaZeta's Makefile with my modifications it works like a charm! Now i can connect to NSLU2 via SSH, write a sketch, type make && make upload... and voila:) Even when devices stay at home and I'm at work ;)

There was a slight error in my original makefile, the applet/main.o target needs to be set to depend on main.cpp. Otherwise, compiling after changing main.cpp won't automatically pickup the change (needs a clean first). The makefile needs to be updated as follows:

applet/main.o: main.cpp
    test -d applet || mkdir applet
    $(CXX) -c $(ALL_CXXFLAGS) main.cpp -o applet/main.o

The arduino-cmake project works even better. And it'll generate project files for Eclipse, Xcode, Qt XCreator, etc. Or just command line.

I found that to get micign's stuff working in my Ubuntu box, I needed to change this line:

CXX_MODULES += $(shell find $(ARDUINO_LIB)  -maxdepth 2 -mindepth 2 -type f -name *.cpp -exec /bin/echo -n " {}" \;)

to this:

CXX_MODULES += $(shell find $(ARDUINO_LIB)  -maxdepth 2 -mindepth 2 -type f -name '*.cpp' -exec /bin/echo -n " {}" \;)

putting *.cpp in quotes, otherwise find wouldn't pick up any of the files :)

EDIT: The original build error I was receiving was something like:

blah/applet/main.cpp:xx: undefined reference to 'SomeCustomLibrary'