How to organize your macros
You can write unnamed macros and put them in a file (e.g. macro1.C)
// macro.C
cout << "hello world" << endl;
and execute them with
root[1] .x macro1.C

You can put functions into a file e.g. macro2.C
void helloWorld() {
cout << "Hello World" << endl;

and load and execute them any function in that file im two steps:
root[2] .L macro2.C
root[3] helloWorld()
By the way, after you loaded the file, ROOT knows about your function, so instead of the above, try to hit <TAB>:
root[3] helloWo

Makefile for compilation/linking of a function and class
The following is an example of how to get your private functions and classes compiled and linked into a shared lib whcih you can dynamically load into a ROOT session. It's not elegant or sophisticated, but it works.

You need a Makefile

For the function, you produce a header.hh and source.cc file as usual. In addition, you need a LinkDef.h file (there are limitations on how the LInkDef file is named, better stick to the examples or RTM). Compile this with

For the class, you'll need the header.hh, the source.cc and the LinkDef.h-file.

To make the shared lib, do

unix-prompt> gmake

You'll get a shared library libMiscRoot.so, which you can include in your ROOT session as follows:
root[1] gSystem->Load("libMiscRoot.so");
root[2] helloWorld()
Hello World
root[3] THelloWorld hi
root[4] hi.Print()
Hello World: 0