forked from confluentinc/librdkafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (66 loc) · 1.85 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
LIBNAME=librdkafka
LIBVER=1
DESTDIR?=/usr/local
SRCS= rdkafka.c rdkafka_broker.c rdkafka_msg.c rdkafka_topic.c \
rdkafka_defaultconf.c
SRCS+= rdcrc32.c rdgz.c rdaddr.c rdrand.c rdthread.c rdqueue.c rdlog.c
SRCS+= snappy.c
HDRS= rdkafka.h
OBJS= $(SRCS:.c=.o)
DEPS= ${OBJS:%.o=%.d}
CFLAGS+=-O2 -Wall -Werror -Wfloat-equal -Wpointer-arith -fPIC -I.
CFLAGS+=-g
# Clang warnings to ignore
ifeq ($(CC),clang)
CFLAGS+=-Wno-gnu-designator
endif
# Enable iovecs in snappy
CFLAGS+=-DSG
# Profiling
#CFLAGS+=-O0
#CFLAGS += -pg
#LDFLAGS += -pg
LDFLAGS+=-g -fPIC
.PHONY:
all: libs
libs: $(LIBNAME).so.$(LIBVER) $(LIBNAME).a CONFIGURATION.md
%.o: %.c
$(CC) -MD -MP $(CFLAGS) -c $<
$(LIBNAME).so.$(LIBVER): $(OBJS)
@(if [ "`uname -s`" = "Linux" ]; then \
$(CC) $(LDFLAGS) \
-shared -Wl,-soname,$@ \
-Wl,--version-script=librdkafka.lds \
$(OBJS) -o $@ -lpthread -lrt -lz -lc ; \
elif [ "`uname -s`" = "Darwin" ]; then \
$(CC) $(LDFLAGS) \
$(OBJS) -dynamiclib -o $@ -lpthread -lz -lc ; \
fi)
$(LIBNAME).a: $(OBJS)
$(AR) rcs $@ $(OBJS)
CONFIGURATION.md: rdkafka.h examples
examples/rdkafka_performance -X list > CONFIGURATION.md.tmp
cmp CONFIGURATION.md CONFIGURATION.md.tmp || \
mv CONFIGURATION.md.tmp CONFIGURATION.md
rm -f CONFIGURATION.md.tmp
examples: .PHONY
make -C $@
install:
if [ "$(DESTDIR)" != "/usr/local" ]; then \
DESTDIR="$(DESTDIR)/usr"; \
else \
DESTDIR="$(DESTDIR)" ; \
fi ; \
install -d $$DESTDIR/include/librdkafka $$DESTDIR/lib ; \
install -t $$DESTDIR/include/$(LIBNAME) $(HDRS) ; \
install -t $$DESTDIR/lib $(LIBNAME).a ; \
install -t $$DESTDIR/lib $(LIBNAME).so.$(LIBVER) ; \
(cd $$DESTDIR/lib && ln -sf $(LIBNAME).so.$(LIBVER) $(LIBNAME).so)
tests: .PHONY
make -C tests
clean:
rm -f $(OBJS) $(DEPS) \
$(LIBNAME)*.a $(LIBNAME)*.so $(LIBNAME)*.so.$(LIBVER)
make -C tests clean
make -C examples clean
-include $(DEPS)