Blame sofort/tools/pkgconf.sh

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