BOARD = atmega328 PORT = /dev/term/0 LIB_DIRS = ../Common/Task ../Common/VirtualWire include ../Makefile.master
Some notes about how to use the Makefile:
- At the moment the Makefile is pretty Solaris-specific, because I haven't had the time to get it all going under a Linux VM, although the required changes are simple. Patches are welcome :-)
- You'll need the standard Arduino environment installed first, either version 0018 or 0019.
- You must use gmake as your make implementation - not usually a problem as it comes included in the Arduino environment.
The valid values for
BOARDare those found in the standard boards.txt file, that file is parsed to extract the relevant values for the Makefile.
PORTis the path of the USB port that the Arduino is attached to.
LIB_DIRSis a list of directories containing any libraries that you want to use.
The following targets are provided in the Makefile:
- all - build everything (default).
- clean - remove all generated files.
- upload - build everything and upload to the board.
- monitor - run the serial monitor.
- upload_monitor - build everything, upload to the board and run the serial monitor.
You don't need to explicitly list the various
.pdefiles that make up your application, the makefile assumes that any such files it finds in the various source directories are all to be compiled.
The processing of the Sketch (.pde) files is very simplistic, much more so than the processing done by the Arduino IDE. There's talk on the Arduino development list of splitting the Sketch-to-C++ processing out into a separate library so it can be reused, but it hasn't happened yet. I've actually stopped using .pde files and now just write my own
main.cpp, it's simple enough not to be any sort of an inconvenience to do so.
The output is all created in the
buildsubdirectory of the Sketch's directory. That means it doesn't interfere with anything if you still want to be able to use the standard Arduino environment.
Unlike the Arduino IDE which rebuilds everything every time, the Makefile only builds files that have changed. One caveat: if you change the board type in the Makefile, be sure to run
make clean; makeafterwards to rebuild everything correctly.
The Makefile builds three archive libraries in the
- libarduino.a - this contains the object code of the standard Arduino run-time libraries.
liblibrary.a - this contains the object code of any libraries you specified in the
- libsketch.a - this contains the object code of the files that comprise your Sketch.
The use of archive libraries allows the linker to only include object files that provide referenced symbols, which will result in smaller executables if you use libraries that contain code that you don't actually use in your Sketch.
I tried offering the Makefile to the Arduino developers but they seem a little, ummm... reluctant to take contributions in areas outside of their immediate goals. I understand they want to concentrate their efforts on their priorities, but if they want to grow the pool of people developing the Arduino platform (as opposed to growing the community developing on the platform) they are going to have to change their approach. It's not just me that has had this experience, the changes for the Solaris Arduino port also haven't made their way back in.
I'll write a followup post on how I've used the Makefile to enable me to use NetBeans as my Arduino development environment, including all the nice features such as code completion, pre-compilation error checking and syntax highlighting, so please check back for more!
Martin Oldfield has done more-or less the same thing, with more of a Linux slant. His version can be found here.