bulk changes: main feat: GNU target

This commit is contained in:
2025-08-23 07:20:35 -04:00
parent fb12449431
commit ea32095d27
12 changed files with 817 additions and 17 deletions

View File

@@ -7,21 +7,18 @@
*/
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <stdio.h>
#include <ctype.h>
#include "../include/yait.h"
#include "util.h"
#include "contents.h"
#define emit_progress_file \
fprintf(stderr, "Created files %d\r", a); \
a++
#include "util.h"
int create_project(manifest_t manifest)
{
int status, a = 1;
int status;
char buffer[BUFSIZ];
status = mkdir_p(manifest.project);
@@ -38,13 +35,12 @@ int create_project(manifest_t manifest)
"Makefile",
".POSIX:\nCC ::= gcc\nCFLAGS ::= -Wall --std=c23 -Wpedantic\n\nall: %s",
manifest.project);
emit_progress_file;
cfprintf("README", "%s", manifest.project);
emit_progress_file;
snprintf(buffer, BUFSIZ, "%s.c", manifest.project);
flast = true;
cfprintf(buffer, "");
fprintf(stderr, "Created files %d, done.\n", a);
break;
case POSIX:
@@ -61,6 +57,7 @@ int create_project(manifest_t manifest)
cfprintf(buffer, ".\\\" %s.1 - Manual page for %s",
manifest.project, manifest.project);
flast = true;
cfprintf("doc/WHATNEXT", what_next);
break;
case FASM:
@@ -72,11 +69,46 @@ int create_project(manifest_t manifest)
"<https://github.com/tgrysztar/fasm/blob/master/FASM.TXT>");
cfprintf(
"SOURCE/main.c",
"#include <stdio.h>\n\nint main() {\n\tputs(\"Hei!\");\n\treturn 0;\n}");
"#include <stdio.h>\n\nint main() {\n\tputs(\"Who's that behind you?\");\n\treturn 0;\n}");
flast = true;
cfprintf("TOOLS/build.sh",
"#!/bin/sh\n\ncc SOURCE/main.c -o %s",
manifest.project);
break;
case GNU:
cfprintf("AUTHORS", "%s", manifest.name);
cfprintf("INSTALL",
"autoreconf -i\n./configure\nmake\nmake install");
cfprintf("COPYING", "%s", "(undefined)");
cfprintf(
"NEWS",
"%s (0.1) unstable; urgency=low\n\n * Initial release. It compiles!\n - Nothing else.\n",
manifest.project);
cfprintf(
"README",
"This is the README file for the %s distribution.\n %s does a thing.",
manifest.project, manifest.project);
cfprintf(
"configure.ac",
"AC_INIT([%s], [0.1], [you@example.com])\nAM_INIT_AUTOMAKE([-Wall -Wextra foreign])\nAC_PROG_CC\nAC_CONFIG_FILES([Makefile src/Makefile man/Makefile])\nAC_OUTPUT");
cfprintf(
"src/main.c",
"#include <stdio.h>\n\nint main(void) {\n\tputs(\"Who's that behind you?\");\n\treturn 0;\n}");
time_t t = time(NULL);
struct tm tm_info = *localtime(&t);
char date[11];
strftime(date, sizeof(date), "%Y-%m-%d", &tm_info);
snprintf(buffer, BUFSIZ, "man/%s.1", manifest.project);
flast = true;
cfprintf(
buffer,
".TH %s 1 \"%s\" \"0.1\" \"User Commands\"\n.SH NAME\n%s \\- a program that does a thing\n.SH SYNOPSIS\n.B %s\n.SH DESCRIPTION\nThis is a program that does a thing.\n.SH AUTHOR\nWritten by %s.",
manifest.project, date, manifest.project,
manifest.project, manifest.name);
break;
default:
abort();
}