xref: /minix3/crypto/external/bsd/openssl/dist/util/cygwin.sh (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc#!/bin/bash
2*ebfedea0SLionel Sambuc#
3*ebfedea0SLionel Sambuc# This script configures, builds and packs the binary package for
4*ebfedea0SLionel Sambuc# the Cygwin net distribution version of OpenSSL
5*ebfedea0SLionel Sambuc#
6*ebfedea0SLionel Sambuc
7*ebfedea0SLionel Sambuc# Uncomment when debugging
8*ebfedea0SLionel Sambuc#set -x
9*ebfedea0SLionel Sambuc
10*ebfedea0SLionel SambucCONFIG_OPTIONS="--prefix=/usr shared zlib no-idea no-rc5"
11*ebfedea0SLionel SambucINSTALL_PREFIX=/tmp/install/INSTALL
12*ebfedea0SLionel Sambuc
13*ebfedea0SLionel SambucVERSION=
14*ebfedea0SLionel SambucSHLIB_VERSION_NUMBER=
15*ebfedea0SLionel SambucSUBVERSION=$1
16*ebfedea0SLionel Sambuc
17*ebfedea0SLionel Sambucfunction cleanup()
18*ebfedea0SLionel Sambuc{
19*ebfedea0SLionel Sambuc  rm -rf ${INSTALL_PREFIX}/etc
20*ebfedea0SLionel Sambuc  rm -rf ${INSTALL_PREFIX}/usr
21*ebfedea0SLionel Sambuc}
22*ebfedea0SLionel Sambuc
23*ebfedea0SLionel Sambucfunction get_openssl_version()
24*ebfedea0SLionel Sambuc{
25*ebfedea0SLionel Sambuc  eval `grep '^VERSION=' Makefile`
26*ebfedea0SLionel Sambuc  if [ -z "${VERSION}" ]
27*ebfedea0SLionel Sambuc  then
28*ebfedea0SLionel Sambuc    echo "Error: Couldn't retrieve OpenSSL version from Makefile."
29*ebfedea0SLionel Sambuc    echo "       Check value of variable VERSION in Makefile."
30*ebfedea0SLionel Sambuc    exit 1
31*ebfedea0SLionel Sambuc  fi
32*ebfedea0SLionel Sambuc  eval `grep '^SHLIB_VERSION_NUMBER=' Makefile`
33*ebfedea0SLionel Sambuc  if [ -z "${SHLIB_VERSION_NUMBER}" ]
34*ebfedea0SLionel Sambuc  then
35*ebfedea0SLionel Sambuc    echo "Error: Couldn't retrieve OpenSSL shared lib version from Makefile."
36*ebfedea0SLionel Sambuc    echo " Check value of variable SHLIB_VERSION_NUMBER in Makefile."
37*ebfedea0SLionel Sambuc    exit 1
38*ebfedea0SLionel Sambuc  fi
39*ebfedea0SLionel Sambuc}
40*ebfedea0SLionel Sambuc
41*ebfedea0SLionel Sambucfunction base_install()
42*ebfedea0SLionel Sambuc{
43*ebfedea0SLionel Sambuc  mkdir -p ${INSTALL_PREFIX}
44*ebfedea0SLionel Sambuc  cleanup
45*ebfedea0SLionel Sambuc  make install INSTALL_PREFIX="${INSTALL_PREFIX}"
46*ebfedea0SLionel Sambuc}
47*ebfedea0SLionel Sambuc
48*ebfedea0SLionel Sambucfunction doc_install()
49*ebfedea0SLionel Sambuc{
50*ebfedea0SLionel Sambuc  DOC_DIR=${INSTALL_PREFIX}/usr/share/doc/openssl
51*ebfedea0SLionel Sambuc
52*ebfedea0SLionel Sambuc  mkdir -p ${DOC_DIR}
53*ebfedea0SLionel Sambuc  cp CHANGES CHANGES.SSLeay INSTALL LICENSE NEWS README ${DOC_DIR}
54*ebfedea0SLionel Sambuc
55*ebfedea0SLionel Sambuc  create_cygwin_readme
56*ebfedea0SLionel Sambuc}
57*ebfedea0SLionel Sambuc
58*ebfedea0SLionel Sambucfunction certs_install()
59*ebfedea0SLionel Sambuc{
60*ebfedea0SLionel Sambuc  CERTS_DIR=${INSTALL_PREFIX}/usr/ssl/certs
61*ebfedea0SLionel Sambuc
62*ebfedea0SLionel Sambuc  mkdir -p ${CERTS_DIR}
63*ebfedea0SLionel Sambuc  cp -rp certs/* ${CERTS_DIR}
64*ebfedea0SLionel Sambuc}
65*ebfedea0SLionel Sambuc
66*ebfedea0SLionel Sambucfunction create_cygwin_readme()
67*ebfedea0SLionel Sambuc{
68*ebfedea0SLionel Sambuc  README_DIR=${INSTALL_PREFIX}/usr/share/doc/Cygwin
69*ebfedea0SLionel Sambuc  README_FILE=${README_DIR}/openssl-${VERSION}.README
70*ebfedea0SLionel Sambuc
71*ebfedea0SLionel Sambuc  mkdir -p ${README_DIR}
72*ebfedea0SLionel Sambuc  cat > ${README_FILE} <<- EOF
73*ebfedea0SLionel Sambuc	The Cygwin version has been built using the following configure:
74*ebfedea0SLionel Sambuc
75*ebfedea0SLionel Sambuc	  ./config ${CONFIG_OPTIONS}
76*ebfedea0SLionel Sambuc
77*ebfedea0SLionel Sambuc	The IDEA and RC5 algorithms are disabled due to patent and/or
78*ebfedea0SLionel Sambuc	licensing issues.
79*ebfedea0SLionel Sambuc	EOF
80*ebfedea0SLionel Sambuc}
81*ebfedea0SLionel Sambuc
82*ebfedea0SLionel Sambucfunction create_profile_files()
83*ebfedea0SLionel Sambuc{
84*ebfedea0SLionel Sambuc  PROFILE_DIR=${INSTALL_PREFIX}/etc/profile.d
85*ebfedea0SLionel Sambuc
86*ebfedea0SLionel Sambuc  mkdir -p $PROFILE_DIR
87*ebfedea0SLionel Sambuc  cat > ${PROFILE_DIR}/openssl.sh <<- "EOF"
88*ebfedea0SLionel Sambuc	export MANPATH="${MANPATH}:/usr/ssl/man"
89*ebfedea0SLionel Sambuc	EOF
90*ebfedea0SLionel Sambuc  cat > ${PROFILE_DIR}/openssl.csh <<- "EOF"
91*ebfedea0SLionel Sambuc	if ( $?MANPATH ) then
92*ebfedea0SLionel Sambuc	  setenv MANPATH "${MANPATH}:/usr/ssl/man"
93*ebfedea0SLionel Sambuc	else
94*ebfedea0SLionel Sambuc	  setenv MANPATH ":/usr/ssl/man"
95*ebfedea0SLionel Sambuc	endif
96*ebfedea0SLionel Sambuc	EOF
97*ebfedea0SLionel Sambuc}
98*ebfedea0SLionel Sambuc
99*ebfedea0SLionel Sambucif [ -z "${SUBVERSION}" ]
100*ebfedea0SLionel Sambucthen
101*ebfedea0SLionel Sambuc  echo "Usage: $0 subversion"
102*ebfedea0SLionel Sambuc  exit 1
103*ebfedea0SLionel Sambucfi
104*ebfedea0SLionel Sambuc
105*ebfedea0SLionel Sambucif [ ! -f config ]
106*ebfedea0SLionel Sambucthen
107*ebfedea0SLionel Sambuc  echo "You must start this script in the OpenSSL toplevel source dir."
108*ebfedea0SLionel Sambuc  exit 1
109*ebfedea0SLionel Sambucfi
110*ebfedea0SLionel Sambuc
111*ebfedea0SLionel Sambuc./config ${CONFIG_OPTIONS}
112*ebfedea0SLionel Sambuc
113*ebfedea0SLionel Sambucget_openssl_version
114*ebfedea0SLionel Sambuc
115*ebfedea0SLionel Sambucmake depend || exit 1
116*ebfedea0SLionel Sambuc
117*ebfedea0SLionel Sambucmake || exit 1
118*ebfedea0SLionel Sambuc
119*ebfedea0SLionel Sambucbase_install
120*ebfedea0SLionel Sambuc
121*ebfedea0SLionel Sambucdoc_install
122*ebfedea0SLionel Sambuc
123*ebfedea0SLionel Sambuccerts_install
124*ebfedea0SLionel Sambuc
125*ebfedea0SLionel Sambuccreate_cygwin_readme
126*ebfedea0SLionel Sambuc
127*ebfedea0SLionel Sambuccreate_profile_files
128*ebfedea0SLionel Sambuc
129*ebfedea0SLionel Sambuccd ${INSTALL_PREFIX}
130*ebfedea0SLionel Sambucchmod u+w usr/lib/engines/*.so
131*ebfedea0SLionel Sambucstrip usr/bin/*.exe usr/bin/*.dll usr/lib/engines/*.so
132*ebfedea0SLionel Sambucchmod u-w usr/lib/engines/*.so
133*ebfedea0SLionel Sambuc
134*ebfedea0SLionel Sambuc# Runtime package
135*ebfedea0SLionel Sambuctar cjf libopenssl${SHLIB_VERSION_NUMBER//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2 \
136*ebfedea0SLionel Sambuc     usr/bin/cyg*dll
137*ebfedea0SLionel Sambuc# Base package
138*ebfedea0SLionel Sambucfind etc usr/bin/openssl.exe usr/bin/c_rehash usr/lib/engines usr/share/doc \
139*ebfedea0SLionel Sambuc     usr/ssl/certs usr/ssl/man/man[157] usr/ssl/misc usr/ssl/openssl.cnf \
140*ebfedea0SLionel Sambuc     usr/ssl/private \
141*ebfedea0SLionel Sambuc     -empty -o \! -type d |
142*ebfedea0SLionel Sambuctar cjfT openssl-${VERSION}-${SUBVERSION}.tar.bz2 -
143*ebfedea0SLionel Sambuc# Development package
144*ebfedea0SLionel Sambucfind usr/include usr/lib/*.a usr/lib/pkgconfig usr/ssl/man/man3 \
145*ebfedea0SLionel Sambuc     -empty -o \! -type d |
146*ebfedea0SLionel Sambuctar cjfT openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2 -
147*ebfedea0SLionel Sambuc
148*ebfedea0SLionel Sambucls -l openssl-${VERSION}-${SUBVERSION}.tar.bz2
149*ebfedea0SLionel Sambucls -l openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2
150*ebfedea0SLionel Sambucls -l libopenssl${SHLIB_VERSION_NUMBER//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2
151*ebfedea0SLionel Sambuc
152*ebfedea0SLionel Sambuccleanup
153*ebfedea0SLionel Sambuc
154*ebfedea0SLionel Sambucexit 0
155