This commit is contained in:
2025-11-05 09:25:02 -05:00
parent d32d48ab36
commit adedeb5b63
9 changed files with 397 additions and 706 deletions

326
template.h Normal file
View File

@@ -0,0 +1,326 @@
/* DO NOT MODIFY THIS FILE! It was generated by t 1.0.1. */
#ifndef FOO_BAR
#define FOO_BAR
/*
* year (d)
* author (s)
*/
static const char templ_INSTALL[] = "\
Installation Instructions\n\
*************************\n\
Copyright (C) %d %s\n\
Copying and distribution of this file, with or without modification,\n\
are permitted in any medium without royalty provided the copyright\n\
notice and this notice are preserved. This file is offered as-is,\n\
without warranty of any kind.\n\
Basic Installation\n\
==================\n\
Briefly, the shell command `./configure && make && make install` should\n\
configure, build, and install this package. The following more-detailed\n\
instruction are generic; see the `README` file for instructions specific to\n\
this package.\n\
The `configure` shell script attempts to guess correct values for\n\
various system-dependent variables used during compilation. It uses\n\
those values within a `Makefile` to build for that POSIX system as\n\
defined by `config.mak` which was generated by `configure`.\n\
Compilers and Options\n\
=====================\n\
Some systems require unusal options for compilation or linking that\n\
the `configure` script does not know about. If you run into an issue\n\
run `./configure --help` to figure out what you can do to fix the\n\
behavoir.\n\
Installation Names\n\
==================\n\
By default, `make install` installs the package's command under\n\
`/usr/local/bin`. You can specify an installation prefix other than `/usr/local/`\n\
by giving `configure` the option `--prefix=PREFIX` to `configure`, the package uses\n\
PREFIX as the prefix for installation programs and libraries.\n\
Documentation and other data files still use the regular prefix.\n\
`configure` Invokation\n\
======================\n\
`configure` recongizes the following options to control its operations.\n\
`--help`\n\
Prints a summary of all the options to `configure`, and exits.\n\
`--prefix=PREFIX`\n\
Sets the installation prefix.\n\
`CFLAGS`\n\
Sets the flags used during compilation.\n\
`configure` also accepts some other options. Run `configure --help` for more\n\
details";
/*
* license (s)
* year (d)
* author (s)
* description (s)
* author (s)
*/
static const char templ_MAIN[] = "\
// SPDX-License-Identifier: %s\n\
/*\n\
* Copyright (C) %d, %s.\n\
* Written by YOU (you@example.com)\n\
*/\n\
#include <stdlib.h>\n\
static int exit_status;\n\
static void print_help();\n\
static void print_version();\n\
int main(int argc, char **argv)\n\
{\n\
exit_status = EXIT_SUCCESS;\n\
return exit_status;\n\
}\n\
static void print_help()\n\
{\n\
printf(\"Usage: %%s [OPTION]...\n\", PROGRAM);\n\
fputs(\"\\\n\
%s.\n\",\n\
stdout);\n\
puts(\"\");\n\
fputs(\"\\\n\
--help display this help and exit\n\\\n\
--version display version information and exit\n\",\n\
stdout);\n\
/*\n\
puts(\"\");\n\
fputs(\"\\\n\
--foo Enable the foo directive\n\",\n\
stdout);\n\
*/\n\
exit(exit_status);\n\
}\n\
static void print_version()\n\
{\n\
printf(\"%%s %%s %%d\n\", prog_name, VERSION, COMMIT);\n\
printf(\"Copyright (C) %%d %s.\n\", YEAR);\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\
}";
/*
* package (s)
*/
static const char templ_MAKEFILE[] = "\
# SPDX-License-Identifier: BSD-3-Clause\n\
PACKAGE := %s\n\
SRCS := $(wildcard src/*.c) $(wildcard lib/*.c)\n\
OBJS := $(patsubst src/%.c,build/obj/%.o,$(SRCS))\n\
BIN := bin/$(PACKAGE)\n\
COMMIT := $(shell git rev-list --count --all)\n\
FLAGS := -I. -DCOMMIT=$(COMMIT) --std=c2x -pedantic -Ibuild/include\n\
VERSION := $(shell git describe --tags --always --dirty)\n\
TARBALL := $(PACKAGE)-$(VERSION).tar.gz\n\
RELEASE_FILES := doc src lib COPYING AUTHORS README $(PACKAGE).1 INSTALL Makefile configure config.h\n\
-include config.mak\n\
ifeq ($(wildcard config.mak),)\n\
all:\n\
@echo \"File config.mak not found, run configure\"\n\
@exit 1\n\
else\n\
all: build $(BIN) doc\n\
build:\n\
mkdir -p bin\n\
mkdir -p build/obj\n\
build/obj/%.o: src/%.c config.mak\n\
$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@\n\
$(BIN): $(OBJS) \n\
$(CC) $(FLAGS) $(CFLAGS) $^ -o $@\n\
endif\n\
install: $(BIN)\n\
cp $(BIN) $(PREFIX)\n\
doc:\n\
$(MAKE) -C doc all\n\
uninstall:\n\
$(RM) $(PREFIX)$(PACKAGE)\n\
clean:\n\
$(RM) -r bin\n\
$(RM) -r build\n\
$(MAKE) -C doc clean\n\
distclean: clean\n\
$(RM) config.mak config.status\n\
$(RM) $(TARBALL)\n\
$(MAKE) -C doc clean\n\
release: clean all\n\
tar -czf $(TARBALL) $(RELEASE_FILES)\n\
test:\n\
@$(BIN) --version > /dev/null 2>&1 && echo \"intact\"|| echo \"defective\"\n\
.PHONY: all clean distclean install uninstall build release doc";
/*
* year (d)
* author (s)
*/
static const char templ_README_DEV[] = "\
This README.dev file describes the development environment.\n\
Copyright (C) %d %s.\n\
Copying and distribution of this file, with or without modification,\n\
are permitted in any medium without royalty provided the copyright\n\
notice and this notice are preserved.\n\
Notice\n\
------\n\
This documentation is standard across all GCK package and is not specified per\n\
package; however, this is the defacto standard for most packages. The only\n\
place where this commonly differs is in non-binary or library packages.\n\
Build system\n\
------------\n\
This distribution uses a GNU autotools-like build system. This is made up of a\n\
configure script, and a Makefile. The configure script detects a C23 compiler\n\
on the system and sets any program flags: debug, release, custom. The Makefile\n\
builds the binary based on the output [config.mak] of the configure script.\n\
Building\n\
--------\n\
To build this distribution you first must run the configure script. This\n\
outputs a config.mak file that will be used in the Make step. Then run make;\n\
this builds the objects into build/ and the binary into bin/.\n\
Configuration\n\
-------------\n\
The configuration script is used to generate a build intermediate step called\n\
the config.mak. This file is used by the Makefile to figure out C compiler to\n\
use, what CFLAGS and LDFLAGS to use, and where to install the binary if\n\
requested. By default these values are gcc, the release flag set, and\n\
/usr/local/. The configuration script supports the following flags that control\n\
CFLAGS: --enable-debug and CFLAGS=\"\". By default, the script uses flags for a release\n\
build. Debug is for in-development programming and is the strictest when it\n\
comes to warnings and other compiler output. CFLAGS=\"\" is for custom flag\n\
definition. For the development environment is it recommended to use the\n\
--debug flag. Some examples of how you can run the configure script:\n\
For default behavior:\n\
./configure\n\
For debug use:\n\
./configure --enable-debug\n\
For help text:\n\
./configure --help\n\
The help text is a more useage specific and up-to-date reference for\n\
the configure script.\n\
Makefile\n\
--------\n\
The GNU Makefile is used to build the final executable, clean up build\n\
artifacts, and install the program. It checks for the config.mak which is\n\
generated by the configure script. For a regular build, once you have the\n\
configure script with desired flags, run:\n\
make\n\
This builds the executable to bin/ and build objects to build/\n\
Suggested enviroment setup\n\
--------------------------\n\
It is suggested that you run do the following things to prepare you environment\n\
for development. This is not a strict enforcement, but due to the project\n\
structure it is a good starting point.\n\
git pull\n\
./tools/Cleanup\n\
./configure --enable-debug\n\
./build-aux/generate-artifacts\n\
make test\n\
This is to ensure that you have the most up-to-date source code, and that there\n\
are no major problems with the source control version.\n\
The git pull is used to sync with the repository and prevent conflicts. The\n\
cleanup is to ensure their are no lingering build artifacts. The configure with\n\
debug enabled is for strict build flags and -ggdb. Bear is used to generated\n\
compile_commands.json for the clang suite of tooling. Finally, run the program\n\
to ensure the chain works.\n\
Pre-commit checks\n\
-----------------\n\
Before you commit to source control ensure that done the following:\n\
* Run the cleanup scripts\n\
./tools/Cleanup\n\
* Ensure that all changes were atomic\n\
* If you compted a TODO list item check it off.\n\
* Based on complexity, test the feature accordingly.";
/*
*/
static const char templ_README_RELEASE[] = "\
Here are most of the steps before you make a release.\n\
* Start from a clean, up-to-date git driectory on \"master\":\n\
make -k distclean || { ./configure && make distclean; }\n\
git checkout master\n\
git pull origin master\n\
* Ensure that the latest stable versions of make, sh, etc.\n\
are in your path. See the prerequisites list in README-dev\n\
for a compile list of tools.\n\
* Ensure that you have no uncommitted diffs. This should produce\n\
no output:\n\
git diff\n\
* Ensure that you've pushed all changes that belong in the release:\n\
git push origin master\n\
* Pre-release testing: ensure that the following command succeeds:\n\
make check syntax-check distcheck\n\
Once all the builds and tests have passed,\n\
* Run the following to create release tarballs.\n\
make release\n\
* Upload the tarball to the relavent distribtuion platform.";
/*
* author (s)
* package (s)
* package (s)
* description (s)
* year (d)
* package (s)
* author (s)
* package (s)
*/
static const char templ_README[] = "\
This is the README file for the %s %s distribution.\n\
%s %s\n\
Copyright (C) %d %s.\n\
Copying and distribution of this file, with or without modification,\n\
are permitted in any medium without royalty provided the copyright\n\
notice and this notice are preserved.\n\
See the files ./INSTALL* for building and installation instructions.\n\
Bug reports:\n\
Please include enough information for the maintainers to reproduce the\n\
problem. Generally speaking, that means:\n\
- the contents of any input files necessary to reproduce the bug\n\
and command line invocations of the program(s) involved (crucial!).\n\
- a description of the problem and any samples of the erroneous output.\n\
- the version number of the program(s) involved (use --version).\n\
- hardware, operating system, and compiler versions (uname -a).\n\
- unusual options you gave to configure, if any (see config.mak).\n\
- anything else that you think would be helpful.\n\
See README-dev for information on the development environment -- any\n\
interested parties are welcome. If you're a programmer and wish to\n\
contribute, this should get you started. If you're not a programmer,\n\
your help in writing test cases, checking documentation against the\n\
implementation, etc., would still be very much appreciated.\n\
%s %s is free software. See the file COPYING for copying conditions.";
/*
* license (s)
* description (s)
* year (d)
* author (s)
* description (s)
* package (s)
*/
static const char templ_SHELL[] = "\
#!/bin/sh\n\
# SPDX-License-Identifier: %s\n\
#\n\
# %s\n\
me=$0\n\
scriptversion=\"1.0.0\"\n\
version=\"$me $scriptversion\n\
Copyright (C) %d %s\n\
This is free software; you are free to change and redistribute it.\n\
There is NO WARRANTY, to the textent permitted by law.\"\n\
usage=\"\\\n\
Usage: $me [OPTION]...\n\
%s\n\
Options:\n\
--help print this help and exit\n\
--version output version information\"\n\
while [ $# -gt 0 ]; do\n\
case $1 in\n\
--help) echo \"$usage\"; exit 0;;\n\
--version) echo \"$version\"; exit 0;;\n\
-*)\n\
echo \"$0: Unknown option '$1'.\" >&2\n\
echo \"$0: Try '--help' for more information.\" >&2\n\
exit 1 ;;\n\
esac\n\
shift\n\
done\n\
echo \"$0: done.\"\n\
# End: %s";
#endif