交叉编译openssh

目录


交叉编译openssh网上资料很多,整理成了一个makefile文件,其中有一步发生错误,需要手动修改一下Makefile,还不能完全自动化编译.

.PHONY:all prepare build clean

CROSS:=arm-himix200-linux

CUR_DIR:=$(shell pwd)
OPENSSH_SRC_DIR:=$(CUR_DIR)/openssh-9.7p1
OPENSSH_INSTALL_DIR:=$(CUR_DIR)/openssh_install
ZIP_LIB_SRC_DIR:=$(CUR_DIR)/zlib
ZIP_LIB_INSTALL_DIR:=$(CUR_DIR)/zip_install
OPENSSL_SRC_DIR:=$(CUR_DIR)/openssl
OPENSSL_INSTALL_DIR:=$(CUR_DIR)/openssl_install

all:prepare build

prepare:
	-@mkdir -p $(OPENSSH_INSTALL_DIR)/usr/local/bin 
	-@mkdir -p $(OPENSSH_INSTALL_DIR)/usr/local/etc
	-@mkdir -p $(OPENSSH_INSTALL_DIR)/usr/libexec
	-@mkdir -p $(ZIP_LIB_INSTALL_DIR)
	-@mkdir -p $(OPENSSL_INSTALL_DIR)
ifneq ($(ZIP_LIB_SRC_DIR), $(wildcard $(ZIP_LIB_SRC_DIR)))
	-@git clone https://gitee.com/PatchLion_admin/zlib.git
endif	
ifneq ($(OPENSSL_SRC_DIR), $(wildcard $(OPENSSL_SRC_DIR)))
	-@git clone https://gitee.com/fedorayang/openssl.git
endif		
ifneq ($(OPENSSH_SRC_DIR), $(wildcard $(OPENSSH_SRC_DIR)))
	-@wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.7p1.tar.gz
	-@pushd $(CUR_DIR);tar -zxf openssh-9.7p1.tar.gz;popd
endif	

build:
	@pushd $(ZIP_LIB_SRC_DIR);prefix=$(ZIP_LIB_INSTALL_DIR) CC=$(CROSS)-gcc ./configure;popd
	@pushd $(ZIP_LIB_SRC_DIR);make -j4;make install;popd
# #https://blog.csdn.net/weixin_46639310/article/details/132587940
	@pushd $(OPENSSL_SRC_DIR);./config no-asm --prefix=$(OPENSSL_INSTALL_DIR) --cross-compile-prefix=$(CROSS)-;popd
	@pushd $(OPENSSL_SRC_DIR);make -j4;make install;popd	
	@pushd $(OPENSSH_SRC_DIR);LD=$(CROSS)-ld CC=$(CROSS)-gcc ./configure --host=$(CROSS) --with-libs --with-zlib=$(ZIP_LIB_INSTALL_DIR) --with-ssl-dir=$(OPENSSL_INSTALL_DIR) --disable-etc-default-login;popd
	@pushd $(OPENSSH_SRC_DIR);make -j4;popd
	@pushd $(OPENSSH_SRC_DIR);cp scp sftp ssh sshd ssh-add ssh-agent ssh-keygen ssh-keyscan $(OPENSSH_INSTALL_DIR)/usr/local/bin/;popd
	@pushd $(OPENSSH_SRC_DIR);cp moduli ssh_config sshd_config $(OPENSSH_INSTALL_DIR)/usr/local/etc/;popd
	@pushd $(OPENSSH_SRC_DIR);cp sftp-server ssh-keysign $(OPENSSH_INSTALL_DIR)/usr/libexec;popd	

clean:
	-@pushd $(ZIP_LIB_SRC_DIR);make distclean;popd
	-@pushd $(OPENSSL_SRC_DIR);make distclean;popd	
	-@pushd $(OPENSSH_SRC_DIR);make distclean;popd
	-@rm -rf $(ZIP_LIB_INSTALL_DIR)
	-@rm -rf $(OPENSSL_INSTALL_DIR)	
	-@rm -rf $(OPENSSH_INSTALL_DIR)
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值