2 # when included in src/*/Makefile then it builds a binary locally
3 # when included in ./Makefile then all tests are linked into one binary
7 SRCS ?= $(sort $(wildcard src/*/*.c))
9 SRCS ?= $(sort $(wildcard *.c))
14 prefix = /usr/local/musl
15 includedir = $(prefix)/include
16 libdir = $(prefix)/lib
21 CFLAGS += -g -D_POSIX_C_SOURCE=200809L -std=c99 -pipe -Wall
22 LDFLAGS += -g -lpthread -lrt -lm
23 INC += -I$(TROOT)/common
25 -include $(TROOT)/Makefile.conf
27 ifeq ($(usemusl), yes)
29 LIBCC=$(shell gcc -print-file-name=libgcc.a |sed 's,/libgcc.a,,')
30 #LIBCC=$(shell pcc -v /dev/null 2>&1 |sed -n 's,/crtbegin.o.*,,;s,.* /,/,p')
31 CFLAGS += -nostdinc -ffreestanding -fno-stack-protector
32 LDFLAGS += -nostdlib -Wl,-e,_start,-Bstatic $(libdir)/crti.o $(libdir)/crt1.o $(libdir)/crtn.o -L $(libdir) -lc -L $(LIBCC) -l$(CC)
33 INC += -isystem $(includedir)
40 rm -f $(OBJS) t t_.o b b_.o tests.a tests.h
43 $(CC) $(CFLAGS) $(INC) -c -o $@ $<
45 $(OBJS): $(TROOT)/common/test.h $(TROOT)/Makefile.conf
48 nm -f posix $+ |awk ' \
49 /^test/ && $$2=="T"{print "T(" $$1 ")"} \
50 /^bench/ && $$2=="T"{print "B(" $$1 ")"} \
58 t_.o: $(TROOT)/common/t.c $(TROOT)/common/test.h tests.h
59 $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $<
62 $(CC) $+ $(LDFLAGS) -o $@
64 b_.o: $(TROOT)/common/b.c $(TROOT)/common/test.h tests.h
65 $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $<
68 $(CC) $+ $(LDFLAGS) -lrt -o $@