To be honest, i don't get the point why you should do this. But anyways.
There are 3 codepools in magento:
once a class or file is not fount in local the autoloader checks up community, if there is no file, it tries to load it from core.
When developing a module using an external library, for example Varien, you can place the library inside the lib folder (placed in the magento root directory) and use it in every module. There are several restriction to these libraries e.g. the classname needs to folow the magento structure (
class Namespace_Folder_Folder_File), or you can use the PSR0 Autoloader for namespaces to be able to load libraries like Elastica or something.
With this possibility you cann refactor you custom module and provide a library with the given functionality.
But if you still need to build a custom codepool in Magento there are several parts to edit:
Mage.php - add you custom codepool to the include path:
* Set include path
$paths = array();
$paths = BP . DS . 'app' . DS . 'code' . DS . 'local';
$paths = BP . DS . 'app' . DS . 'code' . DS . 'community';
$paths = BP . DS . 'app' . DS . 'code' . DS . 'core';
$paths = BP . DS . 'app' . DS . 'code' . DS . 'custom';
$paths = BP . DS . 'lib';
Your classes will also have to follow the magento class structure as explained above. This will work (i tested it seconds ago) but with this "hack" nearly noone will use your module.
Mage.php is the main file in every shop and it will be overwritten during an update.
So if you can use the suggestion with the
lib-option it'll be the best way for everyone who will use your module in the future.