Bug 21465 - Installing scripts in auto-load scripts-directory
Summary: Installing scripts in auto-load scripts-directory
Status: UNCONFIRMED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-06 22:42 UTC by dilyan.palauzov@aegee.org
Modified: 2017-05-07 00:45 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dilyan.palauzov@aegee.org 2017-05-06 22:42:42 UTC
If an Autotools package wants to install a -gdb.py script under "auto-load scripts-directory" during "make install", what is the procedure to determine the destination path?

I wrote this code:

AC_CHECK_PROG(gdb, gdb, found)
if $gdb = found; then
  GDB_AUTO_LOAD_SCRIPTS_DIRECTORY=$(gdb -q -ex "show data-directory" -ex "show auto-load scripts-directory" -ex quit |sed "1d;2{N;s/\n//g; s/.*\"\(.*\)\".*:\(.*\)./\1 \2/}; /\$datadir/ {s/\(.*\) \$datadir\(.*\)/\1\2/;q}; s/.* \(.\)/\1/")
else
  GDB_AUTO_LOAD_SCRIPTS_DIRECTORY='${datadir}/gdb/auto-load/${libdir}'
fi
AC_SUBST(GDB_AUTO_LOAD_SCRIPTS_DIRECTORY)

which exposes the current "auto-load scripts-directory" to the Makefile

Isn't there a better way?

show configuration prints:

This GDB was configured as follows:
   configure --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu
             --with-auto-load-dir=$debugdir:$datadir/auto-load
             --with-auto-load-safe-path=$debugdir:$datadir/auto-load
             --with-expat
             --with-gdb-datadir=/usr/local/share/gdb (relocatable)
             --with-jit-reader-dir=/usr/local/lib/gdb (relocatable)
             --without-libunwind-ia64
             --with-lzma
             --with-python=/usr/local (relocatable)
             --with-guile
             --with-separate-debug-dir=/usr/local/lib/debug (relocatable)
             --without-babeltrace

("Relocatable" means the directory can be moved with the GDB installation
tree, and GDB will still find it.)

info '(gdb)Data Files':
If the data directory is inside GDB's configured binary prefix (set with '--prefix' or '--exec-prefix'), then the default data directory will be updated automatically if the installed GDB is moved to a new location.

and my gdb is in /usr/local/bin.

Where shall I move gdb, so that 'show configurtion' prints something different for '--with-gdb-datadir'?
Comment 1 dilyan.palauzov@aegee.org 2017-05-07 00:32:23 UTC
I mean

AC_CHECK_PROG(gdb, gdb, found)
if $gdb = found; then
  GDB_AUTO_LOAD_SCRIPTS_DIRECTORY=$(gdb -q -ex "show data-directory" -ex "show auto-load scripts-directory" -ex quit |sed "1d;2{N;s/\n//g; s/.*\"\(.*\)\".*:\(.*\)./\1 \2/}; /\$datadir/ {s/\(.*\) \$datadir\(.*\)/\1\2/;q}; s/.* \(.\)/\1/")
else
  GDB_AUTO_LOAD_SCRIPTS_DIRECTORY='${datadir}/gdb/auto-load'
fi
AC_SUBST(GDB_AUTO_LOAD_SCRIPTS_DIRECTORY)
Comment 2 dilyan.palauzov@aegee.org 2017-05-07 00:45:14 UTC
AC_CHECK_PROG(gdb, gdb, found)
if test $gdb = found; then
  GDB_AUTO_LOAD_SCRIPTS_DIRECTORY=$(gdb -q -ex "show data-directory" -ex "show auto-load scripts-directory" -ex quit |sed "1d;2{N;s/\n//g; s/.*\"\(.*\)\".*:\(.*\)./\1 \2/}; /\$datadir/ {s/\(.*\) \$datadir\(.*\)/\1\2/;q}; s/.* \(.\)/\1/")
else
  GDB_AUTO_LOAD_SCRIPTS_DIRECTORY='${datadir}/gdb/auto-load'
fi
AC_SUBST(GDB_AUTO_LOAD_SCRIPTS_DIRECTORY)