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 == "skel")
    {
        where = setWhere(where, SKEL);

        printf("  INSTALLING skeleton files at `" + where + "'\n");
        md(where);
        run("cp skeletons/* " + where);
        exit(0);
    }

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

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

    if (what == "manual")
    {
        where = setWhere(where, MANUAL);

        printf("  INSTALLING the manual at `", where, "'\n");
        run("cp -r tmp/manual " + where);
        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/" PROGRAM "man.html " + where);
        exit(0);
    }

    exit(0);
}




