Download :
 - openssl1.1.1c.tar.gz from https://www.openssl.org/source/openssl-1.1.1c.tar.gz or ftp://ftp.openssl.org/source/openssl-1.1.1c.tar.gz
 - libssh2 1.8.0 from https://www.libssh2.org/download/libssh2-1.8.0.tar.gz
 - curl 7.65.1 from https://curl.haxx.se/download/curl-7.65.1.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 esekilxxen1250.rnd.ericsson.se (64-bit machine with old linux version 2.6.16 and old libc 2.4) -> skip the option -m32  in CFLAGS !!

module add perl/5.10.1

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

setenv CC gcc

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

Build libssh2
tar -xzf /tmp/19012-11_CAX1053568_X_A_UNIX_TAR_COMPRESS.tar.Z
cd /tmp/libssh2-1.8.0/
env CFLAGS=" -I/tmp/openssl-1.1.1c/include" LIBS="-ldl" LDFLAGS="-L/tmp/openssl-1.1.1c -L/tmp/zlib-1.2.3" ./configure --with-openssl --enable-shared=no --with-libssl-prefix=/tmp/openssl-1.1.1c --with-libgcrypt-prefix=/tmp/openssl-1.1.1c && make

cd /tmp
unzip 19012-37_CAX1053172_X_A_PKZIPV2R04.zip
tar -xf curl-7.65.1.tar.bz2
cd /tmp/curl-7.65.1/
env CFLAGS="" LIBS="-ldl" LDFLAGS="-L/tmp/openssl-1.1.1c -L/tmp/libssh2-1.8.0/src/.libs -L/tmp/zlib-1.2.3/ -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.1c --with-libssh2=/tmp/libssh2-1.8.0 && make


#script: run with bash -v

set -e
module add perl/5.10.1
cd /tmp
cp /home/eanzmagn/openssl-1.1.1c.tar.gz  /home/eanzmagn/zlib-1.2.3.tar.gz /home/eanzmagn/libssh2-1.8.0.zip /home/eanzmagn/curl-7.65.1.zip .
rm -rf openssl-1.1.1c zlib-1.2.3 libssh2-1.8.0 curl-7.65.1
tar xf openssl-1.1.1c.tar.gz
tar xf zlib-1.2.3.tar.gz
unzip libssh2-1.8.0.zip
unzip curl-7.65.1.zip
cd /tmp/zlib-1.2.3
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.1c.patch /tmp/openssl-1.1.1c
cd /tmp/openssl-1.1.1c
patch -p1 -i 0001-Moshell-SSL-mods-1.1.1c.patch
./config -fPIC no-shared no-threads && make
cd /tmp/libssh2-1.8.0
chmod 755 configure
env CFLAGS=" -I/tmp/openssl-1.1.1c/include" LIBS="-ldl" LDFLAGS="-L/tmp/openssl-1.1.1c -L/tmp/zlib-1.2.3" ./configure --with-openssl --enable-shared=no --with-libssl-prefix=/tmp/openssl-1.1.1c --with-libgcrypt-prefix=/tmp/openssl-1.1.1c && make
cd /tmp/curl-7.65.1
chmod 755 configure
env CFLAGS="" LIBS="-ldl" LDFLAGS="-L/tmp/openssl-1.1.1c -L/tmp/libssh2-1.8.0/src/.libs -L/tmp/zlib-1.2.3/ -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.1c --with-libssh2=/tmp/libssh2-1.8.0 && make
 
