#! /bin/sh

# Configure ARM/PID eCos to create PID GDB stubs
# Ensure that PATH include the directory where the ARM tools reside.
#
# Run from an empty temporary directory with two arguments: the path to
# the packages directory (i.e., where pkgconf.tcl lives), and the platform
# name (pid or pid9).
# If a big-endian stub is required, use the name 'pidBE'
#
# Output files are in the directory hal/arm/pid/<version>/misc.
#  gdb_module.img: suitable for programming via GDB stub/Angel
#  gdb_module.bin: suitable for programming with an EPROM programmer
# See Notes for details.

if [ "$2"x = "x" ]; then
  PID="pid"
else
  PID=$2
fi

if ( echo | tclsh ) 2>/dev/null ; then
  TCL=tclsh
elif ( echo | cygtclsh80 ) 2>/dev/null ; then
  TCL=cygtclsh80
else
  echo Could not find TCL interpreter
  exit 1
fi

$TCL $1/pkgconf.tcl                                         \
   --target=arm --platform=${PID} --startup=stubs                      \
   --disable CYGPKG_KERNEL --disable CYGPKG_UITRON                     \
   --disable CYGPKG_LIBC --disable CYGPKG_LIBM                         \
   --disable CYGPKG_ERROR --disable CYGPKG_IO                          \
   --disable CYGPKG_IO_SERIAL --disable CYGPKG_DEVICES_WALLCLOCK       \
   --disable CYGPKG_DEVICES_WATCHDOG

patch <<END_OF_PATCH -p0
--- pkgconf/hal.h       1999/11/21 14:48:03     1.66
+++ pkgconf/hal.h       1999/12/15 21:48:53
@@ -118,11 +118,11 @@
          diagnostic I/O because of the environment.  This option
          allows for an explicit override in these cases."
  }
 
  }}CFG_DATA */
-#define CYGFUN_HAL_COMMON_KERNEL_SUPPORT
+#undef CYGFUN_HAL_COMMON_KERNEL_SUPPORT
 #undef  CYGDBG_HAL_DIAG_DISABLE_GDB_PROTOCOL
 
 #ifdef CYGDBG_HAL_DIAG_DISABLE_GDB_PROTOCOL
 #if !defined(CYGPKG_HAL_ARM)
 #err GDB protocol cannot be explicitly disabled for this platform.
@@ -424,14 +424,14 @@
          to support multi-threaded source level debugging."
  }
 
    }}CFG_DATA */
 
-#undef   CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+#define  CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
 #undef   CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
-#define  CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT
-#define  CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT
+#undef   CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT
+#undef   CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT
 
 /*
  * NOTE:
  *
  * Right now there is no easy way to express the ROM monitor options
END_OF_PATCH

make
make misc
