From 50f99eabe9204d6a1cc7cd00b5d09a02bf1f1a6f Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Mon, 25 Apr 2022 19:01:05 -0400 Subject: make directories before trying to put things in them --- make.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); -- cgit v1.2.1