bench: pass N as argument, update readme
[libc-test] / Makefile.inc
index bfdc3dc..5f1d614 100644 (file)
@@ -16,6 +16,8 @@ includedir = $(prefix)/include
 libdir = $(prefix)/lib
 -include $(ROOTDIR)/Makefile.conf
 
+AR=ar
+RANLIB=ranlib
 
 CFLAGS += -g -std=c99 -pipe -Wall
 LDFLAGS += -g
@@ -30,23 +32,36 @@ LDFLAGS += -nostdlib -Wl,-e,_start,-Bstatic $(libdir)/crti.o $(libdir)/crt1.o $(
 INC     += -isystem $(includedir)
 endif
 
-all: t
+all: t b
 
 clean:
-       rm -f $(OBJS) t main.o main.h
+       rm -f $(OBJS) t t.o b b.o tests.a tests.h
 
 .c.o:
        $(CC) $(CFLAGS) $(INC) -c -o $@ $<
 
-$(OBJS): $(ROOTDIR)/common/test.h
+$(OBJS): $(ROOTDIR)/common/test.h $(ROOTDIR)/Makefile.conf
 
-main.h: $(OBJS)
-       nm -f posix $+ |awk '/^test/ && $$2=="T"{print "T(" $$1 ")"}' >main.h
+tests.h: $(OBJS)
+       nm -f posix $+ |awk ' \
+               /^test/ && $$2=="T"{print "T(" $$1 ")"} \
+               /^bench/ && $$2=="T"{print "B(" $$1 ")"} \
+       ' >tests.h
 
-main.o: $(ROOTDIR)/common/main.c $(ROOTDIR)/common/test.h main.h
+tests.a: $(OBJS)
+       $(AR) rc $@ $+
+       $(RANLIB) $@
+
+t.o: $(ROOTDIR)/common/t.c $(ROOTDIR)/common/test.h tests.h
        $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $<
 
-t: $(OBJS) main.o
+t: t.o tests.a
        $(CC) $+ $(LDFLAGS) -o $@
 
+b.o: $(ROOTDIR)/common/b.c $(ROOTDIR)/common/test.h tests.h
+       $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $<
+
+b: b.o tests.a
+       $(CC) $+ $(LDFLAGS) -lrt -o $@
+
 .PHONY: all clean