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 == "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/" PROJECT "man.html " + where);

        printf("  INSTALLING logrotate mold  as `", 
                    where, "/scripts/etc/logrotate.d/target.gz'\n");
        md(where + "/scripts/etc/logrotate.d");
        run("gzip -9 < share/etc/logrotate.d/target > " + 
                    where + "/scripts/etc/logrotate.d/target.gz");

        printf("  INSTALLING cleanup script as `", 
                    where, "/scripts/etc/stealth/cleanup.rc.gz'\n");
        md(where + "/scripts/etc/stealth");
        run("gzip -9 < share/etc/stealth/cleanup.rc > " + 
                where + "/scripts/etc/stealth/cleanup.rc.gz");

        printf("  INSTALLING additional scripts at `", 
                        where, "/scripts/usr/bin'\n");
        md(where + "/scripts/usr/bin");
        run("gzip -9 < share/usr/bin/stealthcleanup > " + 
                where + "/scripts/usr/bin/stealthcleanup.gz");
        run("gzip -9 < share/usr/bin/stealthcron > " + 
                where + "/scripts/usr/bin/stealthcron.gz");
        run("gzip -9 < share/usr/bin/stealthmail > " + 
                where + "/scripts/usr/bin/stealthmail.gz");

        exit(0);
    }

    if (what == "extra")
    {
        where = setWhere(where, EXTRA);

        printf("  INSTALLING the changelog at `", where, "'\n");
        run("gzip -9 < changelog > " + where + "/changelog.gz");

        printf("  INSTALLING README and ACKNOWLEDGEMENTS at `", where, "\n");
        run("cp README README.3.00.00 ACKNOWLEDGEMENTS " + where);
 
        printf("  INSTALLING examples at `", where, "'\n");
        md(where + "/examples");
        run("gzip -9 < documentation/example-policies/demo.pol > " + 
                                        where + "/examples/demo.pol.gz");
        run("gzip -9 < documentation/example-policies/localhost.pol > " + 
                                        where + "/examples/localhost.pol.gz");
        run("gzip -9 < documentation/example-policies/simple.pol > " + 
                                        where + "/examples/simple.pol.gz");

        printf("  INSTALLING CROSS REFERENCE INFO at `", where, "\n");
        run("gzip -9 < stealth.xref > " + where + "/stealth.xref.gz");
    }

    exit(0);
}




