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 -n -9 < tmp/man/" PROGRAM ".1 > " + where + 
                                                    "/" PROGRAM ".1.gz");
        exit(0);
    }

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

        printf("  INSTALLING the changelog at `", where, "\n");
        run("gzip -n -9 < changelog > " + where + "/changelog.gz");
    
        printf("  INSTALLING the html-manual page at `", where, "\n");
        run("cp tmp/manhtml/" PROGRAM "man.html " + where);
        exit(0);
    }

    exit(0);
}




