* [python] add --with-pythondir
@ 2009-03-04 18:00 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2009-03-04 18:00 UTC (permalink / raw)
To: Project Archer
This patch adds a --with-pythondir configure option.
By default, we install the python code in $gdb_datadir/python. This
directory is treated as relocatable, so if you move the whole $prefix
tree, it will keep working.
For a distro, however, we'd rather install gdb's python library in the
standard python library directory. --with-pythondir enables this. It
takes a directory argument.
Tom
2009-03-03 Tom Tromey <tromey@redhat.com>
* Makefile.in (pythondir): New variable.
(install-python): Use it.
(uninstall-python): Likewise.
* python/python.c (_initialize_python): Set pythondir if
--with-pythondir was given. Use it during initialization.
* configure, config.in: Rebuild.
* configure.ac (--with-pythondir): New option.
(PYTHONDIR): New define.
(pythondir): New subst.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 3b43d29..81cdb83 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -175,6 +175,10 @@ TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
# Did the user give us a --with-gdb-datadir option?
GDB_DATADIR_PATH = @GDB_DATADIR_PATH@
+# The argument to --with-pythondir. If not given, this is
+# GDB_DATADIR_PATH/python.
+pythondir = @pythondir@
+
# Helper code from gnulib.
LIBGNU = gnulib/libgnu.a
INCGNU = -I$(srcdir)/gnulib -Ignulib
@@ -1937,17 +1941,17 @@ PY_FILES = gdb/FrameIterator.py gdb/command/alias.py \
gdb/__init__.py
# Install the Python library. Python library files go under
-# $(GDB_DATADIR_PATH)/python.
+# $(pythondir).
install-python:
files='$(PY_FILES)'; for file in $$files; do \
dir=`echo "$$file" | sed 's,/[^/]*$$,,'`; \
- $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR_PATH)/python/$$dir; \
- $(INSTALL_DATA) $(srcdir)/python/lib/$$file $(DESTDIR)$(GDB_DATADIR_PATH)/python/$$file; \
+ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(pythondir)/$$dir; \
+ $(INSTALL_DATA) $(srcdir)/python/lib/$$file $(DESTDIR)$(pythondir)/$$file; \
done
# Brute force.
uninstall-python:
- rm -rf $(DESTDIR)/$(GDB_DATADIR_PATH)/python
+ rm -rf $(DESTDIR)/$(pythondir)
#
# Dependency tracking. Most of this is conditional on GNU Make being
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 95871d8..325d02f 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1,6 +1,6 @@
dnl Autoconf configure script for GDB, the GNU debugger.
dnl Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-dnl 2005, 2006, 2007, 2008
+dnl 2005, 2006, 2007, 2008, 2009
dnl Free Software Foundation, Inc.
dnl
dnl This file is part of GDB.
@@ -148,6 +148,21 @@ esac
GDB_DATADIR_PATH=${gdbdatadir}
AC_SUBST(GDB_DATADIR_PATH)
+AC_ARG_WITH([pythondir],
+ [AS_HELP_STRING([--with-pythondir],
+ [install Python data files in this path [DATADIR/gdb/python]])], [pythondir="${withval}"], [pythondir=no])
+
+# If the user passed in a path, define it. Otherwise, compute it at
+# runtime based on the possibly-relocatable datadir.
+if test "$pythondir" = "no"; then
+ pythondir='$(GDB_DATADIR_PATH)/python'
+else
+ AC_DEFINE_UNQUOTED(PYTHONDIR, "$pythondir",
+ [Define to install path for Python sources])
+fi
+AC_SUBST(pythondir)
+
+
AC_CONFIG_SUBDIRS(doc testsuite)
# Check whether to support alternative target configurations
diff --git a/gdb/python/python.c b/gdb/python/python.c
index c338009..d751fd4 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1775,8 +1775,12 @@ Enables or disables auto-loading of Python code when an object is opened."),
PyModule_AddStringConstant (gdb_module, "VERSION", (char*) version);
PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", (char*) host_name);
PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG", (char*) target_name);
+#ifdef PYTHONDIR
+ PyModule_AddStringConstant (gdb_module, "pythondir", PYTHONDIR);
+#else
if (gdb_datadir)
PyModule_AddStringConstant (gdb_module, "datadir", gdb_datadir);
+#endif
gdbpy_initialize_values ();
gdbpy_initialize_breakpoints ();
@@ -1827,11 +1831,12 @@ class GdbOutputFile:\n\
sys.stderr = GdbOutputFile()\n\
sys.stdout = GdbOutputFile()\n\
if hasattr (gdb, 'datadir'):\n\
- gdb.pythonlibdir = gdb.datadir + '/python'\n\
- sys.path.insert(0, gdb.pythonlibdir)\n\
- gdb.__path__ = [gdb.pythonlibdir + '/gdb']\n\
+ gdb.pythondir = gdb.datadir + '/python'\n\
+if hasattr (gdb, 'pythondir'):\n\
+ sys.path.insert(0, gdb.pythondir)\n\
+ gdb.__path__ = [gdb.pythondir + '/gdb']\n\
from os.path import exists\n\
- ipy = gdb.pythonlibdir + '/gdb/__init__.py'\n\
+ ipy = gdb.pythondir + '/gdb/__init__.py'\n\
if exists (ipy):\n\
execfile (ipy)\n\
");
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-03-04 18:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-04 18:00 [python] add --with-pythondir Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).