diff --git a/3_Sully/Makefile b/3_Sully/Makefile index f2c3570..2372c1d 100644 --- a/3_Sully/Makefile +++ b/3_Sully/Makefile @@ -4,7 +4,13 @@ CLONE = Sully_4.c \ Sully_3.c \ Sully_2.c \ Sully_1.c \ - Sully_0.c \ + Sully_0.c CREATE_CLONE = ./$(NAME) +RM_MORE = rm -f +RM_MORE += Sully_4 \ + Sully_3 \ + Sully_2 \ + Sully_1 \ + Sully_0 include ../MakefileCommon diff --git a/3_Sully/Sully.c b/3_Sully/Sully.c index 2dfca74..8c1117e 100644 --- a/3_Sully/Sully.c +++ b/3_Sully/Sully.c @@ -3,6 +3,6 @@ #include #define xstr(s) #s #define str(s) xstr(s) -#define FT(s) int main() { char *before = "#define _GNU_SOURCE /* for asprintf */\n#include /* for free and system */\n#include \n#define xstr(s) #s\n#define str(s) xstr(s)\n#define FT(s) "; char *quine = s; char *after = "\nint i = %i;\nFT(str(FT(s)))\n"; i--; char *kid_name; char *kid_name_c; char *decremented_after; char *cmd; asprintf(&kid_name, "Sully_%i", i); asprintf(&kid_name_c, "%s.c", kid_name); FILE *file = fopen(kid_name_c, "w"); asprintf(&decremented_after, after, i); fprintf(file, "%s%s%s", before, quine, decremented_after); fclose(file); asprintf(&cmd, "clang %1$s -o %2$s ; ./%2$s", kid_name_c, kid_name); printf("cmd: %s\n", cmd); if (i > 0) {system(cmd); }free(kid_name_c); free(kid_name); free(decremented_after); free(cmd); return 0; } +#define FT(s) int main() { char *before = "#define _GNU_SOURCE /* for asprintf */\n#include /* for free and system */\n#include \n#define xstr(s) #s\n#define str(s) xstr(s)\n#define FT(s) "; char *quine = s; char *after = "\nint i = %i;\nFT(str(FT(s)))\n"; i--; char *kid_name; char *kid_name_c; char *decremented_after; char *cmd; asprintf(&kid_name, "Sully_%i", i); asprintf(&kid_name_c, "%s.c", kid_name); FILE *file = fopen(kid_name_c, "w"); asprintf(&decremented_after, after, i); fprintf(file, "%s%s%s", before, quine, decremented_after); fclose(file); asprintf(&cmd, "clang %1$s -o %2$s ; ./%2$s", kid_name_c, kid_name); printf("cmd: %s\n", cmd); if (i > 0) {system(cmd); } free(kid_name_c); free(kid_name); free(decremented_after); free(cmd); return 0; } int i = 5; FT(str(FT(s))) diff --git a/MakefileCommon b/MakefileCommon index a6a6df1..ca5cfdd 100644 --- a/MakefileCommon +++ b/MakefileCommon @@ -35,6 +35,7 @@ RESET = "\e[0m" #SRCS -> defined in subfolder makefiles #CLONE -> defined in subfolder makefiles #CREATE_CLONE -> defined in subfolder makefiles +#RM_MORE -> might be defined in subfolder makefiles LIBS = D_SRCS = . D_HEADERS = . @@ -117,6 +118,7 @@ clean: fclean: clean rm -f $(NAME) rm -f $(CLONE) + $(RM_MORE) re: fclean all