From 2c4f5e1229f7ff7cfea35355a116f53546726e73 Mon Sep 17 00:00:00 2001
From: Alex Bennee <alex@bennee.com>
Date: Thu, 13 Nov 2008 19:56:06 +0000
Subject: [PATCH] Make /.rockbox a configurable path

While the bootloader is hard coded to look for .rockbox we do have the ability
to run additional firmware files from the File Browser. However they will most
likely fail unless you have unziped the while new build ontop of the old one.

This patch adds the ability to specify a different root. This is useful for
testing. It also means any messing around or config hacking you do won't
impact your normal working install. You just won't be able to boot directly
into such a firmware.
---
 apps/settings.h |    9 +++++++--
 tools/configure |   18 ++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/apps/settings.h b/apps/settings.h
index 8448059..c5658aa 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -57,10 +57,15 @@ struct opt_items {
 #define ROCKBOX_DIR "."
 #define ROCKBOX_DIR_LEN 1
 #else
-#define ROCKBOX_DIR "/.rockbox"
-#define ROCKBOX_DIR_LEN 9
+
+/* ROCKBOX_DIR is now defined in autoconf.h for flexible build types */
+#ifndef ROCKBOX_DIR
+#error ROCKBOX_DIR not defined (should be in autoconf.h)
+#endif
+#define ROCKBOX_DIR_LEN sizeof(ROCKBOX_DIR)
 #endif
 
+
 #define FONT_DIR    ROCKBOX_DIR "/fonts"
 #define LANG_DIR    ROCKBOX_DIR "/langs"
 #define WPS_DIR     ROCKBOX_DIR "/wps"
diff --git a/tools/configure b/tools/configure
index a817f5d..ac6a649 100755
--- a/tools/configure
+++ b/tools/configure
@@ -15,6 +15,8 @@ use_logf="#undef ROCKBOX_HAS_LOGF"
 
 scriptver=`echo '$Revision$' | sed -e 's:\\$::g' -e 's/Revision: //'`
 
+rbdir="/.rockbox"
+
 #
 # Begin Function Definitions
 #
@@ -607,6 +609,13 @@ cat <<EOF
 
     --type=TYPE       Sets the build type. The shortcut is also valid.
                       Run without this option to see available types.
+
+    --rbdir=dir       Set the device install dir (default:${rbdir}).
+                      This is useful for having multiple alternate builds on your
+                      device that you can run with ROLO.  However as the bootcode
+                      is hardcoded to look for .rockbox you wouldn't be able to
+                      use such a build as your "master" rockbox.
+
     --ccache          Enable ccache use (done by default these days)
     --no-ccache       Disable ccache use
     --help            Shows this message (must not be used with other options)
@@ -2282,11 +2291,17 @@ else
   defendian="ROCKBOX_LITTLE_ENDIAN"
 fi
 
+if [ "1" != `parse_args --rbdir` ]; then
+  rbdir=`parse_args --rbdir`;
+  echo "Using alternate rockbox dir:${rbdir}"
+fi
+
 sed > autoconf.h \
  -e "s,@ENDIAN@,${defendian},g" \
  -e "s,^#undef ROCKBOX_HAS_LOGF,$use_logf,g" \
  -e "s,@config_rtc@,$config_rtc,g" \
  -e "s,@have_rtc_alarm@,$have_rtc_alarm,g" \
+ -e "s,@RBDIR@,${rbdir},g" \
 <<EOF
 /* This header was made by configure */
 #ifndef __BUILD_AUTOCONF_H
@@ -2302,6 +2317,9 @@ sed > autoconf.h \
 @config_rtc@
 @have_rtc_alarm@
 
+/* root of Rockbox */
+#define ROCKBOX_DIR "@RBDIR@"
+
 #endif /* __BUILD_AUTOCONF_H */
 EOF
 
-- 
1.5.6.4

