From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21082 invoked by alias); 4 Mar 2009 18:00:28 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 21056 invoked by uid 22791); 4 Mar 2009 18:00:25 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_24,J_CHICKENPOX_36,J_CHICKENPOX_37,J_CHICKENPOX_39,J_CHICKENPOX_92,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org To: Project Archer Subject: [python] add --with-pythondir From: Tom Tromey Reply-To: tromey@redhat.com Date: Wed, 04 Mar 2009 18:00:00 -0000 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2009-q1/txt/msg00330.txt.bz2 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 * 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\ ");