Add MakeBinary_add_filtered_src_dir
diff --git a/src/Charmonizer/Core/Make.c b/src/Charmonizer/Core/Make.c
index 15185a7..bea3709 100644
--- a/src/Charmonizer/Core/Make.c
+++ b/src/Charmonizer/Core/Make.c
@@ -69,6 +69,12 @@
     size_t            num_binaries;
 };
 
+typedef struct {
+    chaz_MakeBinary         *binary;
+    chaz_Make_file_filter_t  filter;
+    void                    *filter_ctx;
+} chaz_MakeBinaryContext;
+
 /* Static vars. */
 static struct {
     char *make_command;
@@ -1018,6 +1024,14 @@
 
 void
 chaz_MakeBinary_add_src_dir(chaz_MakeBinary *self, const char *path) {
+    chaz_MakeBinary_add_filtered_src_dir(self, path, NULL, NULL);
+}
+
+void
+chaz_MakeBinary_add_filtered_src_dir(chaz_MakeBinary *self, const char *path,
+                                     chaz_Make_file_filter_t filter,
+                                     void *filter_ctx) {
+    chaz_MakeBinaryContext context;
     size_t num_dirs = self->num_dirs;
     char **dirs = (char**)realloc(self->dirs, (num_dirs + 2) * sizeof(char*));
 
@@ -1026,18 +1040,27 @@
     self->dirs     = dirs;
     self->num_dirs = num_dirs + 1;
 
+    context.binary     = self;
+    context.filter     = filter;
+    context.filter_ctx = filter_ctx;
+
     chaz_Make_list_files(path, "c", S_chaz_MakeBinary_list_files_callback,
-                         self);
+                         &context);
 }
 
 static void
 S_chaz_MakeBinary_list_files_callback(const char *dir, char *file,
-                                      void *context) {
+                                      void *vcontext) {
+    chaz_MakeBinaryContext *context = (chaz_MakeBinaryContext*)vcontext;
     const char *dir_sep = chaz_OS_dir_sep();
-    char *path = chaz_Util_join(dir_sep, dir, file, NULL);
 
-    S_chaz_MakeBinary_do_add_src_file((chaz_MakeBinary*)context, path);
-    free(path);
+    if (context->filter == NULL
+        || context->filter(dir, file, context->filter_ctx) != 0
+       ) {
+        char *path = chaz_Util_join(dir_sep, dir, file, NULL);
+        S_chaz_MakeBinary_do_add_src_file(context->binary, path);
+        free(path);
+    }
 }
 
 static void
@@ -1127,7 +1150,7 @@
 
 void
 chaz_Make_list_files(const char *dir, const char *ext,
-                     chaz_Make_list_files_callback_t callback, void *context) {
+                     chaz_Make_file_callback_t callback, void *context) {
     int         shell_type = chaz_OS_shell_type();
     const char *pattern;
     char       *command;
diff --git a/src/Charmonizer/Core/Make.h b/src/Charmonizer/Core/Make.h
index 10e28ac..1036a06 100644
--- a/src/Charmonizer/Core/Make.h
+++ b/src/Charmonizer/Core/Make.h
@@ -31,8 +31,10 @@
 typedef struct chaz_MakeRule chaz_MakeRule;
 typedef struct chaz_MakeBinary chaz_MakeBinary;
 
-typedef void (*chaz_Make_list_files_callback_t)(const char *dir, char *file,
-                                                void *context);
+typedef void
+(*chaz_Make_file_callback_t)(const char *dir, char *file, void *context);
+typedef int
+(*chaz_Make_file_filter_t)(const char *dir, char *file, void *context);
 
 /** Initialize the environment.
  *
@@ -66,7 +68,7 @@
  */
 void
 chaz_Make_list_files(const char *dir, const char *ext,
-                     chaz_Make_list_files_callback_t callback, void *context);
+                     chaz_Make_file_callback_t callback, void *context);
 
 /** MakeFile constructor.
  */
@@ -230,6 +232,19 @@
 void
 chaz_MakeBinary_add_src_dir(chaz_MakeBinary *self, const char *path);
 
+/** Add .c files in a directory as sources for the binary if they match
+ * a filter.
+ *
+ * @param path The path to the directory.
+ * @param filter A callback that is invoked for every source file. The
+ * source file is only added if the callback returns true. May be NULL.
+ * @param context Context passed to filter.
+ */
+void
+chaz_MakeBinary_add_filtered_src_dir(chaz_MakeBinary *self, const char *path,
+                                     chaz_Make_file_filter_t filter,
+                                     void *context);
+
 /** Add a prerequisite to the make rule of the binary.
  *
  * @param prereq The prerequisite.