环境:
Linux平台:Centos Linux release 7.6.1810 (Core)、gcc 4.8.5
开始:
一、下载源码
1. openssl-OpenSSL_0_9_8g.tar.gz 解压得到openssl-OpenSSL_0_9_8g目录
查看openssl版本:opensslv.h #define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8g 19 Oct 2007"
二、编译脚本
build_openssl.sh
#!/usr/bin/sh #resolve error: 'out range of signed 32bit displacement' #use option no-asm if [ $# -lt 2 ]; then echo "usage:" echo " ./build_openssl.sh make [source_dir]" echo " ./build_openssl.sh install [source_dir] [output_dir]" echo " ./build_openssl.sh clean [source_dir]" echo "example:" echo " build_openssl.sh make openssl-OpenSSL_0_9_8g" echo " build_openssl.sh install openssl-OpenSSL_0_9_8g openssl-0.9.8" echo " build_openssl.sh clean openssl-OpenSSL_0_9_8g" exit 0 fi if [[ "$1" == "make" ]]; then if [ $# -ne 2 ]; then echo "usage:" echo " ./build.sh make [source_dir]" exit 0 fi cd $2 ./config no-asm no-shared -fPIC make make test elif [[ "$1" == "install" ]]; then if [ $# -ne 3 ]; then echo "usage:" echo " ./build.sh install [source_dir] [output_dir]" exit 0 fi source_dir=$2 output_dir=$3 #output_dir if [ ! -d $output_dir ];then mkdir $output_dir fi #output_dir/include if [ ! -d $output_dir/include ];then mkdir $output_dir/include fi #output_dir/include/openssl if [ ! -d $output_dir/include/openssl ];then mkdir $output_dir/include/openssl fi #output_dir/lib if [ ! -d $output_dir/lib ];then mkdir $output_dir/lib fi #copy include file to output_dir cp -f $source_dir/include/openssl/*.h $output_dir/include/openssl #copy library file to output_dir cp -f $source_dir/*.a $output_dir/lib mv -f $output_dir/include/openssl/opensslconf.h $output_dir/include/openssl/opensslconf_unix.h echo '#if WIN32' > $output_dir/include/openssl/opensslconf.h echo ' #include "openssl/opensslconf_windows.h"' >> $output_dir/include/openssl/opensslconf.h echo '#else' >> $output_dir/include/openssl/opensslconf.h echo ' #include "openssl/opensslconf_unix.h"' >> $output_dir/include/openssl/opensslconf.h echo '#endif' >> $output_dir/include/openssl/opensslconf.h elif [[ "$1" == "clean" ]]; then if [ $# -ne 2 ]; then echo "usage:" echo " ./build.sh build [source_dir]" exit 0 fi cd $2 make clean fi
三、编译
usage: ./build_openssl.sh make [source_dir] ./build_openssl.sh install [source_dir] [output_dir] ./build_openssl.sh clean [source_dir] example: build_openssl.sh make openssl-OpenSSL_0_9_8g build_openssl.sh install openssl-OpenSSL_0_9_8g openssl-0.9.8 build_openssl.sh clean openssl-OpenSSL_0_9_8g
标签:OpenSSL.0,openssl,echo,9.8,build,Linux,output,include,dir From: https://www.cnblogs.com/dongc/p/16634418.html