void _manual(string conversion, int usePath, string macroBase)
{
    string includes;
    string manualDestination;

    if (exists("tmp/" + conversion + "-manual-stamp"))
        return;

    includes = " -I.:" + g_wip + ":" + macroBase + ":manual/yo";

    manualDestination =  g_install + DOCDOC;

    if (usePath)
    {
        putenv("YODL_BIN=" + g_cwd + g_install + BIN);
        run("yodl2" + conversion + includes + 
            " -o" + manualDestination +
            " manual");
    }
    else
    {
        run(g_install + BIN + "/yodl" + includes + 
                            " -o" + g_wip + "/out " +
                            conversion + " manual");
        if (conversion == "latex")
            run("mv " + g_wip + "/out " + g_install + DOCDOC + "/yodl.latex");
        else
        {
            run(g_install + BIN + "/yodlpost "
                        + g_wip + "/out.idx " + g_wip + "/out " +
                        "yodl." + conversion);
            run("mv yodl*." + conversion + " " + manualDestination);
        }
    }

    if (conversion == "latex")
    {
        chdir(g_install + DOCDOC);

        runP(P_NOCHECK, "latex yodl.latex");
        runP(P_NOCHECK, "latex yodl.latex");
        run("latex yodl.latex");
        run("rm yodl.aux yodl.log yodl.toc");

        run("dvips -o yodl.ps yodl.dvi");
        run("ps2pdf yodl.ps yodl.pdf");
        chdir(g_cwd);
    }
    run("touch tmp/" + conversion + "-manual-stamp");
}

void manualMayExit(string path, int doExit) // doExit == 0, then only html
{
    int idx;
    int usePath;
    string macroBase;

    usePath = path == "path";
    macroBase = g_wip + "/macros";

                                       // build the macros for the man(ual)
                                       // "./": use the current dir for 
                                       // finding macros
    buildMacros(macroBase, "tmp/man-macros-stamp", "./");

    manualMacroList();
    
    md(g_install + DOCDOC);

    _manual("html", usePath, macroBase);

    if (doExit)
    {
        _manual("txt", usePath, macroBase);
        _manual("latex", usePath, macroBase);
        exit(0);
    }
}

void manualExit(string path)
{
    manualMayExit(path, 1);
}









