diff --git a/configure.c b/configure.c index b0cbee6..6d1f1a7 100644 --- a/configure.c +++ b/configure.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -306,22 +307,29 @@ collect_sources(char *dir, bool head, char *ext) free(na); continue; } - if (!strchr(name, '.') && - strcmp(name, "out") && - strcmp(name, "Makefile")) { - str_array_t *sub; char *d1 = string_cat(dir, "/"); char *d2 = string_cat(d1, name); size_t i; + struct stat sb; - sub = collect_sources(d2, false, ext); - for (i = 0; i < str_array_len(sub); i++) + if (stat(d2, &sb)) { - char *file = str_array_get(sub, i); - str_array_add(ret, file); + fprintf(stderr, "stat(2) %s: %s\n", d2, strerror(errno)); + free(d2); + free(d1); } - str_array_free(sub); + else if (S_ISDIR(sb.st_mode)) + { + str_array_t *sub = collect_sources(d2, false, ext); + for (i = 0; i < str_array_len(sub); i++) + { + char *file = str_array_get(sub, i); + str_array_add(ret, file); + } + str_array_free(sub); + } + free(d2); free(d1); }