X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=Makefile.inc;h=22f028231b3b8f5b091fe0ad34e20df660911e74;hb=086c6aa74d2a792cead9b7245239a82459ed909c;hp=62356af690a5ef7a1f42e41b609a2d9d703fe698;hpb=a520c1cb2a3e6eaeb4abba79b0582f7e434ee3ed;p=libc-test diff --git a/Makefile.inc b/Makefile.inc index 62356af..22f0282 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -2,11 +2,11 @@ # when included in src/*/Makefile then it builds a binary locally # when included in ./Makefile then all tests are linked into one binary -ROOTDIR ?= ../.. -ifeq ($(ROOTDIR), .) -SRCS = $(sort $(wildcard src/*/*.c)) +TROOT ?= ../.. +ifeq ($(TROOT), .) +SRCS ?= $(sort $(wildcard src/*/*.c)) else -SRCS = $(sort $(wildcard *.c)) +SRCS ?= $(sort $(wildcard *.c)) endif OBJS = $(SRCS:.c=.o) @@ -14,14 +14,15 @@ usemusl = yes prefix = /usr/local/musl includedir = $(prefix)/include libdir = $(prefix)/lib --include $(ROOTDIR)/Makefile.conf AR=ar RANLIB=ranlib -CFLAGS += -g -std=c99 -pipe -Wall -LDFLAGS += -g -INC += -I$(ROOTDIR)/common +CFLAGS += -g -D_POSIX_C_SOURCE=200809L -std=c99 -pipe -Wall +LDFLAGS += -g -lpthread -lrt -lm +INC += -I$(TROOT)/common + +-include $(TROOT)/Makefile.conf ifeq ($(usemusl), yes) CC=gcc @@ -32,36 +33,38 @@ LDFLAGS += -nostdlib -Wl,-e,_start,-Bstatic $(libdir)/crti.o $(libdir)/crt1.o $( INC += -isystem $(includedir) endif -all: t b +test: t b + ./t clean: - rm -f $(OBJS) t main.o main.h b bench.o tests.a + 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): $(TROOT)/common/test.h $(TROOT)/Makefile.conf -main.h: $(OBJS) +tests.h: $(OBJS) nm -f posix $+ |awk ' \ /^test/ && $$2=="T"{print "T(" $$1 ")"} \ /^bench/ && $$2=="T"{print "B(" $$1 ")"} \ - ' >main.h + ' >tests.h tests.a: $(OBJS) $(AR) rc $@ $+ $(RANLIB) $@ -main.o: $(ROOTDIR)/common/main.c $(ROOTDIR)/common/test.h main.h +# TODO: /tmp/t.o ? +t_.o: $(TROOT)/common/t.c $(TROOT)/common/test.h tests.h $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $< -t: main.o tests.a +t: t_.o tests.a $(CC) $+ $(LDFLAGS) -o $@ -bench.o: $(ROOTDIR)/common/bench.c $(ROOTDIR)/common/test.h main.h +b_.o: $(TROOT)/common/b.c $(TROOT)/common/test.h tests.h $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $< -b: bench.o tests.a +b: b_.o tests.a $(CC) $+ $(LDFLAGS) -lrt -o $@ .PHONY: all clean