Blame sofort/pkgconf.sh

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