How does basic compilation work for an arduino project ?

I would like to use the original "serial" port code and change some things in there, like putting in extended error reporting.
I located the "hardware serial" .h and .cpp files in the arduino folder.
Am I wrong in assuming that changes I make in these will be reflected in any new project file I compliled ?
I thought that if my assumption is incorrect, there may be some other way the core code for a project is obtained but can't for the life of me think how.
So, in summary, are all the .h and .cpp files in the original core libraries examined by the compliler and re-compiled every time a project is compiled ?

It compiles them once when you compile for the first time after launching the IDE. After that, it only recompiles if the files have changed since it last compiled them.

It's probably a better idea to copy HardwareSerial.{h,cpp} under a different name into your libraries folder so you don't have to keep several versions of the core.

Thanks, much appreciated.
So, how do I go about finding out more about the full compilation process ? I would like to get the nitty gritty docs on how this works and what files are produced. I don't care if its for windoz or linux, I have arduino installed on both systems.
Some one must have asked these questions before and wading thru so many questions in the forum is draining. Even a search might not uncover the most important one.
I just want an explanation of how the core files are generated and how machine code is synthesised from the object files or what ever is produced, before the machine code is generated.

I assume you have googled for "arduino build process"

Machine code is gotten from object files via a linker. Object files are gotten from the source code with a compiler. Arduino uses avr-gcc for both.

Arduino is open source if you really want to get nitty gritty.

WizenedEE:
It compiles them once when you compile for the first time after launching the IDE. After that, it only recompiles if the files have changed since it last compiled them.

I've read that in various places, but it always seems to me judging by the list of files that scroll by and how long the process takes that that the IDE recompiles everything regardless.

I assume you have googled for "arduino build process"

Thanks, I missed that one.
Also, using your suggestion has opened a deluge of info from other sources that will keep me busy.

Much appreciated.

PeterH:

WizenedEE:
It compiles them once when you compile for the first time after launching the IDE. After that, it only recompiles if the files have changed since it last compiled them.

I've read that in various places, but it always seems to me judging by the list of files that scroll by and how long the process takes that that the IDE recompiles everything regardless.

It did prior to 1.0. Do you want to actually look at the output of your build and see if everything is as it seems?

Actually, I would like to be able to pipe the build process messages to a text file for later examination

Turn on verbose output in the IDE and copy/paste the messages to a text file.

I have turned on verbose but does'nt the buffer overflow with all those messages ?
I got the impression it was only a short scrollback buffer

I just tried compiling a relatively complicated program and got 168 lines of output starting with the invocation of the compiler and ending with the message giving the size of the program, so it seems to cope with at least that many lines. Why not try it and see ?

In a POSIX shell you can do:

arduino > file

since the IDE puts all its compilation output on standard out. You will get some extra stuff, though.