Allow for static initialisation.
[libeze] / Makefile
1
2 CPPFLAGS=-I.
3 CFLAGS=-O2 -g -fPIC -Wall -mtune=native
4 test_LDLIBS=-lpthread -lrt
5 ARFLAGS=rvsUc
6 VERSION=2.1.99
7
8 SRCS=                                           \
9  ez-bitset.c                                    \
10  ez-blob.c                                      \
11  ez-blob.c                                      \
12  ez-blob-io.c                                   \
13  ez-blob-print.c                                \
14  ez-blob-dump.c                                 \
15  ez-blob-tagz.c                                 \
16  ez-blob-xdrn.c                                 \
17  ez-port.c                                      \
18  ez-set.c                                       \
19  ez-tree.c
20
21 HEADERS =                                       \
22  ez-bitset.h                                    \
23  ez-blob.h                                      \
24  ez-blobio.h                                    \
25  ez-blob-tagz.h                                 \
26  ez-blob-xdrn.h                                 \
27  ez-list.h                                      \
28  ez-node.h                                      \
29  ez-port.h                                      \
30  ez-set.h                                       \
31  ez-tree.h
32
33 test_SRCS=test-bitset.c test-blob.c test-port.c test-set.c test-tree.c test-list.c
34
35 TESTS=$(test_SRCS:.c=)
36
37 OBJS=$(SRCS:.c=.o)
38
39 all: libeze.a($(OBJS))
40
41 libeze.a: libeze.a($(OBJS))
42 tests: $(TESTS)
43 check: tests
44         for test in $(TESTS) ; do               \
45                 echo $$test ;                   \
46                 ./$$test || exit 1;             \
47         done
48
49 test-%: test-%.o
50         $(CC) $(CFLAGS) -o $@ $< libeze.a $(test_LDLIBS)
51
52 test-bitset: libeze.a(ez-bitset.o)
53 test-blob: libeze.a(ez-blob.o) libeze.a(ez-blob-print.o) libeze.a(ez-blob-io.o) \
54         libeze.a(ez-blob-xdrn.o) libeze.a(ez-blob-tagz.o) libeze.a(ez-blob-dump.o)
55 test-port: libeze.a(ez-port.o)
56 test-set: libeze.a(ez-set.o)
57 test-tree: libeze.a(ez-tree.o)
58
59 dist: libeze-$(VERSION).tar.gz
60
61 libeze-$(VERSION).tar.gz: $(HEADERS) $(SRCS) $(test_SRCS) Makefile README CHANGES COPYING
62         tar -c                                          \
63                 --transform=s@^@libeze-$(VERSION)/@     \
64                 -f $@                                   \
65                 -z                                      \
66                 $^
67
68 clean:
69         rm -f libeze.a
70         rm -f *.o
71         rm -f $(TESTS)
72         rm -rf .deps
73
74 .deps/%.d: %.c
75         @rm -f $@
76         @install -d .deps $(@D)
77         @$(CC) -MM $(CPPFLAGS) $< > $@ || rm $@
78
79 # Without this the behavior of libeze.a($(OBJS)) changes when one includes the .d files.
80 .INTERMEDIATE: $(OBJS)
81 .NOTPARALLEL:
82
83 ifeq ($(filter clean dist,$(MAKECMDGOALS)),)
84 -include $(patsubst %.c,.deps/%.d,$(SRCS) $(test_SRCS))
85 endif