Pages: [1]   Go Down
Author Topic: Arduino 1.0 Makefile  (Read 5484 times)
0 Members and 1 Guest are viewing this topic.
CT, USA
Offline Offline
Sr. Member
****
Karma: 3
Posts: 446
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
http://www.kerrywong.com/2011/12/17/makefile-for-arduino-1-0/

And here is my original post on how to use NetBeans to write Arduino projects.
http://www.kerrywong.com/2010/05/16/arduino-development-using-netbeans/

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


Logged

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

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:
Code:
CXX_MODULES = \
$(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

Code:
CINCS = -I$(ARDUINO)  -I$(VARIANTS) -I$(ARDUINO_LIB)
CXXINCS = -I$(ARDUINO) -I$(VARIANTS) -I$(ARDUINO_LIB)

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.

Code:
applet/main.o:
        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
Code:
VERSION=1.00
into
Code:
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 - downloaded 23 times.)
Logged

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

Some marks

I have Duemilanove board with stock atmega168, sotck bootloader. Had to make these changes for make upload work:
Code:
UPLOAD_RATE = 19200
AVRDUDE_PROGRAMMER = arduino

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 http://www.nslu2-linux.org/). 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 smiley-wink
Logged

CT, USA
Offline Offline
Sr. Member
****
Karma: 3
Posts: 446
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

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

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

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

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

I found that to get micign's stuff working in my Ubuntu box, I needed to change this line:
Code:
CXX_MODULES += $(shell find $(ARDUINO_LIB)  -maxdepth 2 -mindepth 2 -type f -name *.cpp -exec /bin/echo -n " {}" \;)

to this:
Code:
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  smiley

EDIT:
The original build error I was receiving was something like:
Code:
blah/applet/main.cpp:xx: undefined reference to 'SomeCustomLibrary'
« Last Edit: January 15, 2013, 06:45:43 pm by kitizz » Logged

Pages: [1]   Go Up
Jump to: