save
This commit is contained in:
32
Makefile
32
Makefile
@@ -2,7 +2,7 @@
|
|||||||
PACKAGE := yait
|
PACKAGE := yait
|
||||||
|
|
||||||
SRCS := $(wildcard src/*.c) $(wildcard lib/*.c)
|
SRCS := $(wildcard src/*.c) $(wildcard lib/*.c)
|
||||||
OBJS := $(patsubst src/%.c,build/obj/%.o,$(SRCS))
|
OBJS := $(patsubst %.c,build/obj/%.o,$(SRCS))
|
||||||
|
|
||||||
BIN := bin/$(PACKAGE)
|
BIN := bin/$(PACKAGE)
|
||||||
|
|
||||||
@@ -21,23 +21,29 @@ all:
|
|||||||
@exit 1
|
@exit 1
|
||||||
else
|
else
|
||||||
|
|
||||||
all: build $(BIN) doc
|
all: $(BIN)
|
||||||
|
|
||||||
build:
|
bin:
|
||||||
mkdir -p bin
|
@mkdir -p bin
|
||||||
mkdir -p build/obj
|
|
||||||
|
|
||||||
build/obj/%.o: src/%.c config.mak
|
build/obj:
|
||||||
$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
|
@mkdir -p build/obj/src
|
||||||
|
@mkdir -p build/obj/lib
|
||||||
|
|
||||||
$(BIN): $(OBJS)
|
build/obj/%.o: %.c config.mak | build/obj
|
||||||
$(CC) $(FLAGS) $(CFLAGS) $^ -o $@
|
@printf " CC %s\n" $(notdir $@)
|
||||||
|
@$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(BIN): $(OBJS) | bin
|
||||||
|
@printf " LINK %s\n" "$(notdir $@)"
|
||||||
|
@$(CC) $(FLAGS) $(CFLAGS) $^ -o $@
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
install: $(BIN)
|
install: $(BIN)
|
||||||
cp $(BIN) $(PREFIX)
|
cp $(BIN) $(PREFIX)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
$(MAKE) -C doc all
|
$(MAKE) -C doc all
|
||||||
|
|
||||||
@@ -54,10 +60,10 @@ distclean: clean
|
|||||||
$(RM) $(TARBALL)
|
$(RM) $(TARBALL)
|
||||||
$(MAKE) -C doc clean
|
$(MAKE) -C doc clean
|
||||||
|
|
||||||
release: clean all
|
release: distclean all
|
||||||
tar -czf $(TARBALL) $(RELEASE_FILES)
|
tar -czf $(TARBALL) $(RELEASE_FILES)
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@$(BIN) --version > /dev/null 2>&1 && echo "intact"|| echo "defective"
|
@$(BIN) --version > /dev/null 2>&1 && echo "intact" || echo "defective"
|
||||||
|
|
||||||
.PHONY: all clean distclean install uninstall build release doc
|
.PHONY: all clean distclean install uninstall doc
|
||||||
|
|||||||
4
TODO
4
TODO
@@ -2,7 +2,7 @@ GCK yait --- TODO
|
|||||||
|
|
||||||
Todo:
|
Todo:
|
||||||
|
|
||||||
* fix 't' so that it handles names correctly
|
* fix 't' so that it handles names correctly and special in-file characters
|
||||||
* write all templates
|
* write all templates sources
|
||||||
|
|
||||||
end of file TODO
|
end of file TODO
|
||||||
|
|||||||
20
src/flat.c
Normal file
20
src/flat.c
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
// SPDX-License-Identifer: BSD-3-Clause
|
||||||
|
/*
|
||||||
|
* A uemacs derided and inspired layout and format for smaller projects;
|
||||||
|
* such as, a small library, or CLI.
|
||||||
|
*/
|
||||||
|
#include <lib/fs.h>
|
||||||
|
#include <lib/say.h>
|
||||||
|
|
||||||
|
#include <template.h>
|
||||||
|
#include "flat.h"
|
||||||
|
|
||||||
|
int generate_flat(char *package, char *author, int year, char *license,
|
||||||
|
char *desc)
|
||||||
|
{
|
||||||
|
char *main;
|
||||||
|
asprintf(&main, "%s.c", package);
|
||||||
|
fs_write("Makefile", templ_flat_MAKEFILE, package);
|
||||||
|
fs_write(main, templ_main, license);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
8
src/flat.h
Normal file
8
src/flat.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#ifndef FLAT_H_
|
||||||
|
#define FLAT_H_
|
||||||
|
|
||||||
|
int generate_flat(char *package, char *author, int year, char *license,
|
||||||
|
char *desc);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
#ifndef LICENCES_H
|
#ifndef LICENCES_H_
|
||||||
#define LICENCES_H
|
#define LICENCES_H_
|
||||||
|
|
||||||
const char *fBSD = "\
|
const char *fBSD = "\
|
||||||
BSD 3-Clause License\n\
|
BSD 3-Clause License\n\
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
#ifndef SHELL_H
|
#ifndef SHELL_H_
|
||||||
#define SHELL_H
|
#define SHELL_H_
|
||||||
|
|
||||||
int write_shell(char *package, char *license, int year, char *author, char *m);
|
int write_shell(char *package, char *license, int year, char *author, char *m);
|
||||||
|
|
||||||
|
|||||||
32
src/yait.c
32
src/yait.c
@@ -3,7 +3,6 @@
|
|||||||
* Copyright (C) 2025, GCK.
|
* Copyright (C) 2025, GCK.
|
||||||
* Written by vx-clutch (vx-clutch)
|
* Written by vx-clutch (vx-clutch)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
@@ -23,12 +22,14 @@
|
|||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "license.h"
|
#include "license.h"
|
||||||
|
#include <template.h>
|
||||||
|
|
||||||
typedef enum { MIT, GPL, BSD, UNL } license_t;
|
typedef enum { MIT, GPL, BSD, UNL } license_t;
|
||||||
|
|
||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {
|
||||||
{ "author", required_argument, 0, 'a' },
|
{ "author", required_argument, 0, 'a' },
|
||||||
{ "license", required_argument, 0, 'l' },
|
{ "license", required_argument, 0, 'l' },
|
||||||
|
{ "flat", no_argument, 0, 'f' },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -96,6 +97,7 @@ int main(int argc, char **argv)
|
|||||||
int lose = 0;
|
int lose = 0;
|
||||||
char *m = str_dup("Does a thing"), *package;
|
char *m = str_dup("Does a thing"), *package;
|
||||||
bool shell = false;
|
bool shell = false;
|
||||||
|
bool flat = false;
|
||||||
char *author = get_name();
|
char *author = get_name();
|
||||||
exit_status = EXIT_SUCCESS;
|
exit_status = EXIT_SUCCESS;
|
||||||
int year = get_year();
|
int year = get_year();
|
||||||
@@ -147,6 +149,9 @@ int main(int argc, char **argv)
|
|||||||
case 'S':
|
case 'S':
|
||||||
shell = true;
|
shell = true;
|
||||||
break;
|
break;
|
||||||
|
case 'f':
|
||||||
|
flat = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
lose = 1;
|
lose = 1;
|
||||||
}
|
}
|
||||||
@@ -175,9 +180,30 @@ int main(int argc, char **argv)
|
|||||||
if (chdir(project_dir))
|
if (chdir(project_dir))
|
||||||
fatalfa(errno);
|
fatalfa(errno);
|
||||||
|
|
||||||
|
switch (license) {
|
||||||
|
case MIT:
|
||||||
|
fs_write("COPYING", fMIT, year, author);
|
||||||
|
break;
|
||||||
|
case GPL:
|
||||||
|
fs_write("COPYING", fGPL);
|
||||||
|
break;
|
||||||
|
case BSD:
|
||||||
|
fs_write("COPYING", fBSD, year, author);
|
||||||
|
break;
|
||||||
|
case UNL:
|
||||||
|
default:
|
||||||
|
fs_write("COPYING", fUNL);
|
||||||
|
}
|
||||||
|
|
||||||
fs_write("README", templ_README, author, package, package, m, year,
|
fs_write("README", templ_README, author, package, package, m, year,
|
||||||
author, author, package);
|
package, author, package);
|
||||||
fs_write("README-dev", templ_README_dev, year, author);
|
|
||||||
|
if (flat)
|
||||||
|
exit_status =
|
||||||
|
generate_flat(package, author, year, license_str, m);
|
||||||
|
else
|
||||||
|
exit_status =
|
||||||
|
generate_regular(package, author, year, license_str, m);
|
||||||
|
|
||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Format_Index: p
|
Format_Index: p
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
PACKAGE := %s
|
PACKAGE := %s
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Format_Index: a, p, p, d, y, a, a, p
|
Format_Index: a, p, p, d, y, p, a, p
|
||||||
This is the README file for the %s %s distribution.
|
This is the README file for the %s %s distribution.
|
||||||
%s %s
|
%s %s
|
||||||
|
|
||||||
|
|||||||
50
t/main.x
Normal file
50
t/main.x
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
Format_Index: l, y, a, d, a
|
||||||
|
// SPDX-License-Identifier: %s
|
||||||
|
/*
|
||||||
|
* Copyright (C) %d, %s.
|
||||||
|
* Written by YOU (you@example.com)
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static int exit_status;
|
||||||
|
|
||||||
|
static void print_help();
|
||||||
|
static void print_version();
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
exit_status = EXIT_SUCCESS;
|
||||||
|
|
||||||
|
return exit_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_help()
|
||||||
|
{
|
||||||
|
printf("Usage: %%s [OPTION]...\n", PROGRAM);
|
||||||
|
fputs("\
|
||||||
|
%s.\n",
|
||||||
|
stdout);
|
||||||
|
puts("");
|
||||||
|
fputs("\
|
||||||
|
--help display this help and exit\n\
|
||||||
|
--version display version information and exit\n",
|
||||||
|
stdout);
|
||||||
|
/*
|
||||||
|
puts("");
|
||||||
|
fputs("\
|
||||||
|
--foo Enable the foo directive\n",
|
||||||
|
stdout);
|
||||||
|
*/
|
||||||
|
exit(exit_status);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_version()
|
||||||
|
{
|
||||||
|
printf("%%s %%s %%d\n", prog_name, VERSION, COMMIT);
|
||||||
|
|
||||||
|
printf("Copyright (C) %%d %s.\n", YEAR);
|
||||||
|
|
||||||
|
puts("This is free software: you are free to change and redistribute it.");
|
||||||
|
puts("There is NO WARRANTY, to the extent permitted by law.");
|
||||||
|
exit(exit_status);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user