Blame sofort/tools/pkgconf.sh

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