X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=Makefile.inc;h=69de079fb9894dd99182dc2eed727f863dd59b3b;hb=a9d0a0ddf7530e8e462ec2ac731558b9037cc905;hp=f163fdab6a14b0484d7343630562d3e8d83c5d27;hpb=3a72706b330e7396bd3ea22e48ffb21f17a000a3;p=libc-test diff --git a/Makefile.inc b/Makefile.inc index f163fda..69de079 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -1,46 +1,33 @@ # 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 - -ROOTDIR ?= ../.. -ifeq ($(ROOTDIR), .) -SRCS = $(sort $(wildcard src/*/*.c)) -else -SRCS = $(sort $(wildcard *.c)) -endif -OBJS = $(SRCS:.c=.o) +# when included in a Makefile it builds *.c unless SRCS are overridden -usemusl = yes -prefix = /usr/local/musl -includedir = $(prefix)/include -libdir = $(prefix)/lib --include $(ROOTDIR)/Makefile.conf +# default TROOT works from src/*/Makefile +TROOT ?= ../.. +SRCS ?= $(sort $(wildcard *.c)) +OBJS = $(SRCS:.c=.o) AR=ar RANLIB=ranlib -CFLAGS += -g -D_POSIX_C_SOURCE=200809L -std=c99 -pipe -Wall +CFLAGS += -g -D_POSIX_C_SOURCE=200809L -std=c99 -pipe -Wall -Wno-unused-function -Wno-missing-braces LDFLAGS += -g -lpthread -lrt -lm -INC += -I$(ROOTDIR)/common -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 +-include $(TROOT)/config.mak + +CFLAGS += -I$(TROOT)/common + +all: test -all: t b +test: t b + ./t clean: - rm -f $(OBJS) t t.o b b.o tests.a tests.h + rm -f $(OBJS) t t_.o b b_.o tests.a tests.h .c.o: - $(CC) $(CFLAGS) $(INC) -c -o $@ $< + $(CC) $(CFLAGS) -c -o $@ $< -$(OBJS): $(ROOTDIR)/common/test.h $(ROOTDIR)/Makefile.conf +$(OBJS): $(TROOT)/common/test.h tests.h: $(OBJS) nm -f posix $+ |awk ' \ @@ -52,16 +39,17 @@ tests.a: $(OBJS) $(AR) rc $@ $+ $(RANLIB) $@ -t.o: $(ROOTDIR)/common/t.c $(ROOTDIR)/common/test.h tests.h - $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $< +# TODO: /tmp/t.o ? +t_.o: $(TROOT)/common/t.c $(TROOT)/common/test.h tests.h + $(CC) $(CFLAGS) -I. -c -o $@ $< -t: t.o tests.a +t: t_.o tests.a $(CC) $+ $(LDFLAGS) -o $@ -b.o: $(ROOTDIR)/common/b.c $(ROOTDIR)/common/test.h tests.h - $(CC) $(CFLAGS) $(INC) -I. -c -o $@ $< +b_.o: $(TROOT)/common/b.c $(TROOT)/common/test.h tests.h + $(CC) $(CFLAGS) -I. -c -o $@ $< -b: b.o tests.a +b: b_.o tests.a $(CC) $+ $(LDFLAGS) -lrt -o $@ -.PHONY: all clean +.PHONY: all clean test