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
20 CFLAGS += -g -std=c99 -pipe -Wall
22 INC += -I$(ROOTDIR)/common
24 ifeq ($(usemusl), yes)
26 LIBCC=$(shell gcc -print-file-name=libgcc.a |sed 's,/libgcc.a,,')
27 #LIBCC=$(shell pcc -v /dev/null 2>&1 |sed -n 's,/crtbegin.o.*,,;s,.* /,/,p')
28 CFLAGS += -nostdinc -ffreestanding -fno-stack-protector
29 LDFLAGS += -nostdlib -Wl,-e,_start,-Bstatic $(libdir)/crti.o $(libdir)/crt1.o $(libdir)/crtn.o -L $(libdir) -lc -L $(LIBCC) -l$(CC)
30 INC += -isystem $(includedir)
36 rm -f $(OBJS) t main.o main.h
39 $(CC) $(CFLAGS) $(INC) -c -o $@ $<
41 $(OBJS): $(ROOTDIR)/common/test.h
44 nm -f posix $+ |awk '/^test/ && $$2=="T"{print "T(" $$1 ")"}' >main.h
46 main.o: $(ROOTDIR)/common/main.c $(ROOTDIR)/common/test.h main.h
47 $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $<
50 $(CC) $+ $(LDFLAGS) -o $@