2012-09-19 14:26:37 +04:00
|
|
|
|
|
|
|
LIBNAME=librdkafka
|
2013-06-06 00:22:20 +04:00
|
|
|
LIBVER=1
|
2012-09-19 14:26:37 +04:00
|
|
|
|
2013-06-06 00:22:20 +04:00
|
|
|
DESTDIR?=/usr/local
|
2012-09-19 14:26:37 +04:00
|
|
|
|
2013-06-06 00:22:20 +04:00
|
|
|
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
|
2013-09-06 01:44:23 +04:00
|
|
|
SRCS+= snappy.c
|
2013-06-06 00:22:20 +04:00
|
|
|
HDRS= rdkafka.h
|
2012-09-19 14:26:37 +04:00
|
|
|
|
|
|
|
OBJS= $(SRCS:.c=.o)
|
|
|
|
DEPS= ${OBJS:%.o=%.d}
|
|
|
|
|
2013-09-11 18:50:11 +04:00
|
|
|
CFLAGS+=-O2 -Wall -Werror -Wfloat-equal -Wpointer-arith -Wno-gnu-designator -fPIC -I.
|
|
|
|
CFLAGS+=-g
|
2013-09-06 01:44:23 +04:00
|
|
|
# Enable iovecs in snappy
|
|
|
|
CFLAGS+=-DSG
|
2012-09-19 14:26:37 +04:00
|
|
|
|
|
|
|
# Profiling
|
|
|
|
#CFLAGS+=-O0
|
|
|
|
#CFLAGS += -pg
|
|
|
|
#LDFLAGS += -pg
|
|
|
|
|
2013-08-27 15:38:31 +04:00
|
|
|
LDFLAGS+=-g -fPIC
|
2012-09-19 14:26:37 +04:00
|
|
|
|
|
|
|
.PHONY:
|
|
|
|
|
|
|
|
all: libs
|
|
|
|
|
2013-06-06 00:22:20 +04:00
|
|
|
libs: $(LIBNAME).so.$(LIBVER) $(LIBNAME).a
|
2012-09-19 14:26:37 +04:00
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) -MD -MP $(CFLAGS) -c $<
|
|
|
|
|
2013-06-06 00:22:20 +04:00
|
|
|
|
|
|
|
$(LIBNAME).so.$(LIBVER): $(OBJS)
|
2013-09-11 18:50:11 +04:00
|
|
|
@(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)
|
2012-09-19 14:26:37 +04:00
|
|
|
|
|
|
|
$(LIBNAME).a: $(OBJS)
|
|
|
|
$(AR) rcs $@ $(OBJS)
|
|
|
|
|
|
|
|
install:
|
2013-06-06 00:22:20 +04:00
|
|
|
if [ "$(DESTDIR)" != "/usr/local" ]; then \
|
|
|
|
DESTDIR="$(DESTDIR)/usr"; \
|
2013-07-09 01:11:40 +04:00
|
|
|
else \
|
|
|
|
DESTDIR="$(DESTDIR)" ; \
|
2013-06-06 00:22:20 +04:00
|
|
|
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)
|
2012-09-19 14:26:37 +04:00
|
|
|
|
2013-09-23 00:44:27 +04:00
|
|
|
tests: .PHONY
|
|
|
|
make -C tests
|
|
|
|
|
2012-09-19 14:26:37 +04:00
|
|
|
clean:
|
2013-06-06 00:22:20 +04:00
|
|
|
rm -f $(OBJS) $(DEPS) \
|
|
|
|
$(LIBNAME)*.a $(LIBNAME)*.so $(LIBNAME)*.so.$(LIBVER)
|
2013-09-23 00:44:27 +04:00
|
|
|
make -C tests clean
|
2012-09-19 14:26:37 +04:00
|
|
|
|
|
|
|
-include $(DEPS)
|