This commit is contained in:
2025-10-28 21:29:19 -04:00
parent fb004394b4
commit 6af34bfd0d
3 changed files with 132 additions and 72 deletions

3
config.mak Normal file
View File

@@ -0,0 +1,3 @@
PREFIX=/usr/local
CFLAGS=-pedantic -O0 -ggdb -Wall -Wextra -Wpedantic -fno-omit-frame-pointer -DDEBUG
CC=gcc

44
config.status Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/sh
# DO NOT MODIFY. THIS IS A AUTOGENERATED SCRIPT FROM 'configure'
#
# COMPILATION (Linux - POSIX):
# ./config.status
#
#
# LICENSE: BSD-3-Clause
#
# Copyright (c) 2025 GCK
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
printf "config.status: recreating config.mak... "
{
printf "PREFIX=%s\n" "/usr/local"
printf "CFLAGS=%s\n" "-pedantic -O0 -ggdb -Wall -Wextra -Wpedantic -fno-omit-frame-pointer -DDEBUG"
printf "CC=%s\n" "gcc"
} > config.status
printf "done\n"

View File

@@ -62,6 +62,7 @@
#include "../lib/proginfo.h"
#include "../lib/say.h"
#include "../lib/textc.h"
#include "../lib/xmem.h"
#include "licence.h"
typedef enum { MIT, GPL, BSD, UNL } licence_t;
@@ -77,6 +78,22 @@ static int exit_status;
static void print_help();
static void print_version();
static char *source_replace(const char *restrict template,
const char *restrict package,
const char *restrict author) {
/*
* XXX(vx-clutch):
* - package token : {{PACKAGE}}
* - author token : {{AUTHOR}}
*
* - allocate buffer
* - replace all packages with package and authors with author
* - return
*/
char *buffer = xmalloc(99999999999);
return NULL;
}
static char *get_name() {
int fds[2];
if (pipe(fds) == -1)
@@ -124,8 +141,6 @@ static int get_year() {
time_t now = time(NULL);
struct tm *t = localtime(&now);
// The tm_year member stores years since 1900, so add 1900 to get the actual
// year
return t->tm_year + 1900;
}
@@ -263,11 +278,6 @@ done\n\
return exit_status;
}
// size_t len = strlen(package);
// char *pdir = xmalloc(len + 2);
// memcpy(pdir, package, len);
// pdir[len] = '/';
// pdir[len + 1] = '\0';
char *pdir;
asprintf(&pdir, "%s/", package);
@@ -275,6 +285,11 @@ done\n\
if (chdir(pdir))
fatalfa(errno);
fs_new("doc/");
fs_new("src/");
fs_new("tools/");
fs_new("lib/");
fs_write("doc/version.texi", "\
@set UPDATED %s\
@set UPDATED-MONTH %s\
@@ -284,7 +299,6 @@ done\n\
"1 January 1970", "January 2025");
char *texi_buffer;
// snprintf(path_buffer, sizeof(path_buffer), "doc/%s.texi", package);
asprintf(&texi_buffer, "doc/%s.texi", package);
fs_write(texi_buffer, "\
\\input texinfo @c -*-texinfo-*-\n\
@@ -459,72 +473,71 @@ a @file{ChangeLog} entry.\n\
author, author, author, author, author, author);
free(texi_buffer);
// TODO(vx-clutch): Why dosn't this write the source?
// snprintf(path_buffer, sizeof(path_buffer), "src/%s.c", package);
char *src_path;
asprintf(&src_path, "src/%s.c", package);
fs_write(src_path, "\
/* Copyright (C) %s\n\
*\n\
* This file is part of %s\n\
*\n\
* This project and file is licenced under the BSD-3-Clause licence.\n\
* <https://opensource.org/licence/bsd-3-clause>\n\
*/\n\
\n\
// Usage: %s [OPTION]...\n\
\n\
#include <stdlib.h>\n\
#include <stdio.h>\n\
\n\
#include <config.h>\n\
\n\
#include \"../lib/proginfo.h\"\n\
\n\
static int exit_status;\n\
\n\
static void print_help();\n\
static void print_version();\n\
\n\
int main(int argc, char **argv)\n\
{\n\
set_prog_name(argv[0]);\n\
\n\
exit_status = EXIT_SUCCESS;\n\
\n\
return exit_status;\n\
}\n\
\n\
void print_help()\n\
{\n\
printf(\"Usage: %%s [OPTION]...\\n\", PROGRAM);\n\
fputs(\"\\
%s does a thing.\\n\",\n\
stdout);\n\
\n puts(\"\");\n\
fputs(\"\\
--help display this help and exit\\n\\
--version display version information and exit\\n\",\n\
stdout);\n\
puts(\"\");\n\
fputs(\"\\
--option Does an awesome thing\\n\\\",\n\
stdout);\n\
exit(exit_status);\n\
}\n\
\n\
void print_version()\n\
{\n\
printf(\"%%s %%s %%d\\n\", prog_name, VERSION, COMMIT);\n\
\n\
printf(\"Copyright (C) %%d %s.\\n\", YEAR);\n\
\n\
puts(\"This is free software: you are free to change and redistribute it.\");\n\
puts(\"There is NO WARRANTY, to the extent permitted by law.\");\n\
exit(exit_status);\n\
}\
",
author, package, package, package, author);
fs_write(src_path, "typedef int x;");
// fs_write(src_path, "\
// /* Copyright (C) %s\n\
// *\n\
// * This file is part of %s\n\
// *\n\
// * This project and file is licenced under the BSD-3-Clause licence.\n\
// * <https://opensource.org/licence/bsd-3-clause>\n\
// */\n\
// \n\
// // Usage: %s [OPTION]...\n\
// \n\
// #include <stdlib.h>\n\
// #include <stdio.h>\n\
// \n\
// #include <config.h>\n\
// \n\
// #include \"../lib/proginfo.h\"\n\
// \n\
// static int exit_status;\n\
// \n\
// static void print_help();\n\
// static void print_version();\n\
// \n\
// int main(int argc, char **argv)\n\
// {\n\
// set_prog_name(argv[0]);\n\
// \n\
// exit_status = EXIT_SUCCESS;\n\
// \n\
// return exit_status;\n\
// }\n\
// \n\
// void print_help()\n\
// {\n\
// printf(\"Usage: %%s [OPTION]...\\n\", PROGRAM);\n\
// fputs(\"\\
// %s does a thing.\\n\",\n\
// stdout);\n\
// \n puts(\"\");\n\
// fputs(\"\\
// --help display this help and exit\\n\\
// --version display version information and exit\\n\",\n\
// stdout);\n\
// puts(\"\");\n\
// fputs(\"\\
// --option Does an awesome thing\\n\\\",\n\
// stdout);\n\
// exit(exit_status);\n\
// }\n\
// \n\
// void print_version()\n\
// {\n\
// printf(\"%%s %%s %%d\\n\", prog_name, VERSION, COMMIT);\n\
// \n\
// printf(\"Copyright (C) %%d %s.\\n\", YEAR);\n\
// \n\
// puts(\"This is free software: you are free to change and redistribute it.\");\n\
// puts(\"There is NO WARRANTY, to the extent permitted by law.\");\n\
// exit(exit_status);\n\
// }\
// ",
// author, package, package, package, author);
free(src_path);
fs_write("tools/Cleanup", "\