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 \
|
2014-01-15 18:55:11 +04:00
|
|
|
rdkafka_defaultconf.c rdkafka_timer.c rdkafka_offset.c
|
2013-06-06 00:22:20 +04:00
|
|
|
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}
|
|
|
|
|
2014-01-07 18:29:49 +04:00
|
|
|
CFLAGS+=-O2 -Wall -Werror -Wfloat-equal -Wpointer-arith -I.
|
2013-09-11 18:50:11 +04:00
|
|
|
CFLAGS+=-g
|
2013-09-23 18:31:56 +04:00
|
|
|
|
|
|
|
# Clang warnings to ignore
|
2013-11-25 17:21:59 +04:00
|
|
|
ifeq ($(CC),clang)
|
|
|
|
CFLAGS+=-Wno-gnu-designator
|
|
|
|
endif
|
2013-09-23 18:31:56 +04:00
|
|
|
|
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
|
|
|
|
|
2014-01-07 18:29:49 +04:00
|
|
|
LDFLAGS+= -g
|
2014-02-01 16:25:34 +04:00
|
|
|
UNAME_S = $(shell uname -s)
|
|
|
|
ifneq ($(findstring CYGWIN,$(UNAME_S)),CYGWIN)
|
2014-01-07 18:29:49 +04:00
|
|
|
LDFLAGS+=-fPIC
|
|
|
|
CFLAGS+=-fPIC
|
|
|
|
endif
|
2012-09-19 14:26:37 +04:00
|
|
|
|
|
|
|
.PHONY:
|
|
|
|
|
|
|
|
all: libs
|
|
|
|
|
2013-10-04 02:15:59 +04:00
|
|
|
libs: $(LIBNAME).so.$(LIBVER) $(LIBNAME).a CONFIGURATION.md
|
2012-09-19 14:26:37 +04:00
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) -MD -MP $(CFLAGS) -c $<
|
|
|
|
|
2014-02-05 07:24:55 +04:00
|
|
|
librdkafka.lds: rdkafka.h
|
|
|
|
@echo "Generating linker script"
|
|
|
|
./lds-gen.pl > $@
|
2013-06-06 00:22:20 +04:00
|
|
|
|
2014-02-05 07:24:55 +04:00
|
|
|
$(LIBNAME).so.$(LIBVER): $(OBJS) librdkafka.lds
|
2014-01-15 06:53:18 +04:00
|
|
|
@(if [ $(UNAME_S) = "Darwin" ]; then \
|
|
|
|
$(CC) $(LDFLAGS) \
|
|
|
|
$(OBJS) -dynamiclib -o $@ -lpthread -lz -lc ; \
|
|
|
|
else \
|
2013-09-11 18:50:11 +04:00
|
|
|
$(CC) $(LDFLAGS) \
|
2013-09-23 00:48:46 +04:00
|
|
|
-shared -Wl,-soname,$@ \
|
|
|
|
-Wl,--version-script=librdkafka.lds \
|
2013-09-11 18:50:11 +04:00
|
|
|
$(OBJS) -o $@ -lpthread -lrt -lz -lc ; \
|
|
|
|
fi)
|
2012-09-19 14:26:37 +04:00
|
|
|
|
|
|
|
$(LIBNAME).a: $(OBJS)
|
|
|
|
$(AR) rcs $@ $(OBJS)
|
|
|
|
|
2013-10-04 02:15:59 +04:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-09-23 18:31:56 +04:00
|
|
|
examples: .PHONY
|
|
|
|
make -C $@
|
|
|
|
|
2012-09-19 14:26:37 +04:00
|
|
|
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 ; \
|
2014-01-07 19:01:18 +04:00
|
|
|
install $(HDRS) $$DESTDIR/include/$(LIBNAME) ; \
|
|
|
|
install $(LIBNAME).a $$DESTDIR/lib ; \
|
|
|
|
install $(LIBNAME).so.$(LIBVER) $$DESTDIR/lib ; \
|
2013-06-06 00:22:20 +04:00
|
|
|
(cd $$DESTDIR/lib && ln -sf $(LIBNAME).so.$(LIBVER) $(LIBNAME).so)
|
2012-09-19 14:26:37 +04:00
|
|
|
|
2014-01-17 07:07:46 +04:00
|
|
|
tests: .PHONY check
|
2013-09-23 00:44:27 +04:00
|
|
|
make -C tests
|
|
|
|
|
2014-01-17 07:07:46 +04:00
|
|
|
check:
|
|
|
|
@(RET=true ; \
|
|
|
|
for f in librdkafka.so.1 librdkafka.a CONFIGURATION.md \
|
|
|
|
examples/rdkafka_example examples/rdkafka_performance ; do \
|
|
|
|
printf "%-30s " $$f ; \
|
|
|
|
if [ -f "$$f" ]; then \
|
|
|
|
echo "\033[32mOK\033[0m"; \
|
|
|
|
else \
|
|
|
|
echo "\033[31mMISSING\033[0m"; \
|
|
|
|
RET=false ; \
|
|
|
|
fi; \
|
|
|
|
done ; \
|
|
|
|
$$($$RET))
|
|
|
|
|
2012-09-19 14:26:37 +04:00
|
|
|
clean:
|
2013-06-06 00:22:20 +04:00
|
|
|
rm -f $(OBJS) $(DEPS) \
|
2014-02-05 07:24:55 +04:00
|
|
|
$(LIBNAME)*.a $(LIBNAME)*.so $(LIBNAME)*.so.$(LIBVER) \
|
|
|
|
librdkafka.lds
|
2013-09-23 00:44:27 +04:00
|
|
|
make -C tests clean
|
2013-11-04 19:06:46 +04:00
|
|
|
make -C examples clean
|
2012-09-19 14:26:37 +04:00
|
|
|
|
|
|
|
-include $(DEPS)
|