summaryrefslogtreecommitdiff
path: root/find_c_extension.sh
blob: 77aa838eca003b641dc7b5e9d95a26a8f2e49c40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /bin/sh

# Usage: find_c_extension.sh BUILDDIR
#
# Write path of directory containing C-extension of build directory.
#
# More precisely, locate the unique directory of the form:
#
#   _include_server/lib.*/include_server/
#
# that contains file 'distcc_pump_c_extensions.so'. Write the path of this 
# directory to stdout and exit with status 0. If such a path does not exist 
# then write error message to stderr and exit with status 1.

builddir=$1
so_files=`ls $builddir/_include_server/lib.*/include_server/\
distcc_pump_c_extensions.so`
if [ -z "$so_files" ]; then
  echo \
    '__________Could not find shared libraries for distcc-pump' 1>&2
  exit 1
elif echo $so_files | grep -q ' '; then
  echo \
    '__________Shared libraries for multiple architectures discovered.' \
    1>&2
  echo \
    "__________Cannot determine which one to use among: $so_files" \
    1>&2
  exit 1
else
  # There was only one such file.
  dirname $so_files
  exit 0
fi