Library Build Procedure

I'm writing a AVR integrated development environment and I'm trying to figure out how Arduino handles the building of libraries.

Since Arduino boards now have 6 different chips and 2 common clock speeds, the libraries would need to be recompiled for every different build.

But it seems like the only thing the sketch writer needs to do is to write the include preprocessor statement with to add a library to their sketch.

So how does the environment know which files to compile? Search for the directory that matches the include statement and then scan that entire folder for .c and .cpp files to compile?

(EDIT, ok I peeked into the java source code, it does look like there's something that scans for preprocessor includes, maybe copying everything into a temporary build folder, which makes me wonder what happens if a name conflict occurs?)

As far as i understand the build process of the Arduino library then first of all the libraries are compiled every time you change the type of atmel.
also, if you look at some core libraries as well as some 3rd party ones you can see that parts of code use #ifdef preprocessor routines to check if an 328, 168 or 1280(mega?) is being used to compile just the important part for that.

i hope that was the informatiion you wanted...

i was wondering how the environment knows what the user has imported, i think i found the answer, i'm going to implement the same thing with regular expressions searching for the preprocessor include statements.

the environment rebuilds the library every time you click verify i believe, several versions before i think they were compiled when you started the environment, very annoying.