1236099Sdes#!/bin/sh
2236099Sdes#
3271947Sdes# $Id: pamgdb.in 816 2014-09-12 07:50:22Z des $
4236099Sdes#
5236099Sdes
6236099Sdessrcdir="@abs_top_srcdir@"
7236099Sdesbuilddir="@abs_top_builddir@"
8236099Sdes
9236099Sdes# Make sure we get the right version of libpam
10236099Sdespam_libdir="${builddir}/lib/.libs"
11236099SdesLD_LIBRARY_PATH="${pam_libdir}:${LD_LIBRARY_PATH}"
12236099SdesLD_LIBRARY_PATH="${LD_LIBRARY_PATH%:}"
13236099Sdesexport LD_LIBRARY_PATH
14236099Sdes
15236099Sdes# DWIM, assuming that the first positional argument is the name of the
16236099Sdes# program to debug rather than a gdb option.
17236099Sdesprog="$1"
18236099Sdesif expr "${prog}" : ".*/.*" >/dev/null ; then
19236099Sdes	# The first argument is an absolute or relative path.  There
20236099Sdes	# is a good chance that it points to the wrapper script
21236099Sdes	# generated by libtool rather than the actual binary.
22236099Sdes	altprog="${prog%/*}/.libs/${prog##*/}"
23236099Sdes	if [ -x "${altprog}" ] ; then
24236099Sdes		shift
25236099Sdes		set "${altprog}" "$@"
26236099Sdes	fi
27236099Sdeselif expr "${prog}" : "[a-z.-][a-z.-]*" >/dev/null ; then
28236099Sdes	# The first argument is just the name of the program.  Look for
29236099Sdes	# it in the build directory.
30236099Sdes	for libdir in $(find "${builddir}" -type d -name .libs -print) ; do
31236099Sdes		altprog="${libdir}/${prog}"
32236099Sdes		if [ -x "${altprog}" ] ; then
33236099Sdes			shift
34236099Sdes			set "${altprog}" "$@"
35236099Sdes			break
36236099Sdes		fi
37236099Sdes	done
38236099Sdesfi
39236099Sdes
40236099Sdes# Let's go!
41236099Sdesexec gdb "$@"
42