diff options
author | midipix <writeonce@midipix.org> | 2018-12-19 07:35:46 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-12-21 22:48:29 -0500 |
commit | dcc018c9c562166281e757b69778be2be429d899 (patch) | |
tree | c339a5f000d05d544c426673624e6977de4ea753 | |
parent | 45423b672d0465c4111a683e495ddda911a9f12b (diff) | |
download | slibtool-dcc018c9c562166281e757b69778be2be429d899.tar.bz2 slibtool-dcc018c9c562166281e757b69778be2be429d899.tar.xz |
build system: re-implemented sofort/pkgconf.sh.
- replace all echo(1) and printf(1) constructs with a single cat(1).
- do not eliminate -I${prefix}/lib and -L${exec_prefix}/lib;
- eliminate trailing spaces from the end of a line.
-rwxr-xr-x | sofort/pkgconf.sh | 135 |
1 files changed, 75 insertions, 60 deletions
diff --git a/sofort/pkgconf.sh b/sofort/pkgconf.sh index a3f8eb0..1b65604 100755 --- a/sofort/pkgconf.sh +++ b/sofort/pkgconf.sh @@ -2,91 +2,106 @@ # prefix, exec_prefix if [ "$PKGCONF_PREFIX" = "$PKGCONF_EXEC_PREFIX" ]; then - echo 'prefix='${PKGCONF_PREFIX} - echo 'exec_prefix=${prefix}' + pkgconf_prefix="${PKGCONF_PREFIX}" + pkgconf_exec_prefix='${prefix}' else - echo 'prefix='${PKGCONF_PREFIX} - echo 'exec_prefix='${PKGCONF_EXEC_PREFIX} + pkgconf_prefix="${PKGCONF_PREFIX}" + pkgconf_exec_prefix="${PKGCONF_EXEC_PREFIX}" fi # (relative) includedir -prefix=`dirname "$PKGCONF_INCLUDEDIR"` -base=`basename "$PKGCONF_INCLUDEDIR"` - -if [ "$prefix/$base" = "$PKGCONF_PREFIX/$base" ]; then - echo 'includedir=${prefix}/'${base} -else - echo 'includedir='${PKGCONF_INCLUDEDIR} -fi - -if [ "$prefix/$base" = "$PKGCONF_PREFIX/include" ]; then - CFLAGS= +if [ -z "$PKGCONF_INCLUDEDIR" ]; then + pkgconf_includedir= + pkgconf_cflags= else - CFLAGS='-I{includedir}' + prefix=$(dirname "$PKGCONF_INCLUDEDIR") + base=$(basename "$PKGCONF_INCLUDEDIR") + + if [ "$prefix/$base" = "$PKGCONF_PREFIX/$base" ]; then + pkgconf_includedir='${prefix}/'"${base}" + pkgconf_cflags='-I${includedir}' + else + pkgconf_includedir="${PKGCONF_INCLUDEDIR}" + pkgconf_cflags='-I${includedir}' + fi fi -# (relative) libdir -prefix=`dirname "$PKGCONF_LIBDIR"` -base=`basename "$PKGCONF_LIBDIR"` - -if [ "$prefix/$base" = "$PKGCONF_EXEC_PREFIX/$base" ]; then - echo 'libdir=${prefix}/'${base} +# (relative) libdir (blank unless needed) +if [ -z "$PKGCONF_LIBDIR" ]; then + pkgconf_libdir= else - echo 'libdir='${PKGCONF_LIBDIR} + prefix=$(dirname "$PKGCONF_LIBDIR") + base=$(basename "$PKGCONF_LIBDIR") + + if [ "$prefix/$base" = "$PKGCONF_EXEC_PREFIX/$base" ]; then + pkgconf_libdir='${exec_prefix}/'"${base}" + else + pkgconf_libdir='${prefix}/'"${PKGCONF_LIBDIR}" + fi fi -if [ "$prefix/$base" = "$PKGCONF_EXEC_PREFIX/lib" ]; then - LDFLAGS='-l'${PKGCONF_NAME} -elif [ "$prefix/$base" = "$PKGCONF_EXEC_PREFIX/lib64" ]; then - LDFLAGS='-l'${PKGCONF_NAME} + +# ldflags (--libs) +if [ -n "$pkgconf_libdir" ] && [ -n "${PKGCONF_NAME}" ]; then + pkgconf_ldflags="$pkgconf_libdir -l${PKGCONF_NAME}" +elif [ -n "${PKGCONF_NAME}" ]; then + pkgconf_ldflags="-l${PKGCONF_NAME}" else - LDFLAGS='-L'${PKGCONF_LIBDIR} '-l'${PKGCONF_NAME} + pkgconf_ldflags="$pkgconf_libdir" fi -# name, description, url, version -echo -echo 'Name: '${PKGCONF_NAME} -echo 'Description: '${PKGCONF_DESC} -echo 'URL: '${PKGCONF_USRC} -echo 'Version: '${PKGCONF_VERSION} +# cflags +if [ -n "$pkgconf_cflags" ] || [ -n "${PKGCONF_DEFS}" ]; then + pkgconf_cflags=" $pkgconf_cflags ${PKGCONF_DEFS}" + pkgconf_cflags=$(printf '%s' "$pkgconf_cflags" | sed -e 's/^[ \t]*//g') +fi # repo (optional) -if ! [ -z "$PKGCONF_REPO" ]; then - echo 'Repo: '${PKGCONF_REPO} +if [ -z "${PKGCONF_REPO}" ]; then + pkgconf_repo='#' +else + pkgconf_repo="Repo: ${PKGCONF_REPO}" fi - # patches (optional) -if ! [ -z "$PKGCONF_PSRC" ]; then - echo 'Patches: '${PKGCONF_PSRC} -fi - - -# disto (optional) -if ! [ -z "$PKGCONF_DURL" ]; then - echo 'Distro: '${PKGCONF_DURL} +if [ -z "${PKGCONF_PSRC}" ]; then + pkgconf_psrc='#' +else + pkgconf_psrc="Patches: ${PKGCONF_PSRC}" fi - -# Cflags -if [ -z "$PKGCONF_DEFS" ] && [ -z "$CFLAGS" ]; then - echo 'Cflags:' -elif [ -z "$PKGCONF_DEFS" ]; then - echo 'Cflags: '${CFLAGS} -elif [ -z "$CFLAGS" ]; then - echo 'Cflags: '${PKGCONF_DEFS} +# distro (optional) +if [ -z "${PKGCONF_DURL}" ]; then + pkgconf_durl='#' else - echo 'Cflags: '${PKGCONF_DEFS} ${CFLAGS} + pkgconf_durl="Distro: ${PKGCONF_DURL}" fi -# Libs -if [ -z "$PKGCONF_LIBS" ]; then - echo 'Libs: '${LDFLAGS} -else - echo 'Libs: '${PKGCONF_LIBS} ${LDFLAGS} -fi +# output (without trailing spaces) +cat << _EOF | grep -v '^#' | sed 's/[ \t]*$//' +### +prefix=$pkgconf_prefix +exec_prefix=$pkgconf_exec_prefix +includedir=$pkgconf_includedir +libdir=$pkgconf_libdir + +Name: ${PKGCONF_NAME} +Description: ${PKGCONF_DESC} +URL: ${PKGCONF_USRC} +Version: ${PKGCONF_VERSION} +$pkgconf_repo +$pkgconf_psrc +$pkgconf_durl + +Cflags: $pkgconf_cflags +Libs: $pkgconf_ldflags +### +_EOF + +# all done +exit 0 |