Part of a function called run_make which should check if the target in the make file exists nd is up to date.
// check if the target exists and is up to date
    struct stat target_stat;
    struct stat dep_stat;
    if (stat(rule->target, &target_stat) == 0) {
        // target file exists
        int up_to_date = 1;
        for (Dependency *dep = rule->dependencies; dep != NULL; dep = dep->next_dep) {
            if (stat(dep->rule->target, &dep_stat) != 0) {
                // dependency file doesn't exist, so target is not up to date
                up_to_date = 0;
                break;
            }
            if (dep_stat.st_mtim.tv_sec > target_stat.st_mtim.tv_sec ||
                (dep_stat.st_mtim.tv_sec == target_stat.st_mtim.tv_sec &&
                 dep_stat.st_mtim.tv_nsec > target_stat.st_mtim.tv_nsec)) {
                // dependency file is more recent than target file
                up_to_date = 0;
                break;
            }
        }
        if (up_to_date) {
            // target is up to date, so no need to run actions
            return;
        }
    }