commit c6e18247d29bfe3e12b43820cedbb95e6c78469d
parent 8fecc4f34c47daa9cde76c09ddd7ae96cbe717f5
Author: nibo <nibo@relim.de>
Date: Mon, 28 Jul 2025 06:37:48 +0200
Improve Makefile stdout and add tests
Diffstat:
2 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/Makefile b/Makefile
@@ -7,7 +7,7 @@ SRC = src/core.c src/config.c src/chordpro.c src/chord_diagram.c src/out_pdf.c s
OBJS = core.o config.o chordpro.o chord_diagram.o out_pdf.o lorid.o
# Control whether log messages are colored.
-COLOR = 0
+COLOR = 1
# Exact font family name, e.g. from `fc-list : family`
DEFAULT_FONT = "Open Sans"
VARS = -DDEFAULT_FONT=\"${DEFAULT_FONT}\" \
@@ -15,23 +15,23 @@ VARS = -DDEFAULT_FONT=\"${DEFAULT_FONT}\" \
-DCOLOR=${COLOR} \
-DPREFIX=\"${PREFIX}\"
-lorid:
- $(CC) ${CFLAGS} ${VARS} -O2 ${SRC} -o lorid ${LDFLAGS}
+lorid: ${OBJS}
+ @echo Linking $@...
+ @$(CC) -o lorid ${OBJS} ${LDFLAGS}
+ @echo Stripping $@...
+ @strip $@
+%.o : src/%.c
+ @echo Compiling $<...
+ @$(CC) ${CFLAGS} ${VARS} -O2 -c $<
standalone:
- $(CC) ${CFLAGS} ${VARS} -Os ${SRC} -o lorid -Wl,-Bstatic -lpdfio -lgrapheme -ltoml -lz -Wl,-Bdynamic -lfontconfig -lpng16 -lm
- # $(CC) -static ${CFLAGS} ${VARS} -O2 ${SRC} -o lorid ${STATIC_LDFLAGS}
- # $(CC) ar/*/*.o ${CFLAGS} ${VARS} ${SRC} -o standalone -lfontconfig -lm
+ $(CC) ${CFLAGS} ${VARS} -O2 ${SRC} -o lorid -Wl,-Bstatic -lpdfio -lgrapheme -ltoml -lz -Wl,-Bdynamic -lfontconfig -lpng16 -lm
debug:
$(CC) ${CFLAGS} ${VARS} -DDEBUG -g ${SRC} -o lorid ${LDFLAGS}
-%.o : src/%.c
- @echo Compiling $<...
- @$(CC) ${CFLAGS} ${VARS} -c $<
-other: ${OBJS}
- @echo Linking lorid...
- @$(CC) -o lorid ${OBJS} ${LDFLAGS}
clean:
rm *.o
rm lorid
+test:
+ cd test/ && ./find-memory-leaks-in-case-of-error
install: lorid
mkdir -p ${PREFIX}/bin
cp lorid ${PREFIX}/bin
@@ -55,4 +55,4 @@ html:
mkdir -p doc/
groff -man -Thtml lorid.1 > doc/lorid.1.html
groff -man -Thtml lorid_config.5 > doc/lorid_config.5.html
-.PHONY: compile static debug clean install uninstall dist html
+.PHONY: standalone debug clean test install uninstall dist html
diff --git a/test/find-memory-leaks-in-case-of-error b/test/find-memory-leaks-in-case-of-error
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+for file in memory/*.cho; do
+ valgrind --leak-check=full \
+ --xml=yes \
+ --xml-file="$file.errors" \
+ ../lorid "$file" \
+ &> /dev/null
+ n=$(grep -c '<error>' "$file.errors")
+ if [ $n -gt 0 ]; then
+ echo -e "\033[1;31mERR\033[0m $file"
+ else
+ echo -e " \033[1;32mOK\033[0m $file"
+ fi
+ rm "$file.errors"
+done