openwrt加入leveldb包编译

升级openwrt的cmake工具版本

  • 由于标准openwrt发行版没有带leveldb包,需要自己加入,首先openwrt 的cmake 版本必须在3.1.13版本往上。升级cmake方法,修改openwrt/tools/cmake/Makefile如下,同时删掉patchs目录
#
# Copyright (C) 2006-2014 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:=cmake
PKG_VERSION:=3.1.3

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.cmake.org/files/v3.1/
PKG_MD5SUM:=5697a77503bb5636f4b4057dcc02aa32

HOST_BUILD_PARALLEL:=1
HOST_CONFIGURE_PARALLEL:=1

include $(INCLUDE_DIR)/host-build.mk

HOST_CONFIGURE_VARS :=

HOST_CONFIGURE_ARGS := \
    --prefix=$(STAGING_DIR_HOST) \
    $(if $(MAKE_JOBSERVER),--parallel="$(MAKE_JOBSERVER)")

$(eval $(call HostBuild))

配置leveldb包

  • 新建包目录以及feeds/packages/libs/leveldb/Makefile文件,内容如下,
    同时新建feeds/packages/libs/leveldb/patches,放入对应的补丁文件,命名为100-downgrade-cmake-version.patch
include $(TOPDIR)/rules.mk

PKG_NAME:=leveldb
PKG_VERSION:=1.22
PKG_RELEASE:=1
PKG_INSTALL:=1

PKG_SOURCE:=$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/google/leveldb/archive/
PKG_MD5SUM:=e1dbde14dcda1b58b49f0c214464fdd9
PKG_BUILD_PARALLEL:=1

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

define Package/leveldb/Default
  SUBMENU:=database
  TITLE:=(leveldb)A key/value database library
  URL:=https://code.google.com/p/leveldb/
  MAINTAINER:=code.google.com
endef

define Package/leveldb
  DEPENDS:=+snappy
  SECTION:=libs
  CATEGORY:=Libraries
  SUBMENU:=database
  TITLE:=A fast and lightweight key/value database library
  URL:=https://code.google.com/p/leveldb/
  DEPENDS:=+libstdcpp +libpthread
  DEFAULT:=y
endef

CMAKE_OPTIONS += \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_SHARED_LIBS=ON

TARGET_CFLAGS += \
    -D_GLIBCXX_USE_C99

define Package/leveldb/Default/description
A fast and lightweight key/value database library
endef

define Build/Compile
  $(call Build/Compile/Default)
endef

define Package/leveldb/install
  $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) DESTDIR="$(1)" install
endef

$(eval $(call BuildPackage,leveldb))

leveldb补丁patches文件

Index: leveldb-1.22/CMakeLists.txt
===================================================================
--- leveldb-1.22.orig/CMakeLists.txt
+++ leveldb-1.22/CMakeLists.txt
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. See the AUTHORS file for names of contributors.
-cmake_minimum_required(VERSION 3.9)
+cmake_minimum_required(VERSION 3.1.13)
# Keep the version below in sync with the one in db.h
project(leveldb VERSION 1.22.0 LANGUAGES C CXX)
  • 由于leveldb使用C++实现,C语言是无法直接调用的,好在leveldb已经实现了C绑定,参考源码目录下的c_test.c文件的调用API
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页