This commit is contained in:
2025-10-05 08:22:44 -04:00
parent 7d2843cd37
commit 40665c96ea
4 changed files with 68 additions and 13 deletions

View File

@@ -20,17 +20,17 @@ all:
@exit 1 @exit 1
else else
all: build $(YAIT) all: build $(BIN)
build: build:
mkdir -p bin mkdir -p bin
mkdir -p build/obj mkdir -p build/obj
build/obj/%.o: src/%.c config.mak build/obj/%.o: src/%.c config.mak
$(CC) $(FLAGS) -c $< -o $@ $(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
$(BIN): $(OBJS) $(BIN): $(OBJS)
$(CC) $(FLAGS) $^ -o $@ $(CC) $(FLAGS) $(CFLAGS) $^ -o $@
endif endif

2
gcklib

Submodule gcklib updated: b88978b6df...c12cd326f4

View File

@@ -59,9 +59,9 @@ void fatalf(const char *format, ...)
va_start(args, format); va_start(args, format);
if (__check()) { if (__check()) {
fprintf(stderr, "%sfatal%s: ", ERROR, RESET); fprintf(stderr, "%sfatal error%s: ", ERROR, RESET);
} else { } else {
fputs("fatal: ", stderr); fputs("fatal error: ", stderr);
} }
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
@@ -69,6 +69,7 @@ void fatalf(const char *format, ...)
va_end(args); va_end(args);
fputs("program terminated.\n", stderr);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
void warnf(const char *format, ...) void warnf(const char *format, ...)

View File

@@ -140,7 +140,7 @@ int main(int argc, char **argv)
} }
if (optind >= argc) { if (optind >= argc) {
fatalf("no project name provided"); fatalf("no input name");
} }
if (optind + 1 < argc) { if (optind + 1 < argc) {
@@ -386,15 +386,69 @@ printf \"CC=%%s\n\" \"$CC\"\n\
printf \"done\n\"\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); char *cwd = getcwd(NULL, 0);
if (cwd == NULL) { if (cwd == NULL)
fatalfa(errno); fatalfa(errno);
} if (!quiet)
if (!quiet) {
fprintf(stderr, "Created %s at\n %s\n", package, cwd); fprintf(stderr, "Created %s at\n %s\n", package, cwd);
}
free(cwd); free(cwd);
return exit_status; return exit_status;