X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=Makefile.inc;h=9137e2bfc1522d0da4e3ebe39024e5ba36464164;hb=b5bbc6ebaeaf4381ea2436a3b410dcf4980c8efd;hp=22f028231b3b8f5b091fe0ad34e20df660911e74;hpb=086c6aa74d2a792cead9b7245239a82459ed909c;p=libc-test diff --git a/Makefile.inc b/Makefile.inc index 22f0282..9137e2b 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -1,70 +1,25 @@ -# gnu makefile -# when included in src/*/Makefile then it builds a binary locally -# when included in ./Makefile then all tests are linked into one binary - -TROOT ?= ../.. -ifeq ($(TROOT), .) -SRCS ?= $(sort $(wildcard src/*/*.c)) -else -SRCS ?= $(sort $(wildcard *.c)) -endif -OBJS = $(SRCS:.c=.o) - -usemusl = yes -prefix = /usr/local/musl -includedir = $(prefix)/include -libdir = $(prefix)/lib - -AR=ar -RANLIB=ranlib - -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 -LIBCC=$(shell gcc -print-file-name=libgcc.a |sed 's,/libgcc.a,,') -#LIBCC=$(shell pcc -v /dev/null 2>&1 |sed -n 's,/crtbegin.o.*,,;s,.* /,/,p') -CFLAGS += -nostdinc -ffreestanding -fno-stack-protector -LDFLAGS += -nostdlib -Wl,-e,_start,-Bstatic $(libdir)/crti.o $(libdir)/crt1.o $(libdir)/crtn.o -L $(libdir) -lc -L $(LIBCC) -l$(CC) -INC += -isystem $(includedir) -endif - -test: t b - ./t - +CFLAGS+=-g -pipe -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wno-unused-function -Wno-missing-braces +LDFLAGS+=-g + +SRC=$(sort $(wildcard *.c)) +OBJ=$(SRC:.c=.o) +DSOOBJ=$(filter %_dso.o,$(OBJ)) +BINOBJ=$(filter-out %_dso.o,$(OBJ)) +DSO=$(DSOOBJ:.o=.so) +BIN=$(BINOBJ:.o=) + +ROOT=../.. +include $(ROOT)/config.mak + +all: $(BIN) $(DSO) +run: all + @N=0; for i in $(BIN);do ./$$i || N=$$((N+1)); done; [ "$$N" = 0 ] && echo PASS || echo FAILS: $$N clean: - rm -f $(OBJS) t t_.o b b_.o tests.a tests.h - -.c.o: - $(CC) $(CFLAGS) $(INC) -c -o $@ $< - -$(OBJS): $(TROOT)/common/test.h $(TROOT)/Makefile.conf - -tests.h: $(OBJS) - nm -f posix $+ |awk ' \ - /^test/ && $$2=="T"{print "T(" $$1 ")"} \ - /^bench/ && $$2=="T"{print "B(" $$1 ")"} \ - ' >tests.h - -tests.a: $(OBJS) - $(AR) rc $@ $+ - $(RANLIB) $@ - -# TODO: /tmp/t.o ? -t_.o: $(TROOT)/common/t.c $(TROOT)/common/test.h tests.h - $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $< - -t: t_.o tests.a - $(CC) $+ $(LDFLAGS) -o $@ - -b_.o: $(TROOT)/common/b.c $(TROOT)/common/test.h tests.h - $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $< - -b: b_.o tests.a - $(CC) $+ $(LDFLAGS) -lrt -o $@ - -.PHONY: all clean + rm -f $(OBJ) $(DSO) $(BIN) + +$(OBJ): test.h +$(DSOOBJ): CFLAGS += -fPIC +%.so: %.o + $(CC) $(LDFLAGS) -shared -o $@ $< +%: %.o + $(CC) $(LDFLAGS) -o $@ $(patsubst %.so,./%.so,$+)