cygwin.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #!/bin/bash
  2. #
  3. # This script configures, builds and packs the binary package for
  4. # the Cygwin net distribution version of OpenSSL
  5. #
  6. # Uncomment when debugging
  7. #set -x
  8. CONFIG_OPTIONS="--prefix=/usr shared zlib no-idea no-rc5"
  9. INSTALL_PREFIX=/tmp/install/INSTALL
  10. VERSION=
  11. SHLIB_VERSION_NUMBER=
  12. SUBVERSION=$1
  13. function cleanup()
  14. {
  15. rm -rf ${INSTALL_PREFIX}/etc
  16. rm -rf ${INSTALL_PREFIX}/usr
  17. }
  18. function get_openssl_version()
  19. {
  20. eval `grep '^VERSION=' Makefile`
  21. if [ -z "${VERSION}" ]
  22. then
  23. echo "Error: Couldn't retrieve OpenSSL version from Makefile."
  24. echo " Check value of variable VERSION in Makefile."
  25. exit 1
  26. fi
  27. eval `grep '^SHLIB_VERSION_NUMBER=' Makefile`
  28. if [ -z "${SHLIB_VERSION_NUMBER}" ]
  29. then
  30. echo "Error: Couldn't retrieve OpenSSL shared lib version from Makefile."
  31. echo " Check value of variable SHLIB_VERSION_NUMBER in Makefile."
  32. exit 1
  33. fi
  34. }
  35. function base_install()
  36. {
  37. mkdir -p ${INSTALL_PREFIX}
  38. cleanup
  39. make install INSTALL_PREFIX="${INSTALL_PREFIX}"
  40. }
  41. function doc_install()
  42. {
  43. DOC_DIR=${INSTALL_PREFIX}/usr/share/doc/openssl
  44. mkdir -p ${DOC_DIR}
  45. cp CHANGES CHANGES.SSLeay INSTALL LICENSE NEWS README ${DOC_DIR}
  46. create_cygwin_readme
  47. }
  48. function certs_install()
  49. {
  50. CERTS_DIR=${INSTALL_PREFIX}/usr/ssl/certs
  51. mkdir -p ${CERTS_DIR}
  52. cp -rp certs/* ${CERTS_DIR}
  53. }
  54. function create_cygwin_readme()
  55. {
  56. README_DIR=${INSTALL_PREFIX}/usr/share/doc/Cygwin
  57. README_FILE=${README_DIR}/openssl-${VERSION}.README
  58. mkdir -p ${README_DIR}
  59. cat > ${README_FILE} <<- EOF
  60. The Cygwin version has been built using the following configure:
  61. ./config ${CONFIG_OPTIONS}
  62. The IDEA and RC5 algorithms are disabled due to patent and/or
  63. licensing issues.
  64. EOF
  65. }
  66. function create_profile_files()
  67. {
  68. PROFILE_DIR=${INSTALL_PREFIX}/etc/profile.d
  69. mkdir -p $PROFILE_DIR
  70. cat > ${PROFILE_DIR}/openssl.sh <<- "EOF"
  71. export MANPATH="${MANPATH}:/usr/ssl/man"
  72. EOF
  73. cat > ${PROFILE_DIR}/openssl.csh <<- "EOF"
  74. if ( $?MANPATH ) then
  75. setenv MANPATH "${MANPATH}:/usr/ssl/man"
  76. else
  77. setenv MANPATH ":/usr/ssl/man"
  78. endif
  79. EOF
  80. }
  81. if [ -z "${SUBVERSION}" ]
  82. then
  83. echo "Usage: $0 subversion"
  84. exit 1
  85. fi
  86. if [ ! -f config ]
  87. then
  88. echo "You must start this script in the OpenSSL toplevel source dir."
  89. exit 1
  90. fi
  91. ./config ${CONFIG_OPTIONS}
  92. get_openssl_version
  93. make depend || exit 1
  94. make || exit 1
  95. base_install
  96. doc_install
  97. certs_install
  98. create_cygwin_readme
  99. create_profile_files
  100. cd ${INSTALL_PREFIX}
  101. chmod u+w usr/lib/engines/*.so
  102. strip usr/bin/*.exe usr/bin/*.dll usr/lib/engines/*.so
  103. chmod u-w usr/lib/engines/*.so
  104. # Runtime package
  105. tar cjf libopenssl${SHLIB_VERSION_NUMBER//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2 \
  106. usr/bin/cyg*dll
  107. # Base package
  108. find etc usr/bin/openssl.exe usr/bin/c_rehash usr/lib/engines usr/share/doc \
  109. usr/ssl/certs usr/ssl/man/man[157] usr/ssl/misc usr/ssl/openssl.cnf \
  110. usr/ssl/private \
  111. -empty -o \! -type d |
  112. tar cjfT openssl-${VERSION}-${SUBVERSION}.tar.bz2 -
  113. # Development package
  114. find usr/include usr/lib/*.a usr/lib/pkgconfig usr/ssl/man/man3 \
  115. -empty -o \! -type d |
  116. tar cjfT openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2 -
  117. ls -l openssl-${VERSION}-${SUBVERSION}.tar.bz2
  118. ls -l openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2
  119. ls -l libopenssl${SHLIB_VERSION_NUMBER//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2
  120. cleanup
  121. exit 0