summaryrefslogtreecommitdiff
path: root/make.c
diff options
context:
space:
mode:
Diffstat (limited to 'make.c')
-rw-r--r--make.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/make.c b/make.c
index 4f8b204..683410f 100644
--- a/make.c
+++ b/make.c
@@ -1,4 +1,5 @@
#define _XOPEN_SOURCE 700
+#include <libgen.h>
#include <string.h>
#include <stdio.h>
@@ -6,29 +7,31 @@
static void make_header(FILE *makefile, const char *target)
{
- fprintf(makefile, ".POSIX:\n");
+ 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, "# Do not edit this Makefile by hand\n");
+ fprintf(makefile, "# Do not edit this Makefile by hand\n\n");
- fprintf(makefile, "default: all\n");
+ fprintf(makefile, "default: all\n\n");
fprintf(makefile, "CC=c99\n");
- fprintf(makefile, "CFLAGS=-Wall -Wextra -Wpedantic -Werror -g\n");
+ fprintf(makefile, "CFLAGS=-Wall -Wextra -Wpedantic -Werror -g\n\n");
- fprintf(makefile, "all: %s\n", target);
+ fprintf(makefile, "all: %s\n\n", target);
fprintf(makefile, "clean:\n");
- fprintf(makefile, "\trm -f %s *.o\n", target);
+ fprintf(makefile, "\trm -f %s *.o\n\n", target);
}
static void addfile(FILE *makefile, const char *src, const char *target)
{
char *obj = strdup(src);
obj[strlen(obj) - 1] = 'o';
+ obj = basename(obj);
- fprintf(makefile, "%s: %s\n", obj, src);
fprintf(makefile, "%s: %s\n", target, obj);
+ fprintf(makefile, "%s: %s\n", obj, src);
+ fprintf(makefile, "\t$(CC) $(CFLAGS) -c %s\n\n", src);
}
void make_makefile(const char *makepath, char **sources, const char *target)