From 48e2e5baaf1370a9c6992df3db3d5c77ead0ab7b Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Sat, 12 Jul 2025 23:52:32 -0400 Subject: [PATCH] save --- Makefile | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ README | 5 ++++- config.mak | 4 ++++ configure | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ yait-doc/main.c | 6 ++++++ yait/main.c | 6 ++++++ 6 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 config.mak create mode 100755 configure create mode 100644 yait-doc/main.c create mode 100644 yait/main.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e5d5d52 --- /dev/null +++ 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 index ca13cae..029685c 100644 --- 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 new file mode 100644 index 0000000..d6ba4f4 --- /dev/null +++ b/config.mak @@ -0,0 +1,4 @@ +PREFIX=/usr/bin/ +CFLAGS=-Wall -Wextra -O2 +LDFLAGS= +CC=gcc diff --git a/configure b/configure new file mode 100755 index 0000000..b75b922 --- /dev/null +++ b/configure @@ -0,0 +1,56 @@ +#!/bin/sh + +usage() { +cat </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 new file mode 100644 index 0000000..f3859b4 --- /dev/null +++ b/yait-doc/main.c @@ -0,0 +1,6 @@ +#include + +int main(void) { + printf("Hello, Yait-doc!\n"); + return 0; +} diff --git a/yait/main.c b/yait/main.c new file mode 100644 index 0000000..b4b2238 --- /dev/null +++ b/yait/main.c @@ -0,0 +1,6 @@ +#include + +int main(void) { + printf("Hello, Yait!\n"); + return 0; +}