summaryrefslogtreecommitdiffstats
path: root/lib/libssl/generate_pkgconfig.sh
blob: 4d04cc574239966d48344fe52becd943eea5fe8f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
#
# $OpenBSD: generate_pkgconfig.sh,v 1.4 2011/01/25 20:53:18 naddy Exp $
#
# Generate pkg-config files for OpenSSL.

usage() {
	echo "usage: ${0##*/} [-k] -c current_directory -o obj_directory"
	exit 1
}

curdir=
objdir=
while getopts "c:ko:" flag; do
	case "$flag" in
		c)
			curdir=$OPTARG
			;;
		o)
			objdir=$OPTARG
			;;
		*)
			usage
			;;
	esac
done

[ -n "${curdir}" ] || usage
if [ ! -w "${curdir}" ]; then
	echo "${0##*/}: ${curdir}: not found or not writable"
	exit 1
fi
[ -n "${objdir}" ] || usage
if [ ! -w "${objdir}" ]; then
	echo "${0##*/}: ${objdir}: not found or not writable"
	exit 1
fi

ssl_version=$(sed -nE 's/^#define[[:blank:]]+SHLIB_VERSION_NUMBER[[:blank:]]+"(.*)".*/\1/p' \
	${curdir}/src/crypto/opensslv.h)

# Put -I${includedir} into Cflags so configure script tests like
#   test -n "`pkg-config --cflags openssl`"
# don't assume that OpenSSL isn't available.

pc_file="${objdir}/libcrypto.pc"
cat > ${pc_file} << __EOF__
prefix=/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include

Name: OpenSSL-libcrypto
Description: OpenSSL cryptography library
Version: ${ssl_version}
Requires: 
Libs: -lcrypto
Cflags: -I\${includedir}
__EOF__


pc_file="${objdir}/libssl.pc"
cat > ${pc_file} << __EOF__
prefix=/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include

Name: OpenSSL
Description: Secure Sockets Layer and cryptography libraries
Version: ${ssl_version}
Requires: 
Libs: -lssl -lcrypto
Cflags: -I\${includedir}
__EOF__


pc_file="${objdir}/openssl.pc"
cat > ${pc_file} << __EOF__
prefix=/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include

Name: OpenSSL
Description: Secure Sockets Layer and cryptography libraries and tools
Version: ${ssl_version}
Requires: 
Libs: -lssl -lcrypto
Cflags: -I\${includedir}
__EOF__