
void install(string request, string dest)
{
    string target;
    int components = 0;

    string base;
    base = "tmp/install/";

    md(base);

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

    if (components & 1)
    {
        printf("\n  installing documentation\n");
        logZip("", 
                   "READLINE "
                   "README "
                   "README.X11 "
                   "README.class-setup "
                   "README.immovable "
                   "README.milter "
                   "README.optimization "
                   "README.process-pipe "
                   "README.fnwrap "
                   "process-pipe.odp "
                   "process-pipe.pdf "
                   "TODO",
                base + DOC "/");
    
        logRecursive("documentation/examples", base + DOC "/examples");
    
        logZip("scripts", "", base + DOC "/scripts");

        logInstall("documentation/images", "*.jpg", base + DOC "/images");
     
        target = base + DOC + "/man";
    
        logInstall("tmp/manhtml", "", target);
    
        logInstall("documentation/man",  LIBRARY ".jpg", target);
  
        chdir(g_cwd + target);
        run("ln -sf " LIBRARY ".7.html index.html");
    
        run("ln -sf iterator.3.html reverseiterator.3.html");
    
        chdir(g_cwd + target);
        logZip("", "README", base + DOC);
    }

    if (components & 2)
    {
        printf("\n  installing the headers\n");
        logInstall("tmp/" LIBRARY, "", base + HDR);
    }


    if (components & 4)
    {
        printf("\n  installing the libraries\n");
        logInstall(g_tmpliba, "", base + LIB);

#ifdef BUILD_SHARED
        logInstall(g_tmplibso, "", base + LIB);
#endif
    }


    if (components & 8)
    {
        printf("\n  installing the manual pages\n");
    
        logZip("tmp/man/man3",  "", base + MAN "/man3");
    
        run("ln -sf iterator.3bobcat.gz reverseiterator.3bobcat.gz");
    
        logZip("tmp/man/man7",  "", base + MAN "/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(base);
    run("../../icmake/installer " + dest + "/");

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

    exit(0);
}
