1,建目录:feeds/packages/libs/librdkafka
2,在该目录下创建Makefile:
#
# Copyright (C) 2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=librdkafka
PKG_VERSION:=0.8
PKG_SOURCE:=$(PKG_VERSION).zip
PKG_SOURCE_URL:=https://github.com/edenhill/librdkafka/archive
PKG_SOURCE_VERSION:=0.8.6
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL:=1
PKG_FIXUP:=autoreconf
include $(INCLUDE_DIR)/package.mk
define Package/librdkafka
TITLE:=librdkafka
SECTION:=libs
DEPENDS:=
+libpthread +zlib +librt +libcrypto +libopenssl
CATEGORY:=Qwifi
URL:=https://github.com/edenhill/librdkafka
endef
TARGET_CONFIGURE_OPTS = \
AR=$(TARGET_CROSS)ar \
AS="$(TARGET_CC) -c $(TARGET_CFLAGS)" \
LD=$(TARGET_CROSS)gcc \
NM=$(TARGET_CROSS)nm \
CC="$(TARGET_CC)" \
GCC="$(TARGET_CC)" \
CXX="$(TARGET_CXX)" \
RANLIB=$(TARGET_CROSS)ranlib \
STRIP=$(TARGET_CROSS)strip \
OBJCOPY=$(TARGET_CROSS)objcopy \
OBJDUMP=$(TARGET_CROSS)objdump \
SIZE=$(TARGET_CROSS)size \
PREFIX=$(PKG_INSTALL_DIR)/usr
define Build/Configure
(cd $(PKG_BUILD_DIR); ./configure);
endef
define Package/librdkafka/prepare
mkdir -p $(PKG_BUILD_DIR)
$(INSTALL_DIR) $(PKG_BUILD_DIR)/usr/include
$(INSTALL_DIR) $(PKG_BUILD_DIR)/usr/lib
endef
define Package/librdkafka/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/local/lib/*.so* $(1)/usr/lib/
endef
$(eval $(call BuildPackage,librdkafka))
这里用的是0.8.6版本
3,编译
make package/librdkafka/compile V=s
这次编译会下载librdkafka的源码包,但编译当然不会那么顺利的通过
a,若提示#error Unknown location for endian.h,则找到错误的头文件,增加一条宏定义
b,编译example src-cpp可能问题比较多,这两个文件可以屏蔽掉,不编译,在这里修改
build_dir/target-mips_34kc_musl-1.1.14/librdkafka-0.8/Makefile
去掉src-cpp example相关的编译语句
4,再次编译,成功生成so库
make package/librdkafka/compile V=s
注意:此时不要使用
make package/librdkafka/{clean,compile} V=s,因为clean后,build_dir下的修改又还原了
librdkafka例程编译见http://blog.sina.com.cn/s/blog_636a55070102waby.html