I'm working on getting the ArduPilot mega 2.x to compile outside the IDE using make (which will also allow it to be compiled in Eclipse, or NetBeans or whatever)
It is a work in progress :(
Is anyone else interested in this? otherwise I'll just do it for my own amusement.
So far I've found the following problems, which mainly relate to the way the Arduino IDE tries to auto-handle C function and variable prototype declarations.
1. Functions are used before being declared
2. Functions are marked static in a file, but are actually used by other files.
3. There is no .h file declaring all the global variables, structures and constants in use
My solution so far is to
1. Add declaration statements at the top of modules where functions, not necessarily externally useful ones that belong in proto.h, are used before the code for them.
2. Build up a proto.h file that is included by every file that is full of "extern .." declarations to define the functions and variables in use all over.
3. Remove "static" in front of functions that are in one file, but used externally to that file (are in proto.h)
As for the makefile, there is a generator written in ruby that does the job of creating the makefile automatically. It works ok, so that hasn't been a problem.
Once the compile errors are killed, and the hex file is created, I'll make sure it uploads it the same way the IDE does.
Basically all I want to do is muck around with the code base in a small filesystem tree, using vi. Then type "make" and "make install" to upload. The IDE was a nice fast start but now it gets in the way.
Replies
Hi,
Are you still pursuing this? Last weekend I noticed that at least since the svn->git transition there is a cmake based build pipeline and even a java tool that emulates the arduino IDE method of merging pde files (thanks, development team! :) . Had to do some minor changes to adapt it to my APM1280 but now I can build and even upload the latest git repo version (taking some stuff out I don't need to reduce the memory footprint, of course). Pretty cool actually.. guess the guys are using it for building the hex images of the mission planner. Once I find the time I maybe write the steps down but it's not much more then just running cmake and make.
We've already written a tutorial on using Eclipse in the manual here.
The guide to using a makefile is here.