commit 48e2e5baaf1370a9c6992df3db3d5c77ead0ab7b
parent c414661d0e9599fe5ee7cf5b5c5a74e0827f0941
Author: vx-clutch <[email protected]>
Date: Sat, 12 Jul 2025 23:52:32 -0400
save
Diffstat:
6 files changed, 133 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
@@ -0,0 +1,57 @@
+prefix=/usr/bin
+
+YAIT_SRCS=yait/main.c
+YAIR_DOC_SRCS=yait-doc/main.c
+
+YAIT_OBJS = $(addprefix obj/yait,$(patsubst yait/%,obj/%,$(patsubst %.c,%.o,$(notdir $(YAIT_SRCS)))))
+YAIT_DOC_OBJS = $(addprefix obj/yait-doc,$(patsubst yait-doc/%,obj/%,$(patsubst %.c,%.o,$(notdir $(YAIT_DOC_SRCS)))))
+
+YAIT=$(prefix)/yait
+YAIT_DOC=$(prefix)/yait-doc
+
+-include config.mak
+
+ifeq ($(wildcard config.mak),)
+all:
+ @echo "File config.mak not found, run configure"
+ @exit 1
+else
+
+all: clean obj bin $(YAIT) $(YAIT_DOC)
+
+obj:
+ mkdir -p $@/yait
+ mkdir -p $@/yait-doc
+
+bin:
+ mkdir -p $@
+
+obj/yait/%.o: yait/**/%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+obj/yait-doc/%.o: yait-doc/**/%.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+$(YAIT):
+ $(CC) $(YAIT_SCRS) -o ./bin/yait
+
+$(YAIT_DOC):
+ $(CC) $(YAIT_DOC_SRCS) -o ./bin/yait-doc
+
+endif
+
+install:
+ @echo "NOT IMPL"
+ exit 1
+
+uninstall:
+ @echo "NOT IMPL"
+ exit 1
+
+clean:
+ rm -rf obj bin
+
+dist-clean: clean
+ rm config.mak
+
+.PHONY: all clean dist-clean install uninstall
diff --git a/README b/README
@@ -2,6 +2,9 @@ yait ( yet another init tool )
yait is designed to allow you to create more side projects; that you will
definitely complete. This tool will create a new directory containing all
-project files needed for your new C ( maybe C++ ) project. It provided you with
+project files needed for your new C ( maybe C++ ) project. It provides you with
a build system and some basic source files to give you a kick start on your new
project--with optional libraries!
+
+For a more in-depth explanation of how to use the tool refer to `--help` or use
+the doc tool `yait-doc`.
diff --git a/config.mak b/config.mak
@@ -0,0 +1,4 @@
+PREFIX=/usr/bin/
+CFLAGS=-Wall -Wextra -O2
+LDFLAGS=
+CC=gcc
diff --git a/configure b/configure
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+usage() {
+cat <<EOF
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.
+
+ CC C compiler command [detected]
+ CFLAGS C compiler flags [-g, ...]
+
+EOF
+exit 0
+}
+
+echo () { printf "%s\n" "$*" ; }
+cmdexists () { type "$1" >/dev/null 2>&1 ; }
+trycc () { test -z "$CC" && cmdexists "$1" && CC=$1 ; }
+
+prefix=/usr/bin/
+CFLAGS="-Wall -Wextra -O2"
+LDFLAGS=
+CC=
+
+for arg ; do
+case "$arg" in
+--help|h) usage ;;
+CFLAGS=*) CFLAGS=${arg#*=} ;;
+LDFLAGS=*) LDFLAGS=${arg#*=} ;;
+esac
+done
+
+printf "checking for C compiler... "
+trycc gcc
+trycc cc
+trycc clang
+printf "%s\n" "$CC"
+
+printf "checking weather C compiler works... "
+status="fail"
+tmpc="$(mktemp -d)/test.c"
+echo "typedef int x;" > "$tmpc"
+if output=$($CC $CFLAGS -c -o /dev/null "$tmpc" 2>&1) ; then
+printf "yes\n"
+else
+printf "no; %s\n" "$output"
+exit 1
+fi
+
+printf "creating config.mak... "
+printf "PREFIX=%s\n" "$prefix" > config.mak
+printf "CFLAGS=%s\n" "$CFLAGS" >> config.mak
+printf "LDFLAGS=%s\n" "$LDFLAGS" >> config.mak
+printf "CC=%s\n" "$CC" >> config.mak
+printf "done\n"
diff --git a/yait-doc/main.c b/yait-doc/main.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void) {
+ printf("Hello, Yait-doc!\n");
+ return 0;
+}
diff --git a/yait/main.c b/yait/main.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void) {
+ printf("Hello, Yait!\n");
+ return 0;
+}