| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Locate file in $VPATH. |
| 4 |
|
| 5 |
if [ $# != 1 ] |
| 6 |
then |
| 7 |
echo "Usage: find-vpath FILE" >&2 |
| 8 |
exit 2 |
| 9 |
fi |
| 10 |
|
| 11 |
file="$1" |
| 12 |
IFS=: |
| 13 |
for dir in ${VPATH:-.} |
| 14 |
do |
| 15 |
if [ x"$dir" = x ] || [ x"$dir" = x. ] |
| 16 |
then |
| 17 |
path=$file |
| 18 |
else |
| 19 |
path="$dir/$file" |
| 20 |
fi |
| 21 |
|
| 22 |
if [ -f "$path" ] |
| 23 |
then |
| 24 |
echo "$path" |
| 25 |
exit 0 |
| 26 |
fi |
| 27 |
done |
| 28 |
|
| 29 |
# This is typically called from make like: |
| 30 |
# |
| 31 |
# $(INSTALL_DATA) `build-aux/find-file-vpath something` $(DESTDIR)$(somedir) |
| 32 |
# |
| 33 |
# so we should return something which will result in a useful error |
| 34 |
# message from the install program ("can't find something"), rather |
| 35 |
# than a usage message since it was called with the wrong number of |
| 36 |
# arguments. |
| 37 |
|
| 38 |
echo "$file" |