
void install(string request, string dest)
{
    string target;
    int components = 0;
    list pathsplit;
    string base;
    base = "tmp/install/";

    md(base);

    if (request == "x")
        components = 63;
    else 
    {
        if (strfind(request, "b") != -1)
            components |= 2;
        if (strfind(request, "d") != -1)
            components |= 4;
        if (strfind(request, "m") != -1)
            components |= 8;                
    }

    if (components & 2)
    {
        target = base + BINARY;
        pathsplit = path_file(target);

        printf("  installing the executable `", target, "'\n");
        logFile("tmp/bin", "binary", pathsplit[0], pathsplit[1]);
    }

    if (components & (4 | 8))
    {
        target = base + DOC "/";
        if (components & 4)
        {
            printf("  installing changelog at `", target, "\n");
            logZip("", "changelog", target );

            printf("  installing the README file at `", target, "\n");
            logZip("", "README", target );
        }

        if (components & 8)
        {
            printf("  installing the html-manual page at `", target, "\n");
            logInstall("tmp/manhtml", "", target);
        }
    }


    if (components & 8)
    {
        target = base + MAN "/";
        printf("  installing the manual page below `", target, "'\n");
    
        logZip("tmp/man", "ssh-cron.1", target);
    }


    chdir(g_cwd);
    if (dest == "")
        dest = "/";
    else
        md(dest);

    dest = cutEoln(backtick("realpath " + dest)[0]);

    if (g_logPath != "")
        backtick("icmake/log " + dest + " " + g_logPath);

    run("tar cf - -Ctmp/install . | tar xf - -C" + dest);

    printf("\n  Installation completed\n");

    exit(0);
}
