aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-08-18 23:40:11 +0200
committerMattias Andrée <maandree@kth.se>2018-08-18 23:40:11 +0200
commit3e746c51b3adcf97e4d11be30bfd91c8aaf2c2ba (patch)
treea00b8ec51cfaf110d8bf36daa91827c95dc107e7 /Makefile
parentImprove makefile (diff)
downloadlibsimple-3e746c51b3adcf97e4d11be30bfd91c8aaf2c2ba.tar.gz
libsimple-3e746c51b3adcf97e4d11be30bfd91c8aaf2c2ba.tar.bz2
libsimple-3e746c51b3adcf97e4d11be30bfd91c8aaf2c2ba.tar.xz
Fix and run tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile39
1 files changed, 35 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 68e5b97..591d62a 100644
--- a/Makefile
+++ b/Makefile
@@ -54,17 +54,48 @@ OBJ =\
vweprintf.o\
libsimple.o
-all: libsimple.a
+TESTS =\
+ asprintf.test\
+ isutf8.test\
+ memdup.test\
+ memends.test\
+ memmem.test\
+ memrchr.test\
+ memrmem.test\
+ memstarts.test\
+ rawmemchr.test\
+ rawmemrchr.test\
+ strcaseends.test\
+ strcasestr.test\
+ strends.test\
+ strndup.test\
+ strrcasestr.test\
+ strrstr.test\
+ strstarts.test\
+ vasprintf.test
+
+all: libsimple.a $(TESTS)
$(OBJ): $(@:.o=.c) libsimple.h
+$(TESTS): $(@:=.o) libsimple.a
+$(TESTS:=.o): $(@:.test.o=.c) libsimple.h test.h
libsimple.a: $(OBJ)
$(AR) rc $@ $?
$(AR) -s $@
+.test.o.test:
+ $(CC) -o $@ $< libsimple.a $(LDFLAGS)
+
+.c.test.o:
+ $(CC) -c -o $@ $< $(CFLAGS) -DTEST
+
+check: $(TESTS)
+ @set -e; for t in $(TESTS); do printf '%s\n' "./$$t"; "./$$t"; done
+
clean:
- -rm -rf -- *.o *.su *.a *.so *.so.* *.gch *.gcda *.gcno *.gcov *.lo
+ -rm -rf -- *.o *.su *.a *.so *.so.* *.gch *.gcda *.gcno *.gcov *.lo *.test
.SUFFIXES:
-.SUFFIXES: .o .c
+.SUFFIXES: .test .test.o .o .c
-.PHONY: all clean
+.PHONY: all check clean