int main(int argc, char **argv) {
    FILE *fp;
    char *filename = "Makefile";
    char *target = NULL;
    int output = 0;
    int parallel = 0;
    char opt;

    while ((opt = getopt(argc, argv, "f:op")) != -1) {
        switch (opt) {
            case 'o':
                output = 1;
                break;
            case 'p':
                parallel = 1;
                break;
            case 'f':
                filename = optarg;
                break;
            default:
                fprintf(stderr, "Usage: %s [-op] [-f <filename>] [target]\n", argv[0]);
                exit(1);
        }
    }

    if (optind < argc) {
        target = argv[optind];
    }
    if ((fp = fopen(filename, "r")) == NULL) {
        perror("fopen");
        exit(1);
    }

    Rule *rules = parse_file(fp);
    fclose(fp);

    if (output) {
        print_rules(rules);
    }

    run_make(target, rules, parallel);

    return 0;
}