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
17 -include $(ROOTDIR)/Makefile.conf
22 CFLAGS += -g -std=c99 -pipe -Wall
24 INC += -I$(ROOTDIR)/common
26 ifeq ($(usemusl), yes)
28 LIBCC=$(shell gcc -print-file-name=libgcc.a |sed 's,/libgcc.a,,')
29 #LIBCC=$(shell pcc -v /dev/null 2>&1 |sed -n 's,/crtbegin.o.*,,;s,.* /,/,p')
30 CFLAGS += -nostdinc -ffreestanding -fno-stack-protector
31 LDFLAGS += -nostdlib -Wl,-e,_start,-Bstatic $(libdir)/crti.o $(libdir)/crt1.o $(libdir)/crtn.o -L $(libdir) -lc -L $(LIBCC) -l$(CC)
32 INC += -isystem $(includedir)
38 rm -f $(OBJS) t main.o main.h b bench.o tests.a
41 $(CC) $(CFLAGS) $(INC) -c -o $@ $<
43 $(OBJS): $(ROOTDIR)/common/test.h
46 nm -f posix $+ |awk ' \
47 /^test/ && $$2=="T"{print "T(" $$1 ")"} \
48 /^bench/ && $$2=="T"{print "B(" $$1 ")"} \
55 main.o: $(ROOTDIR)/common/main.c $(ROOTDIR)/common/test.h main.h
56 $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $<
59 $(CC) $+ $(LDFLAGS) -o $@
61 bench.o: $(ROOTDIR)/common/bench.c $(ROOTDIR)/common/test.h main.h
62 $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $<
65 $(CC) $+ $(LDFLAGS) -lrt -o $@