string setWhere(string where, string defaultWhere)
{
    if (where == "")
        where = defaultWhere;

    md(where);
    return where;
}

void install(string what, string where)
{
    string path;

    if (what == "program")
    {
        if (where == "")
            where = BINARY;

        path = get_path(where);
        if (path != "")
            md(path);

        printf("  INSTALLING the executable `", where, "'\n");
        run("icmbuild install program " + where);
        exit(0);
    }

    if (what == "man")
    {
        where = setWhere(where, MAN);

        printf("  INSTALLING the manual page at `", where, "'\n");
        run("gzip -9 < tmp/man/" PROJECT ".1 > " + where + "/" PROJECT ".1.gz");
        exit(0);
    }

    if (what == "std")
    {
        where = setWhere(where, STD);

        printf("  INSTALLING the changelog at `", where, "\n");
        run("gzip -9 < changelog > " + where + "/changelog.gz");
    
        printf("  INSTALLING the html-manual page at `", where, "'\n");
        run("cp tmp/manhtml/" PROJECT ".1.html " + where);

        printf("  INSTALLING README at `", where, "\n");
        run("cp README " + where);
 
        exit(0);
    }

    exit(0);
}




