gdb: Allow more control over where to find python libraries
The motivation behind this commit is to make it easier to bundle the
Python *.py library files with GDB when statically linking GDB against
libpython. The Python files will be manually added into the GDB
installation tree, and GDB should be able to find them at run-time.
The installation tree will look like this:
.
|-- bin/
|-- include/
|-- lib/
| `-- python3.8/
`-- share/
The benefit here is that the entire installation tree can be bundled
into a single archive and copied to another machine with a different
version of Python installed, and GDB will still work, including its
Python support.
In use the new configure options would be used something like this,
first build and install a static Python library:
mkdir python
cd python
# Clone or download Python into a src/ directory.
mkdir build
export PYTHON_INSTALL_PATH=$PWD/install
cd build
../src/configure --disable-shared --prefix=$PYTHON_INSTALL_PATH
make
make install
Now build and install GDB:
mkdir binutils-gdb
cd binutils-gdb
# Clone or download GDB into a src/ directory.
mkdir build
export GDB_INSTALL_DIR=$PWD/install
cd build
../src/configure \
--prefix=$GDB_INSTALL_DIR \
--with-python=$PYTHON_INSTALL_PATH/bin/python3 \
--with-python-libdir=$GDB_INSTALL_DIR/lib
make all-gdb
make install-gdb
Finally, copy the Python libraries into the GDB install:
cp -r $PYTHON_INSTALL_DIR/lib/python3.8/ $GDB_INSTALL_DIR/lib
After this the Python src, build, and install directories are no
longer needed and can be deleted.
If the new --with-python-libdir option is not used then the existing
behaviour is left unchanged, GDB will look for the Python libraries in
the lib/ directory within the python path. The concatenation of the
python prefix and the string 'lib/' is now done at configure time,
rather than at run time in GDB as it was previous, however, this was
never something that the user had dynamic control over, so there's no
loss of functionality.
gdb/ChangeLog:
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Add --with-python-libdir option.
* main.c: Use WITH_PYTHON_LIBDIR.