xref: /freebsd/crypto/openssh/.github/install_libcrypto.sh (revision 644b4646c7acab87dc20d4e5dd53d2d9da152989)
1*644b4646SEd Maste#!/bin/sh
2*644b4646SEd Maste#
3*644b4646SEd Maste# Install specified libcrypto.
4*644b4646SEd Maste#  -a : install version for ABI compatibility test.
5*644b4646SEd Maste#  -n : dry run, don't actually build and install.
6*644b4646SEd Maste#
7*644b4646SEd Maste# Usage: $0 [-a] [-n] openssl-$branch/tag destdir [config options]
8*644b4646SEd Maste
9*644b4646SEd Masteset -e
10*644b4646SEd Maste
11*644b4646SEd Mastebincompat_test=""
12*644b4646SEd Mastedryrun=""
13*644b4646SEd Mastewhile [ "$1" = "-a" ] || [ "$1" = "-n" ]; do
14*644b4646SEd Maste	if [ "$1" = "-a" ]; then
15*644b4646SEd Maste		abi_compat_test=y
16*644b4646SEd Maste	elif [ "$1" = "-n" ]; then
17*644b4646SEd Maste		dryrun="echo dryrun:"
18*644b4646SEd Maste	fi
19*644b4646SEd Maste	shift
20*644b4646SEd Mastedone
21*644b4646SEd Maste
22*644b4646SEd Mastever="$1"
23*644b4646SEd Mastedestdir="$2"
24*644b4646SEd Masteopts="$3"
25*644b4646SEd Maste
26*644b4646SEd Masteif [ -z "${ver}" ] || [ -z "${destdir}" ]; then
27*644b4646SEd Maste	echo tag/branch and destdir required
28*644b4646SEd Maste	exit 1
29*644b4646SEd Mastefi
30*644b4646SEd Maste
31*644b4646SEd Masteset -x
32*644b4646SEd Maste
33*644b4646SEd Masteif [ ! -d ${HOME}/openssl ]; then
34*644b4646SEd Maste	cd ${HOME}
35*644b4646SEd Maste	git clone https://github.com/openssl/openssl.git
36*644b4646SEd Maste	cd ${HOME}/openssl
37*644b4646SEd Maste	git fetch --all
38*644b4646SEd Mastefi
39*644b4646SEd Mastecd ${HOME}/openssl
40*644b4646SEd Maste
41*644b4646SEd Masteif [ "${abi_compat_test}" = "y" ]; then
42*644b4646SEd Maste	echo selecting ABI test release/branch for ${ver}
43*644b4646SEd Maste	case "${ver}" in
44*644b4646SEd Maste	openssl-3.6)
45*644b4646SEd Maste		ver=openssl-3.0.0
46*644b4646SEd Maste		echo "selecting older release ${ver}"
47*644b4646SEd Maste		;;
48*644b4646SEd Maste	openssl-3.[012345])
49*644b4646SEd Maste		major=$(echo ${ver} | cut -f1 -d.)
50*644b4646SEd Maste		minor=$(echo ${ver} | cut -f2 -d.)
51*644b4646SEd Maste		ver="${major}.$((${minor} + 1))"
52*644b4646SEd Maste		echo selecting next release branch ${ver}
53*644b4646SEd Maste		;;
54*644b4646SEd Maste	openssl-3.*.*)
55*644b4646SEd Maste		major=$(echo ${ver} | cut -f1 -d.)
56*644b4646SEd Maste		minor=$(echo ${ver} | cut -f2 -d.)
57*644b4646SEd Maste		patch=$(echo ${ver} | cut -f3 -d.)
58*644b4646SEd Maste		ver="${major}.${minor}.$((${patch} + 1))"
59*644b4646SEd Maste		echo checking for release tag ${ver}
60*644b4646SEd Maste		if git tag | grep -q "^${ver}\$"; then
61*644b4646SEd Maste			echo selected next patch release ${ver}
62*644b4646SEd Maste		else
63*644b4646SEd Maste			ver="${major}.${minor}"
64*644b4646SEd Maste			echo not found, selecting release branch ${ver}
65*644b4646SEd Maste		fi
66*644b4646SEd Maste		;;
67*644b4646SEd Maste	esac
68*644b4646SEd Mastefi
69*644b4646SEd Maste
70*644b4646SEd Mastegit checkout ${ver}
71*644b4646SEd Mastemake clean >/dev/null 2>&1 || true
72*644b4646SEd Maste${dryrun} ./config no-threads shared ${opts} --prefix=${destdir} \
73*644b4646SEd Maste    -Wl,-rpath,${destdir}/lib64
74*644b4646SEd Maste${dryrun} make -j4
75*644b4646SEd Maste${dryrun} sudo make install_sw
76