hi3798mv100SDK上DropBear的交叉编译
hi3798mv100SDK上DropBear的交叉编译
Dropbear是一个相对较小的SSH服务器和客户端。它运行在各种基于POSIX的平台上。Dropbear是一种开源软件,以MIT风格的许可证分发。Dropbear对于“嵌入”型Linux(或其他Unix)系统(如无线路由器)特别有用。
而在打造hi3798mv100的ramdisk时,SDK并没有包含此工具。因此需要手工添加上。
一、下载Dropbear
官方地址:https://matt.ucc.asn.au/dropbear/dropbear-2020.81.tar.bz2
下载下来的源代码,放入SDK的默认开源代码目录下:third_party/open_source/
二、添加Makefile
在source/component/添加目录dropbear目录,仿照此目录下的其他子目录,添加上相应的Makefile
#===============================================================================
# export variable
#===============================================================================
ifeq ($(CFG_HI_EXPORT_FLAG),)
SDK_DIR ?= $(shell cd $(CURDIR)/../../.. && /bin/pwd)
include $(SDK_DIR)/base.mak
endif
#===============================================================================
# local variable
#===============================================================================
DROPBEAR := dropbear-2020.81
DROPBEAR_DIR := $(HI_OUT_DIR)/obj/source/component/dropbear
INSTALL_DIR = $(DROPBEAR_DIR)/release
TARGETS := dropbear
CFLAGS += $(subst -Werror,,$(CFG_HI_CFLAGS))
#===============================================================================
# rules
#===============================================================================
.PHONY: all clean dropbear
all: $(TARGETS)
$(AT)test -d $(HI_INCLUDE_DIR) || mkdir -p $(HI_INCLUDE_DIR)
clean:
$(AT)rm -rf $(INSTALL_DIR) $(DROPBEAR_DIR)
dropbear: $(DROPBEAR_DIR)/$(DROPBEAR)/tar
$(AT)cd $(DROPBEAR_DIR)/$(DROPBEAR) && make && make install
$(DROPBEAR_DIR)/$(DROPBEAR)/tar:
$(AT)test -d $(INSTALL_DIR) || mkdir -p $(INSTALL_DIR)
$(AT)test -d $(DROPBEAR_DIR)/$(DROPBEAR) || (tar xjf $(OPEN_SOURCE_DIR)/$(DROPBEAR).tar.bz2 -C $(DROPBEAR_DIR); \
cd $(DROPBEAR_DIR)/$(DROPBEAR); \
sh ./configure CC=$(CFG_HI_ARM_TOOLCHAINS_NAME)-gcc CPP=$(CFG_HI_ARM_TOOLCHAINS_NAME)-cpp AR=$(CFG_HI_ARM_TOOLCHAINS_NAME)-ar AS=$(CFG_HI_ARM_TOOLCHAINS_NAME)-as LD=$(CFG_HI_ARM_TOOLCHAINS_NAME)-ld NM=$(CFG_HI_ARM_TOOLCHAINS_NAME)-nm STRIP=$(CFG_HI_ARM_TOOLCHAINS_NAME)-strip OBJDUMP=$(CFG_HI_ARM_TOOLCHAINS_NAME)-objdump RANLIB=$(CFG_HI_ARM_TOOLCHAINS_NAME)-ranlib CFLAGS="$(CFLAGS)" --target=$(CFG_HI_ARM_TOOLCHAINS_NAME) --host=$(CFG_HI_ARM_TOOLCHAINS_NAME) --prefix=$(INSTALL_DIR) --enable-static --with-zlib=`pwd`/../../zlib/release;)
$(AT)touch $@
dropbear默认依赖于zlib,因此需要先编译一遍zlib(进入source/component/zlib目录,然后执行make命令),然后进入source/component/dropbear,执行make命令,即可编译出来。
编译后的程序位于:out/hi3798cv200/hi3798cv2dmo/obj/source/component/dropbear/release/目录下。