commit 40665c96eae0fac963ada9dcf633baf9d0d38a2f
parent 7d2843cd37c5044cee7211c0b33406042090751c
Author: vx-clutch <[email protected]>
Date: Sun, 5 Oct 2025 08:22:44 -0400
save
Diffstat:
3 files changed, 67 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
@@ -20,17 +20,17 @@ all:
@exit 1
else
-all: build $(YAIT)
+all: build $(BIN)
build:
mkdir -p bin
mkdir -p build/obj
build/obj/%.o: src/%.c config.mak
- $(CC) $(FLAGS) -c $< -o $@
+ $(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
$(BIN): $(OBJS)
- $(CC) $(FLAGS) $^ -o $@
+ $(CC) $(FLAGS) $(CFLAGS) $^ -o $@
endif
diff --git a/lib/err.c b/lib/err.c
@@ -59,9 +59,9 @@ void fatalf(const char *format, ...)
va_start(args, format);
if (__check()) {
- fprintf(stderr, "%sfatal%s: ", ERROR, RESET);
+ fprintf(stderr, "%sfatal error%s: ", ERROR, RESET);
} else {
- fputs("fatal: ", stderr);
+ fputs("fatal error: ", stderr);
}
vfprintf(stderr, format, args);
@@ -69,6 +69,7 @@ void fatalf(const char *format, ...)
va_end(args);
+ fputs("program terminated.\n", stderr);
exit(EXIT_FAILURE);
}
void warnf(const char *format, ...)
diff --git a/src/yait.c b/src/yait.c
@@ -140,7 +140,7 @@ int main(int argc, char **argv)
}
if (optind >= argc) {
- fatalf("no project name provided");
+ fatalf("no input name");
}
if (optind + 1 < argc) {
@@ -386,15 +386,69 @@ printf \"CC=%%s\n\" \"$CC\"\n\
printf \"done\n\"\n\
");
+ fs_write("Makefile", "\
+PACKAGE := %s\n\
+\n\
+SRCS := $(wildcard src/*.c) $(wildcard lib/*.c)\n\
+OBJS := $(patsubst src/%%.c,build/obj/%%.o,$(SRCS))\n\
+\n\
+BIN := bin/$(PACKAGE)\n\
+\n\
+COMMIT := $(shell git rev-list --count --all)\n\
+FLAGS := -I. -DCOMMIT=$(COMMIT)\n\
+\n\
+VERSION := $(shell git describe --tags --always --dirty)\n\
+TARBALL := $(PACKAGE)-$(VERSION).tar.gz\n\
+RELEASE_FILES := doc src lib COPYING AUTHORS README yait.1 INSTALL Makefile configure config.h\n\
+\n\
+-include config.mak\n\
+\n\
+ifeq ($(wildcard config.mak),)\n\
+all:\n\
+ @echo \"File config.mak not found, run configure \"\n\
+ @exit 1\n\
+else\n\
+\n\
+all: build $(BIN)\n\
+\n\
+build:\n\
+ mkdir -p bin\n\
+ mkdir -p build/obj\n\
+\n\
+build/obj/%.o: src/%.c config.mak\n\
+ $(CC) $(FLAGS) $(CFLAGS) -c $< -o $@\n\
+\n\
+$(BIN): $(OBJS) \n\
+ $(CC) $(FLAGS) $(CFLAGS) $^ -o $@\n\
+\n\
+endif\n\
+\n\
+install: $(BIN)\n\
+ cp $(BIN) $(PREFIX)\n\
+\n\
+uninstall:\n\
+ $(RM) $(PREFIX)$(PACKAGE)\n\
+\n\
+clean:\n\
+ $(RM) $(BIN)\n\
+ $(RM) -r build\n\
+\n\
+distclean: clean\n\
+ $(RM) config.mak\n\
+ $(RM) $(TARBALL)\n\
+\n\
+release: clean all\n\
+ tar -czf $(TARBALL) $(RELEASE_FILES)\n\
+\n\
+.PHONY: all clean distclean install uninstall build release\n\
+",
+ package);
+
char *cwd = getcwd(NULL, 0);
- if (cwd == NULL) {
+ if (cwd == NULL)
fatalfa(errno);
- }
-
- if (!quiet) {
+ if (!quiet)
fprintf(stderr, "Created %s at\n %s\n", package, cwd);
- }
-
free(cwd);
return exit_status;