Download :
 - openssl1.1.1k.tar.gz from https://www.openssl.org/source/openssl-1.1.1k.tar.gz or ftp://ftp.openssl.org/source/openssl-1.1.1k.tar.gz
 - libssh2 1.9.0 from https://www.libssh2.org/download/libssh2-1.9.0.tar.gz
 - curl 7.77.0 from https://curl.se/download/curl-7.77.0.tar.gz
 - zlib 1.2.11 from https://zlib.net/zlib-1.2.11.tar.gz
Store all the files in /tmp

Compilation machines: only compiled on linux 32bit for now
 - for linux 32, works on esekilxxen1231.rnd.ericsson.se (32-bit machine with old linux version 2.6.16 and old libc 2.4) with module add gcc/3.4.6 -> use old glibc to avoid problems when running on a old linux machine 
 - for linux 64, works on ottlsvr18 (libc 2.11.3) or seliiuts02929 or sekilx484.wrbs.rnd.ki.sw.ericsson.se or sekilx1260.wrbs.rnd.ki.sw.ericsson.se

module add gcc/10.2.0
module add make/4.3

cd /tmp
tar -xf /tmp/zlib-1.2.11.tar.gz
cd /tmp/zlib-1.2.11/
env CFLAGS="-g -O2 -fPIC" LDSHARED="gcc " ./configure && make

cd /tmp
tar -xf openssl-1.1.1k.tar.gz 
cd /tmp/openssl-1.1.1k
cp ~/moshell/commonjars/src/openssh/patches/0001-Moshell-SSL-mods-1.1.1k.patch .
patch -p1 -i 0001-Moshell-SSL-mods-1.1.1k.patch
./config -fPIC shared && make depend && make

cd /tmp
tar -xf /tmp/libssh2-1.9.0.tar.gz
cd /tmp/libssh2-1.9.0/
env CFLAGS=" -I/tmp/openssl-1.1.1k/include" LIBS="-ldl" LDFLAGS="-L/tmp/openssl-1.1.1k -L/tmp/zlib-1.2.11" ./configure --with-openssl --enable-shared=no --with-libssl-prefix=/tmp/openssl-1.1.1k --with-libgcrypt-prefix=/tmp/openssl-1.1.1k && make

cd /tmp
rm /tmp/openssl-1.1.1k/libcrypto.so* /tmp/openssl-1.1.1k/libssl.so*
tar -xf curl-7.77.0.tar.gz
cd /tmp/curl-7.77.0/
env CFLAGS="" LIBS="-ldl" LDFLAGS="-L/tmp/openssl-1.1.1k -L/tmp/libssh2-1.9.0/src/.libs -L/tmp/zlib-1.2.11/ -static" ./configure --disable-debug --disable-curldebug --disable-ldap --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-libcurl-option --enable-ipv6 --disable-sspi --disable-ntlm-wb --with-ssl=/tmp/openssl-1.1.1k --with-libssh2=/tmp/libssh2-1.9.0 && make


#script: run with bash -v

set -e
module add perl/5.10.1
cd /tmp
cp /home/eanzmagn/openssl-1.1.1k.tar.gz  /home/eanzmagn/zlib-1.2.11.tar.gz /home/eanzmagn/libssh2-1.9.0.zip /home/eanzmagn/curl-7.77.0.zip .
rm -rf openssl-1.1.1k zlib-1.2.11 libssh2-1.9.0 curl-7.77.0
tar xf openssl-1.1.1k.tar.gz
tar xf zlib-1.2.11.tar.gz
unzip libssh2-1.9.0.zip
unzip curl-7.77.0.zip
cd /tmp/zlib-1.2.11
chmod 755 configure
env CFLAGS="-g -O2 -fPIC" LDSHARED="gcc " ./configure && make
cp /home/eanzmagn/moshell/commonjars/src/openssh/patches/0001-Moshell-SSL-mods-1.1.1k.patch /tmp/openssl-1.1.1k
cd /tmp/openssl-1.1.1k
patch -p1 -i 0001-Moshell-SSL-mods-1.1.1k.patch
./config -fPIC no-shared no-threads && make
cd /tmp/libssh2-1.9.0
chmod 755 configure
env CFLAGS=" -I/tmp/openssl-1.1.1k/include" LIBS="-ldl" LDFLAGS="-L/tmp/openssl-1.1.1k -L/tmp/zlib-1.2.11" ./configure --with-openssl --enable-shared=no --with-libssl-prefix=/tmp/openssl-1.1.1k --with-libgcrypt-prefix=/tmp/openssl-1.1.1k && make
cd /tmp/curl-7.77.0
chmod 755 configure
env CFLAGS="" LIBS="-ldl" LDFLAGS="-L/tmp/openssl-1.1.1k -L/tmp/libssh2-1.9.0/src/.libs -L/tmp/zlib-1.2.11/ -static" ./configure --disable-debug --disable-curldebug --disable-ldap --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-libcurl-option --enable-ipv6 --disable-sspi --disable-ntlm-wb --with-ssl=/tmp/openssl-1.1.1k --with-libssh2=/tmp/libssh2-1.9.0 && make
 
