commit 8de30a1896fee036a9794c54ffc1d98eb1345faf
parent 342e8423878efd63cfd1cba10ce3fb5db842f341
Author: Mario Rosell R. Martinez <mario@mariorosell.es>
Date: Thu, 26 Mar 2026 20:26:00 +0100
build: Build ssystem and a few scripts
Diffstat:
5 files changed, 104 insertions(+), 1 deletion(-)
diff --git a/.clang-format b/.clang-format
@@ -15,5 +15,6 @@ PointerAlignment: Left
ColumnLimit: 0
-InserFinalNewline: true
+InsertNewlineAtEOF: true
+KeepEmptyLinesAtEOF: true # clang-format 17
diff --git a/Makefile b/Makefile
@@ -0,0 +1,72 @@
+#
+# Makefile -- build system
+#
+
+#*** config ***#
+
+PROG = s-httpd
+VERSION = 0.1.0 DEV
+SRCS != echo *.c
+OBJS = ${SRCS:.c=.o}
+DEPS = ${OBJS:.c=.d}
+
+CC = cc
+PKGCONF = pkgconf
+INSTALL = install
+
+LIBS := openssl
+CFLAGS_LIBS != ${PKGCONF} --cflags ${LIBS}
+LDFLAGS_LIBS != ${PKGCONF} --libs ${LIBS}
+
+WARN := -Wall -Werror
+CPPFLAGS := -DIN_S_HTTPD -DVERSION='"${VERSION}"'
+CFLAGS := -std=c99 ${WARN}
+LDFLAGS := ${LDFLAGS_LIBS}
+
+.ifdef STATIC
+CFLAGS += -static
+LDFLAGS += -static
+.endif
+
+PREFIX ?= /usr/local
+BINDIR ?= ${PREFIX}/bin
+MANDIR ?= ${PREFIX}/man/man8
+MAN := s-httpd.8
+BEAR := bear
+
+#*** build ***#
+
+all: ${PROG}
+
+.c.o:
+ ${CC} ${CFLAGS} ${CPPFLAGS} -MMD -MF ${<:.c=.d} -MD -c $< -o $@
+
+${PROG}: ${OBJS}
+ ${CC} ${CFLAGS} -o ${PROG} ${OBJS} ${LDFLAGS}
+
+.if exist(${DEPS})
+.include "${DEPS}"
+.endif
+
+#*** utils ***#
+
+install: ${PROG} ${MAN}
+ @echo "Installing ${PROG} to ${BINDIR}"
+ ${INSTALL} -d ${BINDIR}
+ ${INSTALL} -m 755 ${PROG} ${BINDIR}
+ @echo "Installing man ${MAN} to ${MANDIR}"
+ ${INSTALL} -d ${MANDIR}
+ ${INSTALL} -m 644 ${MAN} ${MANDIR}
+
+uninstall:
+ rm -f ${BINDIR}/${PROG}
+ rm -f ${MANDIR}/${MAN}
+
+clean:
+ rm -f ${OBJS} ${DEPS} ${PROG}
+
+db:
+ ${BEAR} -- ${MAKE} all
+
+.PHONY: all clean install uninstall db
+
diff --git a/cleanup.sh b/cleanup.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# cleanup.sh -- format and tidy
+#
+
+if ! command -v clang-format 2>&1 >/dev/null; then
+ echo "cleanup.sh: don't have clang-format"
+ exit 1
+fi
+
+if ! command -v clang-tidy 2>&1 >/dev/null; then
+ echo "cleanup.sh: don't have clang-tidy"
+ exit 1
+fi
+
+# when I add a header add *.h below
+# vvv
+for f in *.c; do
+ clang-format -i $f
+ clang-tidy -fix-errors -fix $f
+done
+
diff --git a/s-httpd b/s-httpd
Binary files differ.
diff --git a/s-httpd.c b/s-httpd.c
@@ -0,0 +1,8 @@
+int
+main(int argc, char** argv)
+{
+ (void)argc;
+ (void)argv;
+ return 0;
+}
+