在处理 openssl的makefile的source code问题,由于不支持makefile中添加整个文件夹,需要每个 .c
文件都要一个一个添加,所以做一个简单的脚本:
#! /bin/bash
# openssl 1.1.1 source 路径
ROOT_SSL_DIR=/mnt/d/SVN/main_ssl/Thirdparty/OpenSSL/openssl
# 暂时保存所有的 .c 路径的 makefile
GEN_MAKEFILE=/mnt/d/SVN/main_ssl/Thirdparty/OpenSSL/MakeFile
func_gen_mk_file(){
local Curren_path=$1
echo $1
echo $Curren_path
echo "\n\n"
local dir=$`pwd`/
# reference : https://stackoverflow.com/questions/1186190/how-do-i-replace-a-token-with-the-result-of-pwd-in-sed
(ls $Curren_path | grep "\.c$") > $Curren_path/aTmp.txt
sed "s#^#${Curren_path//\//\\/}"/"#" $Curren_path/aTmp.txt >> $GEN_MAKEFILE
echo -e "\n" >> $GEN_MAKEFILE
rm -rf ${dir}aTmp.txt
for file_i in "${Curren_path}"/*
do
# echo ${file_i}
if [ -d "${file_i}" ] ; then
echo $file_i
func_gen_mk_file "${file_i}"
fi
done
}
# 需要处理的文件
CRYPTO=$ROOT_SSL_DIR/crypto
ENGINES=$ROOT_SSL_DIR/engines
SSL=$ROOT_SSL_DIR/ssl
rm -rf ${GEN_MAKEFILE}
func_gen_mk_file $CRYPTO
func_gen_mk_file $ENGINES
func_gen_mk_file $SSL