summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-03-01 17:11:16 -0500
committerJakob Kaivo <jkk@ung.org>2019-03-01 17:11:16 -0500
commit52a6be4089e0b995694fb8a49d7de7e5e2b2dd7f (patch)
tree9efefd7a2e4d927f1644171839e739da4f44f1da
parent7551fd06be130a02411b775e9bf8a9f995a12968 (diff)
script to generate distinct value checker and typedef checker from small input
-rw-r--r--Makefile8
-rwxr-xr-xdefs2d.awk16
2 files changed, 23 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 85fe6f8..15b0c0a 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,12 @@ include config.mk
CFLAGS=-g -I$(INCLUDEDIR) -nostdinc -fno-builtin
LDFLAGS=-L$(LIBDIR) $(LIBS)
-TESTOBJS=main.o test.o assert.o ctype.o locale.o errno.o time.o
+TESTOBJS=main.o test.o assert.o ctype.o locale.o errno.o time.o signal.o
+
+.SUFFIXES: .defs .d
+
+.defs.d:
+ awk -f defs2d.awk $< > $@
testlibc: $(TESTOBJS) $(LIBDIR)/libc.a
$(CC) -o $@ $(TESTOBJS) $(LDFLAGS)
@@ -15,6 +20,7 @@ ctype.o: ctype.c test.h
locale.o: locale.c test.h
errno.o: errno.c test.h
time.o: time.c test.h
+signal.o: signal.c signal.d
test.o: test.c test.h
main.o: main.c test.h
diff --git a/defs2d.awk b/defs2d.awk
new file mode 100755
index 0000000..1151185
--- /dev/null
+++ b/defs2d.awk
@@ -0,0 +1,16 @@
+#!/usr/bin/awk -f
+
+/type/ {
+ printf("static %s a_%s;\n\n", $2, $2);
+}
+
+/distinct/ {
+ printf("static int %s[] = {\n", $2);
+ for (i = 3; i < NF; i++) {
+ #printf("#ifndef %s\n", $i);
+ #printf("#error %s not defined\n", $i);
+ #printf("#endif\n");
+ printf("\t%s,\n", $i);
+ }
+ printf("};\n");
+}