void _link(string program)
{
    exec(COMPILER, "-o", g_install + BIN + "/" + program,
                    g_wip + "/" + program + "/*.o", 
                    "-L" + g_wip, "-lyodl", g_lopt);
}

void _buildProgram(string program)
{
    std_cpp(g_wip + "/" + program, 0, program, "");
    _link(program);
}

void _programYodl()
{
    buildBuiltins();
    _buildProgram("yodl");
}

void _programYodlpost()
{
    _buildProgram("yodlpost");
}

void _programYodlverbinsert()
{
    run(COMPILER + " -o " + g_install + BIN + "/yodlverbinsert " + g_copt +
                   " src/verbinsert/verbinsert.c " + g_lopt);
}

void program(string target)
{
    md(g_install + BIN);

    if (target == "programs" || target == "yodlstriproff")
        run("cp scripts/yodlstriproff " + g_install + BIN);

    if (target == "programs" || target == "yodl2whatever")
        run("scripts/configreplacements " +
                        "scripts/yodl2whatever.in " + 
                        g_install + BIN + "/yodl2whatever " +
                        g_install);

    if (target == "yodlstriproff" || target == "yodl2whatever")
        return;

    compileRSS();

    if (target == "programs" || target == "yodl")
        _programYodl();

    if (target == "programs" || target == "yodlpost")
        _programYodlpost();

    if (target == "programs" || target == "yodlverbinsert")
        _programYodlverbinsert();

}

void programExit(string target, string strip)   // build one program, 
{                                               // called from main
    #ifndef PROFILING
        if (strip == "strip")
            g_lopt = "-s";
    #endif

    program(target);
    exit(0);
}

void programsExit(string strip)                 // build all programs,
{                                               // called from main
    #ifndef PROFILING
        if (strip == "strip")
            g_lopt = "-s";
    #endif

    program("programs");
    exit(0);
}
