diff options
author | Jakob Kaivo <jkk@ung.org> | 2020-01-14 11:36:56 -0500 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2020-01-14 11:36:56 -0500 |
commit | ac4540cf63dd92b6be7530c44893591b16c97308 (patch) | |
tree | 98b21908fae13f7f9686b54ed332e9f04428995f | |
parent | 0a2235b3a5d5f7daabf5233220f58eea848fe831 (diff) |
compile *.o instead of sources again
-rw-r--r-- | make.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -1,4 +1,5 @@ #define _XOPEN_SOURCE 700 +#include <string.h> #include <stdio.h> #include "maje.h" @@ -19,8 +20,11 @@ static void make_header(FILE *makefile, const char *target) static void addfile(FILE *makefile, const char *src, const char *target) { - fprintf(makefile, "%s: %s\n", src, src); - fprintf(makefile, "%s: %s\n", target, src); + char *obj = strdup(src); + obj[strlen(obj) - 1] = 'o'; + + fprintf(makefile, "%s: %s\n", obj, src); + fprintf(makefile, "%s: %s\n", target, obj); } void make_makefile(const char *makepath, char **sources, const char *target) @@ -37,11 +41,7 @@ void make_makefile(const char *makepath, char **sources, const char *target) } fprintf(makefile, "%s:\n", target); - fprintf(makefile, "\t$(CC) -o $@"); - for (char **src = sources; *src != NULL; src++) { - fprintf(makefile, " %s", *src); - } - fprintf(makefile, "\n"); + fprintf(makefile, "\t$(CC) -o $@ *.o\n"); fclose(makefile); } |