09157951638 / compilers / bcparser

Forked from compilers/bcparser a year ago
Clone

Blame sofort/tools/pkgconf.sh

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