Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- declare -A V
- V[zlib]=1.2.8-debian
- V[openssl]=1.0.2-20131217
- source_tree=$(readlink -e "$0" | xargs -r0 dirname)
- prebuilt_tree=${source_tree}/prebuilt
- rm -rf ${prebuilt_tree}; mkdir ${prebuilt_tree}
- TMPDIR=${source_tree}/gcc_temp
- rm -rf ${TMPDIR}; mkdir ${TMPDIR}
- heavy_task='nice -n +40 chrt -i 0 ionice -c 3'
- jobs=${JOBS:-1}
- make=$(which make)
- if [ ${jobs} -gt 1 ]; then
- make="${heavy_task} ${make} -j ${jobs}"
- fi
- Binit() {
- [ -z "${source_tree}" ] && return 1
- [ -z "${name}" ] && return 1
- [ -z "${version}" ] && version=${V[${name}]}
- [ -z "${version}" ] && return 1
- cd ${source_tree}/${name}
- [ -e ${version}.tar.xz ] || return 1
- file -i ${version}.tar.xz | cut -d: -f2 | fgrep -qe application/x-xz || return 1
- ${heavy_task} find ./ -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} +
- ${heavy_task} xz -dvv < ${version}.tar.xz | ${heavy_task} tar xf -
- prebuilt=${prebuilt_tree}/${name}/${version}
- mkdir -p ${prebuilt}/{,/lib,/include}
- cd ${version}/
- ln -s ${source_tree} source_tree
- ln -s ${prebuilt_tree} prebuilt_tree
- }
- Bcleanup() {
- gcc_cleanup
- [ -z "${source_tree}" ] && return
- [ -z "${name}" ] && return
- [ -z "${version}" ] && return
- cd ${source_tree}/
- ${heavy_task} rm -rf ${source_tree}/${name}/${version}/
- unset name version
- }
- # Source Tree path
- # ST {A|R} <name>
- ST() {
- local base=
- case "$1" in
- [Aa]) base=${source_tree} ;; # absolute path
- [Rr]) base=source_tree ;; # relative path
- *) return 1 ;;
- esac
- [ -z "$2" ] && return 1
- local name=$2
- local version=${V[${name}]}
- [ -z "${version}" ] && return 1
- echo ${base}/${name}/${version}
- }
- # Prebuild Tree path
- # PT {A|R} <name> [path]
- PT() {
- local base=
- case "$1" in
- [Aa]) base=${prebuilt_tree} ;; # absolute path
- [Rr]) base=prebuilt_tree ;; # relative path
- *) return 1 ;;
- esac
- [ -z "$2" ] && return 1
- local name=$2
- local version=${V[${name}]}
- [ -z "${version}" ] && return 1
- local path=${3:+'/'}$3
- echo ${base}/${name}/${version}${path}
- }
- gcc_cleanup() { ${heavy_task} find ${TMPDIR}/ -mindepth 1 -maxdepth 1 -name 'cc*' -delete; }
- ### zlib
- name=zlib
- Binit && {
- cp contrib/amd64/amd64-match.S match.S
- CFLAGS=-DASMV ./configure
- gcc_cleanup
- ${make} OBJA=match.o libz.a
- cp -Lp *.a ${prebuilt}/lib
- cp -Lp *.h ${prebuilt}/include
- }
- Bcleanup
- ### openssl
- name=openssl
- Binit && {
- ./config --prefix=$(PT R ${name}) zlib --with-zlib-lib=$(PT A zlib lib) --with-zlib-include=$(PT A zlib include)
- cp -LpR include/openssl/ ${prebuilt}/include/
- gcc_cleanup
- ${make} depend
- ${make} build_libs
- cp -Lp *.a ${prebuilt}/lib/
- }
- Bcleanup
- # krd@amethyst:/tmp/gentoo$ find -mindepth 1 -maxdepth 2 -exec ls -lhdG {} + | sed -e 's# ./# #'
- # drwxr-xr-x 2 krd 40 Dec 17 17:30 gcc_temp
- # -rw-r--r-- 1 krd 2.5K Dec 17 17:30 gentoo.sh
- # drwxr-xr-x 2 krd 60 Dec 17 17:32 openssl
- # -rw-r--r-- 1 krd 3.0M Dec 17 16:39 openssl/1.0.2-20131217.tar.xz
- # drwxr-xr-x 4 krd 80 Dec 17 17:30 prebuilt
- # drwxr-xr-x 3 krd 60 Dec 17 17:30 prebuilt/openssl
- # drwxr-xr-x 3 krd 60 Dec 17 17:30 prebuilt/zlib
- # drwxr-xr-x 2 krd 60 Dec 17 17:30 zlib
- # -rw-r--r-- 1 krd 330K Dec 17 14:45 zlib/1.2.8-debian.tar.xz
- #
- # krd@amethyst:/tmp/gentoo$ find prebuilt/ -exec ls -lhdG {} +
- # drwxr-xr-x 4 krd 80 Dec 17 17:30 prebuilt/
- # drwxr-xr-x 3 krd 60 Dec 17 17:30 prebuilt/openssl
- # drwxr-xr-x 4 krd 80 Dec 17 17:30 prebuilt/openssl/1.0.2-20131217
- # drwxr-xr-x 3 krd 60 Dec 17 17:30 prebuilt/openssl/1.0.2-20131217/include
- # drwxr-xr-x 2 krd 1.6K Dec 17 17:30 prebuilt/openssl/1.0.2-20131217/include/openssl
- # -rw-r--r-- 1 krd 5.4K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/aes.h
- # -rw-r--r-- 1 krd 52K Oct 1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/asn1.h
- # -rw-r--r-- 1 krd 19K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/asn1_mac.h
- # -rw-r--r-- 1 krd 30K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/asn1t.h
- # -rw-r--r-- 1 krd 33K Oct 7 16:00 prebuilt/openssl/1.0.2-20131217/include/openssl/bio.h
- # -rw-r--r-- 1 krd 5.1K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/blowfish.h
- # -rw-r--r-- 1 krd 35K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/bn.h
- # -rw-r--r-- 1 krd 4.6K Oct 1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/buffer.h
- # -rw-r--r-- 1 krd 4.9K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/camellia.h
- # -rw-r--r-- 1 krd 4.4K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/cast.h
- # -rw-r--r-- 1 krd 3.2K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/cmac.h
- # -rw-r--r-- 1 krd 22K Nov 9 20:00 prebuilt/openssl/1.0.2-20131217/include/openssl/cms.h
- # -rw-r--r-- 1 krd 2.0K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/comp.h
- # -rw-r--r-- 1 krd 9.7K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/conf.h
- # -rw-r--r-- 1 krd 4.0K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/conf_api.h
- # -rw-r--r-- 1 krd 24K Feb 6 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/crypto.h
- # -rw-r--r-- 1 krd 11K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/des.h
- # -rw-r--r-- 1 krd 18K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/des_old.h
- # -rw-r--r-- 1 krd 14K Oct 1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/dh.h
- # -rw-r--r-- 1 krd 12K Oct 1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/dsa.h
- # -rw-r--r-- 1 krd 18K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/dso.h
- # -rw-r--r-- 1 krd 8.0K Sep 18 21:00 prebuilt/openssl/1.0.2-20131217/include/openssl/dtls1.h
- # -rw-r--r-- 1 krd 11K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/e_os2.h
- # -rw-r--r-- 1 krd 540 Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ebcdic.h
- # -rw-r--r-- 1 krd 49K Oct 1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ec.h
- # -rw-r--r-- 1 krd 4.8K Oct 1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ecdh.h
- # -rw-r--r-- 1 krd 13K Sep 18 21:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ecdsa.h
- # -rw-r--r-- 1 krd 40K Dec 2 04:00 prebuilt/openssl/1.0.2-20131217/include/openssl/engine.h
- # -rw-r--r-- 1 krd 16K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/err.h
- # -rw-r--r-- 1 krd 53K Nov 15 02:00 prebuilt/openssl/1.0.2-20131217/include/openssl/evp.h
- # -rw-r--r-- 1 krd 4.4K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/hmac.h
- # -rw-r--r-- 1 krd 4.4K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/idea.h
- # -rw-r--r-- 1 krd 7.5K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/krb5_asn.h
- # -rw-r--r-- 1 krd 6.0K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/kssl.h
- # -rw-r--r-- 1 krd 8.9K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/lhash.h
- # -rw-r--r-- 1 krd 4.6K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/md4.h
- # -rw-r--r-- 1 krd 4.6K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/md5.h
- # -rw-r--r-- 1 krd 3.9K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/mdc2.h
- # -rw-r--r-- 1 krd 5.8K Oct 1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/modes.h
- # -rw-r--r-- 1 krd 138K Oct 1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/obj_mac.h
- # -rw-r--r-- 1 krd 36K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/objects.h
- # -rw-r--r-- 1 krd 25K Oct 7 16:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ocsp.h
- # -rw-r--r-- 1 krd 6.8K Dec 17 17:30 prebuilt/openssl/1.0.2-20131217/include/openssl/opensslconf.h
- # -rw-r--r-- 1 krd 3.7K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/opensslv.h
- # -rw-r--r-- 1 krd 7.3K Oct 1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ossl_typ.h
- # -rw-r--r-- 1 krd 22K Sep 10 21:00 prebuilt/openssl/1.0.2-20131217/include/openssl/pem.h
- # -rw-r--r-- 1 krd 2.8K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/pem2.h
- # -rw-r--r-- 1 krd 13K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/pkcs12.h
- # -rw-r--r-- 1 krd 18K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/pkcs7.h
- # -rw-r--r-- 1 krd 3.5K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/pqueue.h
- # -rw-r--r-- 1 krd 5.5K Sep 22 22:00 prebuilt/openssl/1.0.2-20131217/include/openssl/rand.h
- # -rw-r--r-- 1 krd 4.4K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/rc2.h
- # -rw-r--r-- 1 krd 3.8K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/rc4.h
- # -rw-r--r-- 1 krd 4.3K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ripemd.h
- # -rw-r--r-- 1 krd 25K Oct 1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/rsa.h
- # -rw-r--r-- 1 krd 182K Oct 1 18:00 prebuilt/openssl/1.0.2-20131217/include/openssl/safestack.h
- # -rw-r--r-- 1 krd 5.6K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/seed.h
- # -rw-r--r-- 1 krd 7.5K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/sha.h
- # -rw-r--r-- 1 krd 5.3K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/srp.h
- # -rw-r--r-- 1 krd 6.5K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/srtp.h
- # -rw-r--r-- 1 krd 120K Dec 13 21:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ssl.h
- # -rw-r--r-- 1 krd 11K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ssl2.h
- # -rw-r--r-- 1 krd 3.7K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ssl23.h
- # -rw-r--r-- 1 krd 29K Oct 6 01:00 prebuilt/openssl/1.0.2-20131217/include/openssl/ssl3.h
- # -rw-r--r-- 1 krd 4.4K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/stack.h
- # -rw-r--r-- 1 krd 24K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/symhacks.h
- # -rw-r--r-- 1 krd 36K Oct 6 01:00 prebuilt/openssl/1.0.2-20131217/include/openssl/tls1.h
- # -rw-r--r-- 1 krd 31K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ts.h
- # -rw-r--r-- 1 krd 4.4K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/txt_db.h
- # -rw-r--r-- 1 krd 17K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ui.h
- # -rw-r--r-- 1 krd 3.4K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/ui_compat.h
- # -rw-r--r-- 1 krd 1019 Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/whrlpool.h
- # -rw-r--r-- 1 krd 45K Jan 17 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/x509.h
- # -rw-r--r-- 1 krd 24K Dec 13 21:00 prebuilt/openssl/1.0.2-20131217/include/openssl/x509_vfy.h
- # -rw-r--r-- 1 krd 33K Jan 11 2013 prebuilt/openssl/1.0.2-20131217/include/openssl/x509v3.h
- # drwxr-xr-x 2 krd 80 Dec 17 17:32 prebuilt/openssl/1.0.2-20131217/lib
- # -rw-r--r-- 1 krd 15M Dec 17 17:32 prebuilt/openssl/1.0.2-20131217/lib/libcrypto.a
- # -rw-r--r-- 1 krd 3.4M Dec 17 17:31 prebuilt/openssl/1.0.2-20131217/lib/libssl.a
- # drwxr-xr-x 3 krd 60 Dec 17 17:30 prebuilt/zlib
- # drwxr-xr-x 4 krd 80 Dec 17 17:30 prebuilt/zlib/1.2.8-debian
- # drwxr-xr-x 2 krd 260 Dec 17 17:30 prebuilt/zlib/1.2.8-debian/include
- # -rw-r--r-- 1 krd 30K Apr 30 2012 prebuilt/zlib/1.2.8-debian/include/crc32.h
- # -rw-r--r-- 1 krd 13K Jun 2 2012 prebuilt/zlib/1.2.8-debian/include/deflate.h
- # -rw-r--r-- 1 krd 6.4K Apr 14 2013 prebuilt/zlib/1.2.8-debian/include/gzguts.h
- # -rw-r--r-- 1 krd 427 Apr 19 2010 prebuilt/zlib/1.2.8-debian/include/inffast.h
- # -rw-r--r-- 1 krd 6.2K Oct 6 2011 prebuilt/zlib/1.2.8-debian/include/inffixed.h
- # -rw-r--r-- 1 krd 6.3K Dec 26 2009 prebuilt/zlib/1.2.8-debian/include/inflate.h
- # -rw-r--r-- 1 krd 2.9K Apr 19 2010 prebuilt/zlib/1.2.8-debian/include/inftrees.h
- # -rw-r--r-- 1 krd 8.3K Apr 18 2010 prebuilt/zlib/1.2.8-debian/include/trees.h
- # -rw-r--r-- 1 krd 16K Dec 17 17:30 prebuilt/zlib/1.2.8-debian/include/zconf.h
- # -rw-r--r-- 1 krd 86K Apr 29 2013 prebuilt/zlib/1.2.8-debian/include/zlib.h
- # -rw-r--r-- 1 krd 6.7K Mar 25 2013 prebuilt/zlib/1.2.8-debian/include/zutil.h
- # drwxr-xr-x 2 krd 60 Dec 17 17:30 prebuilt/zlib/1.2.8-debian/lib
- # -rw-r--r-- 1 krd 472K Dec 17 17:30 prebuilt/zlib/1.2.8-debian/lib/libz.a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement