Reicher82 / python / sbpython3

Forked from python/sbpython3 3 years ago
Clone

Blame sofort/tools/pkgconf.sh

5dc983
#!/bin/sh
5dc983
920216
set -eu
920216
5dc983
# prefix, exec_prefix
5dc983
if [ "$PKGCONF_PREFIX" = "$PKGCONF_EXEC_PREFIX" ]; then
7cb7c8
	pkgconf_prefix="${PKGCONF_PREFIX}"
7cb7c8
	pkgconf_exec_prefix='${prefix}'
5dc983
else
7cb7c8
	pkgconf_prefix="${PKGCONF_PREFIX}"
7cb7c8
	pkgconf_exec_prefix="${PKGCONF_EXEC_PREFIX}"
5dc983
fi
5dc983
5dc983
5dc983
# (relative) includedir
7cb7c8
if [ -z "$PKGCONF_INCLUDEDIR" ]; then
7cb7c8
	pkgconf_includedir=
7cb7c8
	pkgconf_cflags=
5dc983
else
7cb7c8
	prefix=$(dirname "$PKGCONF_INCLUDEDIR")
7cb7c8
	base=$(basename "$PKGCONF_INCLUDEDIR")
7cb7c8
7cb7c8
	if [ "$prefix/$base" = "$PKGCONF_PREFIX/$base" ]; then
7cb7c8
		pkgconf_includedir='${prefix}/'"${base}"
7cb7c8
		pkgconf_cflags='-I${includedir}'
7cb7c8
	else
7cb7c8
		pkgconf_includedir="${PKGCONF_INCLUDEDIR}"
7cb7c8
		pkgconf_cflags='-I${includedir}'
7cb7c8
	fi
5dc983
fi
5dc983
5dc983
7cb7c8
# (relative) libdir (blank unless needed)
7cb7c8
if [ -z "$PKGCONF_LIBDIR" ]; then
7cb7c8
	pkgconf_libdir=
5dc983
else
7cb7c8
	prefix=$(dirname "$PKGCONF_LIBDIR")
7cb7c8
	base=$(basename "$PKGCONF_LIBDIR")
7cb7c8
7cb7c8
	if [ "$prefix/$base" = "$PKGCONF_EXEC_PREFIX/$base" ]; then
7cb7c8
		pkgconf_libdir='${exec_prefix}/'"${base}"
7cb7c8
	else
7cb7c8
		pkgconf_libdir='${prefix}/'"${PKGCONF_LIBDIR}"
7cb7c8
	fi
5dc983
fi
5dc983
7cb7c8
7cb7c8
# ldflags (--libs)
7cb7c8
if [ -n "$pkgconf_libdir" ] &&  [ -n "${PKGCONF_NAME}" ]; then
7cb7c8
	pkgconf_ldflags="$pkgconf_libdir -l${PKGCONF_NAME}"
7cb7c8
elif [ -n "${PKGCONF_NAME}" ]; then
7cb7c8
	pkgconf_ldflags="-l${PKGCONF_NAME}"
5dc983
else
7cb7c8
	pkgconf_ldflags="$pkgconf_libdir"
5dc983
fi
5dc983
5dc983
7cb7c8
# cflags
7cb7c8
if [ -n "$pkgconf_cflags" ] || [ -n "${PKGCONF_DEFS}" ]; then
d8b018
	pkgconf_cflags="$pkgconf_cflags ${PKGCONF_DEFS}"
7cb7c8
	pkgconf_cflags=$(printf '%s' "$pkgconf_cflags" | sed -e 's/^[ \t]*//g')
7cb7c8
fi
5dc983
5dc983
5dc983
# repo (optional)
7cb7c8
if [ -z "${PKGCONF_REPO}" ]; then
7cb7c8
	pkgconf_repo='#'
7cb7c8
else
7cb7c8
	pkgconf_repo="Repo:        ${PKGCONF_REPO}"
5dc983
fi
5dc983
5dc983
# patches (optional)
7cb7c8
if [ -z "${PKGCONF_PSRC}" ]; then
7cb7c8
	pkgconf_psrc='#'
7cb7c8
else
7cb7c8
	pkgconf_psrc="Patches:     ${PKGCONF_PSRC}"
5dc983
fi
5dc983
7cb7c8
# distro (optional)
7cb7c8
if [ -z "${PKGCONF_DURL}" ]; then
7cb7c8
	pkgconf_durl='#'
5dc983
else
7cb7c8
	pkgconf_durl="Distro:      ${PKGCONF_DURL}"
5dc983
fi
5dc983
5dc983
7cb7c8
# output (without trailing spaces)
7cb7c8
cat << _EOF | grep -v '^#' | sed 's/[ \t]*$//'
7cb7c8
###
7cb7c8
prefix=$pkgconf_prefix
7cb7c8
exec_prefix=$pkgconf_exec_prefix
7cb7c8
includedir=$pkgconf_includedir
7cb7c8
libdir=$pkgconf_libdir
7cb7c8
7cb7c8
Name:        ${PKGCONF_NAME}
7cb7c8
Description: ${PKGCONF_DESC}
7cb7c8
URL:         ${PKGCONF_USRC}
7cb7c8
Version:     ${PKGCONF_VERSION}
7cb7c8
$pkgconf_repo
7cb7c8
$pkgconf_psrc
7cb7c8
$pkgconf_durl
7cb7c8
7cb7c8
Cflags:      $pkgconf_cflags
7cb7c8
Libs:        $pkgconf_ldflags
7cb7c8
###
7cb7c8
_EOF
7cb7c8
7cb7c8
# all done
7cb7c8
exit 0