string g_compiler;
int g_gch = 1;

void _precompile(string class)
{
    string classIH;

    classIH = class + ".ih";
    if (classIH younger class + ".ih.gch")
        run(g_compiler + " -x c++-header " + classIH);
}

void precompileHeaders()
{
    int idx;
    list classes;
    string class;

    if (!g_gch)
        return;

    classes = makelist(O_SUBDIR, "*");


    g_compiler = setOpt(CXX, "CXX") + " " + 
                                    setOpt(CXXFLAGS, "CXXFLAGS") + " ";


    _precompile("main");         // precompile the main program .ih file


    for (idx = listlen(classes); idx--; )
    {
        class = classes[idx];

        chdir(class);

        _precompile(class);        

        chdir(g_cwd);
    }
}

