Add $HOME/.openocd as the first default script search directory, allowing
the user to override the standard scripts.

Update the user guide with information on where OpenOCD expects to find
configuration files and scripts. Also fixed some minor formatting issues.

Add entry to NEWS as well.

Signed-off-by: Andreas Fritiofson <andreas.fritiof...@gmail.com>
---
 NEWS                 |    1 +
 doc/openocd.texi     |   22 ++++++++++++++--------
 src/helper/options.c |   13 ++++++++++++-
 3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/NEWS b/NEWS
index 1a024e4..0dcc4bc 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,7 @@ Flash Layer:
 Board, Target, and Interface Configuration Scripts:
        ARM9
                - ETM and ETB hookup for iMX2* targets
+       Add $HOME/.openocd to the search path.
 
 Documentation:
 Build and Release:
diff --git a/doc/openocd.texi b/doc/openocd.texi
index 9659e92..f895cc3 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -483,14 +483,24 @@ bash$ openocd --help
 --pipe       | -p       use pipes when talking to gdb
 @end verbatim
 
-By default OpenOCD reads the file configuration file @file{openocd.cfg}
-in the current directory.  To specify a different (or multiple)
-configuration file, you can use the ``-f'' option. For example:
+By default OpenOCD reads the configuration file @file{openocd.cfg}.
+To specify a different (or multiple)
+configuration file, you can use the @option{-f} option. For example:
 
 @example
 openocd -f config1.cfg -f config2.cfg -f config3.cfg
 @end example
 
+Configuration files and scripts are searched for in
+...@enumerate
+...@item the current directory,
+...@item any search dir specified on the command line using the @option{-s} 
option,
+...@item @file{$HOME/.openocd} (not on Windows),
+...@item the site wide script library @file{$pkgdatadir/site} and
+...@item the OpenOCD-supplied script library @file{$pkgdatadir/scripts}.
+...@end enumerate
+The first found file with a matching file name will be used.
+
 OpenOCD starts by processing the configuration commands provided
 on the command line or in @file{openocd.cfg}.
 @xref{Configuration Stage}.
@@ -507,7 +517,7 @@ clients (Telnet, GDB, Other) and processes the commands 
issued through
 those channels.
 
 If you are having problems, you can enable internal debug messages via
-the ``-d'' option.
+the @option{-d} option.
 
 Also it is possible to interleave JIM-Tcl commands w/config scripts using the
 @option{-c} command line switch.
@@ -523,10 +533,6 @@ setting from within a telnet or gdb session using 
@command{debug_level
 You can redirect all output from the daemon to a file using the
 @option{-l <logfile>} switch.
 
-Search paths for config/script files can be added to OpenOCD by using
-the @option{-s <search>} switch. The current directory and the OpenOCD
-target library is in the search path by default.
-
 For details on the @option{-p} option. @xref{Connecting to GDB}.
 
 Note! OpenOCD will launch the GDB & telnet server even if it can not
diff --git a/src/helper/options.c b/src/helper/options.c
index 5792e11..438fb94 100644
--- a/src/helper/options.c
+++ b/src/helper/options.c
@@ -101,7 +101,18 @@ static void add_default_dirs(void)
         * listed last in the built-in search order, so the user can
         * override these scripts with site-specific customizations.
         */
-       /// @todo Implement @c add_script_search_dir("${HOME}/.openocd").
+
+       const char *home = getenv("HOME");
+
+       if (home) {
+               const char *suffix = "/.openocd";
+               char path[strlen(home) + strlen(suffix) + 1];
+
+               strcpy(path, home);
+               strcat(path, suffix);
+               add_script_search_dir(path);
+       }
+
        add_script_search_dir(PKGDATADIR "/site");
        add_script_search_dir(PKGDATADIR "/scripts");
 #endif
-- 
1.6.3.3

_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to