pamgdb.in revision 271947
1#!/bin/sh
2#
3# $Id: pamgdb.in 816 2014-09-12 07:50:22Z des $
4#
5
6srcdir="@abs_top_srcdir@"
7builddir="@abs_top_builddir@"
8
9# Make sure we get the right version of libpam
10pam_libdir="${builddir}/lib/.libs"
11LD_LIBRARY_PATH="${pam_libdir}:${LD_LIBRARY_PATH}"
12LD_LIBRARY_PATH="${LD_LIBRARY_PATH%:}"
13export LD_LIBRARY_PATH
14
15# DWIM, assuming that the first positional argument is the name of the
16# program to debug rather than a gdb option.
17prog="$1"
18if expr "${prog}" : ".*/.*" >/dev/null ; then
19	# The first argument is an absolute or relative path.  There
20	# is a good chance that it points to the wrapper script
21	# generated by libtool rather than the actual binary.
22	altprog="${prog%/*}/.libs/${prog##*/}"
23	if [ -x "${altprog}" ] ; then
24		shift
25		set "${altprog}" "$@"
26	fi
27elif expr "${prog}" : "[a-z.-][a-z.-]*" >/dev/null ; then
28	# The first argument is just the name of the program.  Look for
29	# it in the build directory.
30	for libdir in $(find "${builddir}" -type d -name .libs -print) ; do
31		altprog="${libdir}/${prog}"
32		if [ -x "${altprog}" ] ; then
33			shift
34			set "${altprog}" "$@"
35			break
36		fi
37	done
38fi
39
40# Let's go!
41exec gdb "$@"
42