#define STAMP     "manual-stamp"
#define HTMLDEST    "../../tmp/manual"

void manual()
{
    list files;
    string file;
    string cwd;
    int idx;
    string compiler;

    compiler = setOpt(CXX, "CXX");

    cwd = chdir(".");

    md("tmp/manual/examples");

    chdir("documentation");

    if (!exists("usage/usage"))
    {
        chdir("usage");
        run(compiler + " -o usage usage.cc");
        run("./usage > ../manual/invoking/usage.txt");
        chdir("..");
    }

    chdir("manual");

    files = makelist("*.yo") + makelist("*/*.yo");
    for (idx = sizeof(files); idx--; )
    {
        file = element(idx, files);
        if (file younger STAMP)
        {
            run("yodl2html -l3 bisonc++.yo");
            run("touch " STAMP);
            run("mv *.html " HTMLDEST);
            run("cp -r grammar/poly " HTMLDEST"/poly");

            run("cp -r examples/rpn " HTMLDEST"/examples");

            break;
        }
    }

    exit(0);
}


