|
nsz |
7308b3 |
# gnu makefile
|
|
nsz |
8f27a3 |
# when included in a Makefile it builds *.c unless SRCS are overridden
|
|
nsz |
7308b3 |
|
|
nsz |
8f27a3 |
# default TROOT works from src/*/Makefile
|
|
nsz |
086c6a |
TROOT ?= ../..
|
|
nsz |
086c6a |
SRCS ?= $(sort $(wildcard *.c))
|
|
nsz |
7308b3 |
OBJS = $(SRCS:.c=.o)
|
|
nsz |
7308b3 |
|
|
nsz |
a520c1 |
AR=ar
|
|
nsz |
a520c1 |
RANLIB=ranlib
|
|
nsz |
7308b3 |
|
|
nsz |
d28968 |
CFLAGS += -g -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE -std=c99 -pipe -Wall -Wno-unused-function -Wno-missing-braces
|
|
nsz |
7f409d |
LDFLAGS += -g -lpthread -lrt -lm
|
|
nsz |
7308b3 |
|
|
nsz |
e08536 |
include $(TROOT)/config.mak
|
|
nsz |
8f27a3 |
|
|
nsz |
8f27a3 |
CFLAGS += -I$(TROOT)/common
|
|
nsz |
08c133 |
|
|
nsz |
8f27a3 |
all: test
|
|
nsz |
7308b3 |
|
|
nsz |
086c6a |
test: t b
|
|
nsz |
086c6a |
./t
|
|
nsz |
7308b3 |
|
|
nsz |
7308b3 |
clean:
|
|
nsz |
086c6a |
rm -f $(OBJS) t t_.o b b_.o tests.a tests.h
|
|
nsz |
7308b3 |
|
|
nsz |
7308b3 |
.c.o:
|
|
nsz |
8f27a3 |
$(CC) $(CFLAGS) -c -o $@ $<
|
|
nsz |
7308b3 |
|
|
nsz |
e08536 |
$(OBJS): $(TROOT)/common/test.h $(TROOT)/config.mak
|
|
nsz |
7308b3 |
|
|
nsz |
7d87d3 |
tests.h: $(OBJS)
|
|
nsz |
a520c1 |
nm -f posix $+ |awk ' \
|
|
nsz |
a520c1 |
/^test/ && $$2=="T"{print "T(" $$1 ")"} \
|
|
nsz |
a520c1 |
/^bench/ && $$2=="T"{print "B(" $$1 ")"} \
|
|
nsz |
7d87d3 |
' >tests.h
|
|
nsz |
a520c1 |
|
|
nsz |
a520c1 |
tests.a: $(OBJS)
|
|
nsz |
a520c1 |
$(AR) rc $@ $+
|
|
nsz |
a520c1 |
$(RANLIB) $@
|
|
nsz |
7308b3 |
|
|
nsz |
086c6a |
# TODO: /tmp/t.o ?
|
|
nsz |
086c6a |
t_.o: $(TROOT)/common/t.c $(TROOT)/common/test.h tests.h
|
|
nsz |
8f27a3 |
$(CC) $(CFLAGS) -I. -c -o $@ $<
|
|
nsz |
7308b3 |
|
|
nsz |
086c6a |
t: t_.o tests.a
|
|
nsz |
7308b3 |
$(CC) $+ $(LDFLAGS) -o $@
|
|
nsz |
7308b3 |
|
|
nsz |
086c6a |
b_.o: $(TROOT)/common/b.c $(TROOT)/common/test.h tests.h
|
|
nsz |
8f27a3 |
$(CC) $(CFLAGS) -I. -c -o $@ $<
|
|
nsz |
a520c1 |
|
|
nsz |
086c6a |
b: b_.o tests.a
|
|
nsz |
a520c1 |
$(CC) $+ $(LDFLAGS) -lrt -o $@
|
|
nsz |
a520c1 |
|
|
nsz |
8f27a3 |
.PHONY: all clean test
|