commit a0e3bfa21ac7d8bce5ad91fd980edcf9a4ead95b
parent 77d6b02a16c8073785813141cd7b794a068a7957
Author: libredev <libredev@ircforever.org>
Date: Tue, 28 Feb 2023 20:06:35 +0530
update build system
Diffstat:
3 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/Makefile b/Makefile
@@ -3,28 +3,32 @@
# including all related and neighboring rights, to the extent allowed by law.
# This work is provided 'as-is', without any express or implied warranty.
# See COPYING file for details.
+.POSIX:
-INSTALL_DIR=/var/www/htdocs/radio.ircforever.org
-STATUS_JSON=http://theinterlude.live:8000/status-json.xsl
+include config.mk
-CC = cc
-CFLAGS =\
- -g -std=c99 -Wall -Wextra -Wpedantic -Wfatal-errors\
- -Wstrict-prototypes -Wold-style-definition\
- -D_DEFAULT_SOURCE -DSTATUS_JSON=\"$(STATUS_JSON)\"
+BIN = index.cgi
+INC = comment.h utils.h http.h
+SRC = main.c comment.c utils.c pdjson/pdjson.c
+DEP = header.html footer.html comment.html style.css music.svg comment.db
-index.cgi: main.c comment.c utils.c comment.h utils.h http.h pdjson/pdjson.c
- $(CC) $(CFLAGS) -o $@ main.c comment.c utils.c pdjson/pdjson.c
+all: ${BIN}
-run: index.cgi
+${BIN}: ${SRC} ${INC}
+ ${CC} ${CFLAGS} -o $@ ${SRC}
+
+test: ${BIN}
REQUEST_URI='/' valgrind --leak-check=full --show-leak-kinds=all ./index.cgi
clean:
- rm -f index.cgi
+ rm -f ${BIN}
+
+install: ${BIN} ${DEP}
+ mkdir -p ${INSTALL_DIR}
+ cp ${BIN} ${DEP} ${INSTALL_DIR}
-install: index.cgi header.html footer.html comment.html style.css music.svg comment.db
- #rm -R -f $(INSTALL_DIR)
- #mkdir -p $(INSTALL_DIR)
- cp index.cgi header.html footer.html comment.html style.css music.svg comment.db $(INSTALL_DIR)
+uninstall:
+ rm -f ${INSTALL_DIR}/${BIN}
+ for f in ${DEP}; do rm -f ${INSTALL_DIR}/$$f; done
-.PHONY: run clean install
+.PHONY: all test clean install uninstall
diff --git a/config.mk b/config.mk
@@ -0,0 +1,14 @@
+# The author(s) have dedicated this work to the public domain by waiving all
+# of his or her rights to this work worldwide under copyright and patent law,
+# including all related and neighboring rights, to the extent allowed by law.
+# This work is provided 'as-is', without any express or implied warranty.
+# See COPYING file for details.
+
+INSTALL_DIR=/var/www/htdocs/radio.ircforever.org
+STATUS_JSON=http://theinterlude.live:8000/status-json.xsl
+
+CFLAGS = -g -std=c99 -Wall -Wextra -Wpedantic -Wfatal-errors\
+ -Wstrict-prototypes -Wold-style-definition\
+ -D_DEFAULT_SOURCE -DSTATUS_JSON=\"$(STATUS_JSON)\"
+
+LDFLAGS =
diff --git a/main.c b/main.c
@@ -71,7 +71,7 @@ not_found(void)
void
format_to_url(char *s)
{
- for(int i = 0; i < strlen(s); i++) {
+ for(int i = 0; i < (int)strlen(s); i++) {
if (s[i] == ' ')
s[i] = '_';
else