]> git.ozlabs.org Git - ccan/blobdiff - tools/depends.c
ccanlint: rename obj_list in examples_compile.c to example_obj_list.
[ccan] / tools / depends.c
index ca1b6fc88b0f893814cb279f26b8ec4be3e77e9b..16f7cb69777cf733f73dda0e2358b2d32308bfb6 100644 (file)
@@ -1,5 +1,5 @@
-#include <ccan/talloc/talloc.h>
 #include <ccan/str/str.h>
+#include <ccan/talloc/talloc.h>
 #include <ccan/grab_file/grab_file.h>
 #include <ccan/str_talloc/str_talloc.h>
 #include <ccan/read_write_all/read_write_all.h>
@@ -13,7 +13,7 @@
 #include <errno.h>
 
 static char ** __attribute__((format(printf, 2, 3)))
-lines_from_cmd(const void *ctx, char *format, ...)
+lines_from_cmd(const void *ctx, const char *format, ...)
 {
        va_list ap;
        char *cmd, *buffer;
@@ -59,11 +59,12 @@ static char *compile_info(const void *ctx, const char *dir)
                return NULL;
 
        ccandir = talloc_dirname(ctx, dir);
-       *strrchr(ccandir, '/') = '\0';
+       if (strrchr(ccandir, '/'))
+               *strrchr(ccandir, '/') = '\0';
 
        compiled = maybe_temp_file(ctx, "", false, "info");
        if (compile_and_link(ctx, info_c_file, ccandir, "",
-                            CCAN_COMPILER, CCAN_CFLAGS, "",
+                            CCAN_COMPILER, CCAN_CFLAGS " -I.", "",
                             compiled, &output))
                return compiled;
        return NULL;