From e42881c4d1f70a6425981782216ab6212b415b42 Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Thu, 13 Nov 2025 15:27:13 -0500 Subject: [PATCH] wip --- proj.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 87 insertions(+), 4 deletions(-) diff --git a/proj.c b/proj.c index 3f9b80f..35db282 100644 --- a/proj.c +++ b/proj.c @@ -7,8 +7,11 @@ */ #include +#include +#include #include "estruct.h" +#include "wrapper.h" #include "file.h" #include "input.h" #include "proj.h" @@ -48,6 +51,8 @@ int makeproj(char *src) { #include \n\ #include \n\ \n\ +#include \"version.h\"\n\ +\n\ void usage(int status)\n\ {\n\ printf(\"Usage: %%s REQUIRED POSITIONAL ARGUMENT\\n\", PROGRAM_NAME);\n\ @@ -71,14 +76,20 @@ int main(int argc, char **argv)\n\ exit(EXIT_SUCCESS);\n\ }\n\ }\n\ +\n\ + puts(\"Hello, World!\");\n\ \n\ return 0;\n\ }", src, author, src, src); + size_t len = strlen(src) + 1 + strlen(author) + 6; /* account for " 1.0 " */ + char *pad = xmalloc(len + 1); + memset(pad, '-', len); + pad[len] = '\0'; ffwrite("README", "\ -+--------------------+\n\ ++%s+\n\ | %s/%s 1.0 |\n\ -+--------------------+\n\ ++%s+\n\ \n\ %s\n\ \n\ @@ -122,18 +133,90 @@ derived from uEmacs/PK 4.0 specifically from the Linux Torvalds\n\ distribution on GitHub. The README on from uEmacs/PK 4.0 has greater and\n\ more accurate attributions, if you desire.\n\ \n\ -%s was generated using yait/fSD %s.\n\ +%s was generated using %s %s\n\ \n\ LAST MODIFED DATE\ ", + pad, src, author, + pad, description, src, author, src, year, author, src, author, src, author, description, src, author, - src, VERSION); + src, PROGRAM_NAME_LONG, VERSION); + + ffwrite("version.h", "\ +#ifndef VERSION_H_\n\ +#define VERSION_H_\n\ +\n\ +#define PROGRAM_NAME \"%s\"\n\ +#define PROGRAM_NAME_LONG \"%s/%s\"\n\ +\n\ +#define VERSION \"1.0.0\"\n\ +\n\ +/* Print the version string. */\n\ +void version(void);\n\ +\n\ +#endif /* VERSION_H_ */", src, src, author); + ffwrite("version.c", "\ +#include \n\ +#include \"version.h\"\n\ +\n\ +void version(void)\n\ +{\n\ + printf(\"%%s version %%s\\n\", PROGRAM_NAME_LONG, VERSION);\n\ +}"); + + ffwrite("Makefile", "\ +# Makefile for %s\n\ +\n\ +# Make the build silent by default\n\ +V =\n\ +\n\ +ifeq ($(strip $(V)),)\n\ + E = @echo\n\ + Q = @\n\ +else\n\ + E = @\\#\n\ + Q =\n\ +endif\n\ +export E Q\n\ +\n\ +PROGRAM = %s\n\ +TARBALL = $(PROGRAM).tar\n\ +SRC = $(wildcard *.c)\n\ +OBJ = $(SRC:.c=.o)\n\ +HDR = $(wildcard *.h)\n\ +\n\ +CC = gcc\n\ +WARNINGS = -Wall -Wstrict-prototypes\n\ +CFLAGS = -O2 $(WARNINGS) -g\n\ +DEFINES =\n\ +LIBS =\n\ +LDFLAGS =\n\ +BINDIR = /usr/bin\n\ +LIBDIR = /usr/lib\n\ +\n\ +$(PROGRAM): $(OBJ) $(HDR)\n\ + $(E) \" LINK \" $@\n\ + $(Q) $(CC) $(LDFLAGS) $(DEFINES) -o $@ $(OBJ) $(LIBS)\n\ +\n\ +clean:\n\ + $(E) \" CLEAN\"\n\ + $(Q) rm -f $(PROGRAM) $(OBJ)\n\ +\n\ +install: $(PROGRAM)\n\ + cp $(PROGRAM) ${BINDIR}\n\ +\n\ +release: $(PROGRAM)\n\ + tar cvf $(TARBALL) $(SRC) $(HDR) Makefile README\n\ +\n\ +.c.o:\n\ + $(E) \" CC \" $@\n\ + $(Q) $(CC) $(CFLAGS) $(DEFINES) -c $< -o $@", src, src); return 0; }