scripts/config: support includes relative to the currently processed file
[openwrt.git] / scripts / config / zconf.l
index 3aef459..1dd7658 100644 (file)
@@ -343,6 +343,7 @@ void zconf_nextfile(const char *name)
        glob_t gl;
        int err;
        int i;
+       char path[PATH_MAX], *p;
 
        err = glob(name, GLOB_ERR | GLOB_MARK, NULL, &gl);
 
@@ -352,6 +353,15 @@ void zconf_nextfile(const char *name)
                gl.gl_pathc = 0;
        }
 
+       if (err == GLOB_NOMATCH) {
+               p = strdup(current_file->name);
+               if (p) {
+                       snprintf(path, sizeof(path), "%s/%s", dirname(p), name);
+                       err = glob(path, GLOB_ERR | GLOB_MARK, NULL, &gl);
+                       free(p);
+               }
+       }
+
        if (err) {
                const char *reason = "unknown error";