diff options
Diffstat (limited to 'make.c')
-rw-r--r-- | make.c | 37 |
1 files changed, 32 insertions, 5 deletions
@@ -6,7 +6,7 @@ #include "maje.h" -static void make_header(FILE *makefile, const char *target) +static void make_header(FILE *makefile, const char *target, struct majeflag *flags) { fprintf(makefile, ".POSIX:\n\n"); fprintf(makefile, "# This Makefile was generated by maje\n"); @@ -15,9 +15,31 @@ static void make_header(FILE *makefile, const char *target) fprintf(makefile, "CC=c99\n"); fprintf(makefile, "LD=$(CC)\n"); - fprintf(makefile, "CFLAGS=-Wall -Wextra -Wpedantic -Werror -g\n"); - fprintf(makefile, "LDFLAGS=\n"); - fprintf(makefile, "LDLIBS=\n"); + + fprintf(makefile, "CFLAGS=-Wall -Wextra -Wpedantic -Werror -g"); + for (struct majeflag *flag = flags; flag != NULL; flag = flag->next) { + if (flag->type == MAJE_CFLAG) { + fprintf(makefile, " %s", flag->flag); + } + } + fprintf(makefile, "\n"); + + fprintf(makefile, "LDFLAGS="); + for (struct majeflag *flag = flags; flag != NULL; flag = flag->next) { + if (flag->type == MAJE_LDFLAG) { + fprintf(makefile, " %s", flag->flag); + } + } + fprintf(makefile, "\n"); + + fprintf(makefile, "LDLIBS="); + for (struct majeflag *flag = flags; flag != NULL; flag = flag->next) { + if (flag->type == MAJE_LDLIB) { + fprintf(makefile, " %s", flag->flag); + } + } + fprintf(makefile, "\n"); + fprintf(makefile, "SRCDIR=.\n"); fprintf(makefile, "OBJDIR=.\n"); fprintf(makefile, "BINDIR=$(OBJDIR)\n"); @@ -60,7 +82,12 @@ void make_makefile(const char *makepath, struct majefile *sources, const char *t return; } - make_header(makefile, target); + struct majeflag *flags = NULL; + for (struct majefile *src = sources; src != NULL; src = src->next) { + flags = add_flags(src, flags); + } + + make_header(makefile, target, flags); for (struct majefile *src = sources; src != NULL; src = src->next) { add_object(makefile, src, target); } |