xref: /openbsd-src/lib/libssl/generate_pkgconfig.sh (revision 938cc31da497eebb0005d9a4ed76447128fca4bc)
17fb09174Sjasper#!/bin/sh
27fb09174Sjasper#
3*938cc31dStb# $OpenBSD: generate_pkgconfig.sh,v 1.11 2022/02/04 16:42:15 tb Exp $
452b20e7bSjasper#
552b20e7bSjasper# Copyright (c) 2010,2011 Jasper Lievisse Adriaanse <jasper@openbsd.org>
652b20e7bSjasper#
752b20e7bSjasper# Permission to use, copy, modify, and distribute this software for any
852b20e7bSjasper# purpose with or without fee is hereby granted, provided that the above
952b20e7bSjasper# copyright notice and this permission notice appear in all copies.
1052b20e7bSjasper#
1152b20e7bSjasper# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1252b20e7bSjasper# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1352b20e7bSjasper# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1452b20e7bSjasper# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1552b20e7bSjasper# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1652b20e7bSjasper# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1752b20e7bSjasper# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
187fb09174Sjasper#
197fb09174Sjasper# Generate pkg-config files for OpenSSL.
207fb09174Sjasper
217fb09174Sjasperusage() {
2252b20e7bSjasper	echo "usage: ${0##*/} -c current_directory -o obj_directory"
237fb09174Sjasper	exit 1
247fb09174Sjasper}
257fb09174Sjasper
267fb09174Sjaspercurdir=
277fb09174Sjasperobjdir=
2852b20e7bSjasperwhile getopts "c:o:" flag; do
297fb09174Sjasper	case "$flag" in
307fb09174Sjasper		c)
317fb09174Sjasper			curdir=$OPTARG
327fb09174Sjasper			;;
337fb09174Sjasper		o)
347fb09174Sjasper			objdir=$OPTARG
357fb09174Sjasper			;;
367fb09174Sjasper		*)
377fb09174Sjasper			usage
387fb09174Sjasper			;;
397fb09174Sjasper	esac
407fb09174Sjasperdone
417fb09174Sjasper
427fb09174Sjasper[ -n "${curdir}" ] || usage
4375d8acf5Smatthieuif [ ! -d "${curdir}" ]; then
4475d8acf5Smatthieu	echo "${0##*/}: ${curdir}: not found"
457fb09174Sjasper	exit 1
467fb09174Sjasperfi
477fb09174Sjasper[ -n "${objdir}" ] || usage
487fb09174Sjasperif [ ! -w "${objdir}" ]; then
497fb09174Sjasper	echo "${0##*/}: ${objdir}: not found or not writable"
507fb09174Sjasper	exit 1
517fb09174Sjasperfi
527fb09174Sjasper
5352b20e7bSjasperversion_re="s/^#define[[:blank:]]+SHLIB_VERSION_NUMBER[[:blank:]]+\"(.*)\".*/\1/p"
5426febb63Sbeckversion_file=${curdir}/../libcrypto/opensslv.h
55*938cc31dStb#lib_version=$(sed -nE ${version_re} ${version_file})
56*938cc31dStblib_version=2.0.0
577fb09174Sjasper
5813c734b5Snaddy# Put -I${includedir} into Cflags so configure script tests like
5913c734b5Snaddy#   test -n "`pkg-config --cflags openssl`"
6013c734b5Snaddy# don't assume that OpenSSL isn't available.
6113c734b5Snaddy
627fb09174Sjasperpc_file="${objdir}/libssl.pc"
637fb09174Sjaspercat > ${pc_file} << __EOF__
647fb09174Sjasperprefix=/usr
657fb09174Sjasperexec_prefix=\${prefix}
667fb09174Sjasperlibdir=\${exec_prefix}/lib
677fb09174Sjasperincludedir=\${prefix}/include
687fb09174Sjasper
697599ce71SinoguchiName: OpenSSL-libssl
707fb09174SjasperDescription: Secure Sockets Layer and cryptography libraries
7152b20e7bSjasperVersion: ${lib_version}
727599ce71SinoguchiRequires.private: libcrypto
737599ce71SinoguchiLibs: -L\${libdir} -lssl
7413c734b5SnaddyCflags: -I\${includedir}
757fb09174Sjasper__EOF__
767fb09174Sjasper
777fb09174Sjasper
787fb09174Sjasperpc_file="${objdir}/openssl.pc"
797fb09174Sjaspercat > ${pc_file} << __EOF__
807fb09174Sjasperprefix=/usr
817fb09174Sjasperexec_prefix=\${prefix}
827fb09174Sjasperlibdir=\${exec_prefix}/lib
837fb09174Sjasperincludedir=\${prefix}/include
847fb09174Sjasper
857fb09174SjasperName: OpenSSL
867fb09174SjasperDescription: Secure Sockets Layer and cryptography libraries and tools
8752b20e7bSjasperVersion: ${lib_version}
887599ce71SinoguchiRequires: libssl libcrypto
897fb09174Sjasper__EOF__
90