
void install(string request, string dest)
{
    string target;
    int components = 0;
    list pathsplit;
    string localInstall = "tmp/install/"; // this is the LOCAL tmp/install dir

    md(localInstall);

    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 = localInstall + BINARY;
        pathsplit = path_file(target);

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

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

            printf("  installing stdconfig/simrisc at `", target, "\n");
            logZip("stdconfig", "simrisc", target);

    //      printf("  installing the pdf-manual at `", target, "\n");
    //      logInstall("tmp/pdf", "simrisc.pdf", target);
    //
    //      printf("  installing the html-manual at `", target, "\n");
    //      logInstall("tmp/manual/html", "", target + "manual");
    //      logInstall("tmp/manual/html/analysis", "",
    //                                     target + "manual/analysis");
        }

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

    if (components & 8)
    {
        target = localInstall + MAN;
        printf("  installing the man pages below `", target, "'\n");

        logZip("tmp/man", "simrisc.1", target + "/man1/");
        logZip("tmp/man", "simriscparams.7", target + "/man7/");
    }


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

    dest = cutEoln(backtick("readlink -f " + dest)[0]);

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

    chdir(localInstall);
    run("../../icmake/installer " + dest + "/");

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

    exit(0);
}
