void _man(string source, string nr, int usePath, string macroBase)
{
    string manDst;
    string nrs;
    string includes;

    nrs = (string)nr;
    manDst = g_install + MAN + "/man" + nrs + "/" + source + "." + nrs;
    includes = " -I.:" + g_wip + ":" + macroBase;

    run("scripts/configreplacements " +
                        "man/" + source + ".in " + 
                        g_wip + "/manyo.yo " +
                        macroBase);

    // manyo.yo is the file to convert to a man-page
    
    if (usePath)                // use yodl/yodlpost via yodl2man
    {
        putenv("YODL_BIN=" + g_cwd + g_install + BIN);
        run("yodl2man" + includes +
                        " -o" + manDst + " " 
                        "manyo");
    }
    else
    {
        run(g_install + BIN + "/yodl" + includes +
                            " -o" + g_wip + "/out man manyo");

        run(g_install + BIN + "/yodlpost " 
                            + g_wip + "/out.idx " + g_wip + "/out " + manDst);
    }
}

void manExit(string path)
{
    int usePath;
    string macroBase;

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

    if (exists("tmp/man-stamp"))        // man-pages are available
        exit(0);

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

    manualMacroList();                  // create the documentation in 
                                        // tmp/wip/macrolist.yo

                                      // where to install the man-pages
    md(g_install + MAN + "/man1 " + g_install + MAN + "/man7");

    _man("yodl",            "1", usePath, macroBase);
    _man("yodlpost",        "1", usePath, macroBase);
    _man("yodlconverters",  "1", usePath, macroBase);
    _man("yodlverbinsert",  "1", usePath, macroBase);
    _man("yodlstriproff",   "1", usePath, macroBase);


    _man("yodlbuiltins",    "7", usePath, macroBase);
    _man("yodlmanpage",     "7", usePath, macroBase);
    _man("yodlletter",      "7", usePath, macroBase);
    _man("yodlmacros",      "7", usePath, macroBase);

    run("touch tmp/man-stamp");

    exit(0);
}

