jpayne@69: #!/bin/sh jpayne@69: # Prints a package's identification PACKAGE VERSION or PACKAGE. jpayne@69: # jpayne@69: # Copyright (C) 2001-2003, 2005, 2014 Free Software Foundation, Inc. jpayne@69: # jpayne@69: # This program is free software: you can redistribute it and/or modify jpayne@69: # it under the terms of the GNU General Public License as published by jpayne@69: # the Free Software Foundation; either version 3 of the License, or jpayne@69: # (at your option) any later version. jpayne@69: # jpayne@69: # This program is distributed in the hope that it will be useful, jpayne@69: # but WITHOUT ANY WARRANTY; without even the implied warranty of jpayne@69: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jpayne@69: # GNU General Public License for more details. jpayne@69: # jpayne@69: # You should have received a copy of the GNU General Public License jpayne@69: # along with this program. If not, see . jpayne@69: jpayne@69: want_version="$1" jpayne@69: jpayne@69: # NLS nuisances: Letter ranges are different in the Estonian locale. jpayne@69: LC_ALL=C jpayne@69: jpayne@69: while true; do jpayne@69: if test -f configure; then jpayne@69: package=`(grep '^PACKAGE_NAME=' configure; grep '^ *PACKAGE=' configure) | grep -v '=[ ]*$' | sed -e '1q' | sed -e 's/^[^=]*=//' | sed -e "s/^'//" -e "s/'$//"` jpayne@69: case "$package" in jpayne@69: *[\"\$\`\{\}]*) jpayne@69: # Some packages (gcal) retrieve the package name dynamically. jpayne@69: package= jpayne@69: ;; jpayne@69: esac jpayne@69: if test -n "$package"; then jpayne@69: is_gnu=`LC_ALL=C grep "GNU $package" * 2>/dev/null | grep -v '^libtool:'` jpayne@69: if test -n "$is_gnu"; then jpayne@69: package="GNU $package" jpayne@69: fi jpayne@69: if test -n "$want_version"; then jpayne@69: version=`(grep '^PACKAGE_VERSION=' configure; grep '^ *VERSION=' configure) | grep -v '=[ ]*$' | sed -e '1q' | sed -e 's/^[^=]*=//' | sed -e "s/^'//" -e "s/'$//"` jpayne@69: case "$version" in jpayne@69: *[\"\$\`\{\}]*) jpayne@69: # Some packages (gcal, gcc, clisp) retrieve the version dynamically. jpayne@69: version= jpayne@69: ;; jpayne@69: esac jpayne@69: if test -n "$version"; then jpayne@69: echo "$package $version" jpayne@69: else jpayne@69: echo "$package" jpayne@69: fi jpayne@69: else jpayne@69: echo "$package" jpayne@69: fi jpayne@69: exit 0 jpayne@69: fi jpayne@69: fi jpayne@69: dir=`basename "\`pwd\`"` jpayne@69: case "$dir" in jpayne@69: i18n) jpayne@69: # This directory name, used in GNU make, is not the top level directory. jpayne@69: ;; jpayne@69: *[A-Za-z]*[0-9]*) jpayne@69: package=`echo "$dir" | sed -e 's/^\([^0-9]*\)[0-9].*$/\1/' -e 's/[-_]$//'` jpayne@69: if test -n "$want_version"; then jpayne@69: version=`echo "$dir" | sed -e 's/^[^0-9]*\([0-9].*\)$/\1/'` jpayne@69: echo "$package $version" jpayne@69: else jpayne@69: echo "$package" jpayne@69: fi jpayne@69: exit 0 jpayne@69: ;; jpayne@69: esac jpayne@69: # Go to parent directory jpayne@69: last=`/bin/pwd` jpayne@69: cd .. jpayne@69: curr=`/bin/pwd` jpayne@69: if test "$last" = "$curr"; then jpayne@69: # Oops, didn't find the package name. jpayne@69: if test -n "$want_version"; then jpayne@69: echo "PACKAGE VERSION" jpayne@69: else jpayne@69: echo "PACKAGE" jpayne@69: fi jpayne@69: exit 0 jpayne@69: fi jpayne@69: done