summaryrefslogtreecommitdiff
path: root/make.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-04-25 19:01:05 -0400
committerJakob Kaivo <jkk@ung.org>2022-04-25 19:01:05 -0400
commit50f99eabe9204d6a1cc7cd00b5d09a02bf1f1a6f (patch)
tree9e2c640796b6789c64f4b2f6c22ffa9fb23c5b64 /make.c
parentde3ccad4e9d3573d7c02f7b5e58ac951f9b3b23e (diff)
make directories before trying to put things in them
Diffstat (limited to 'make.c')
-rw-r--r--make.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/make.c b/make.c
index 1e21332..5d2c808 100644
--- a/make.c
+++ b/make.c
@@ -10,7 +10,7 @@ static void make_header(FILE *makefile, const char *target)
{
fprintf(makefile, ".POSIX:\n\n");
fprintf(makefile, "# This Makefile was generated by maje\n");
- fprintf(makefile, "# See https://gitlab.com/jkaivo/maje/ for more information\n");
+ fprintf(makefile, "# See https://src.kaivo.net/dev/maje/ for more information\n");
fprintf(makefile, "# Do not edit this Makefile by hand\n\n");
fprintf(makefile, "CC=c99\n");
@@ -30,6 +30,7 @@ static void make_header(FILE *makefile, const char *target)
fprintf(makefile, "\trm -f $(BINDIR)/%s $(OBJDIR)/*.o\n\n", target);
fprintf(makefile, "install: $(BINDIR)/%s\n", target);
+ fprintf(makefile, "\tmkdir -p $(DESTDIR)/bin\n");
fprintf(makefile, "\tcp $(BINDIR)/%s $(DESTDIR)/bin\n\n", target);
}
@@ -45,6 +46,7 @@ static void add_object(FILE *makefile, const struct majefile *src, const char *t
obj, inc->path);
}
fprintf(makefile, "$(OBJDIR)/%s: $(SRCDIR)/%s\n", obj, src->path);
+ fprintf(makefile, "\t@mkdir -p $(@D)\n");
fprintf(makefile, "\t$(CC) $(CFLAGS) -o $@ -c $(SRCDIR)/%s\n\n", src->path);
free(fullobj);
@@ -64,6 +66,7 @@ void make_makefile(const char *makepath, struct majefile *sources, const char *t
}
fprintf(makefile, "$(BINDIR)/%s:\n", target);
+ fprintf(makefile, "\t@mkdir -p $(@D)\n");
fprintf(makefile, "\t$(LD) $(LDFLAGS) -o $@ $(OBJDIR)/*.o $(LDLIBS)\n");
fclose(makefile);