Index: contrib/mingw/ChangeLog
===================================================================
--- contrib/mingw/ChangeLog	(revision e4a22331c63fcbb49592301cd7a6620c80dd9593)
+++ contrib/mingw/ChangeLog	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -1,2 +1,12 @@
+2007-07-28	Chris Johns <chisj@rtems.org>
+	* README, build-rpms.sh, rtems.ini, build-exes.sh,
+	rtems-tools.nsi: Updated to the new 4.8 build plus a new
+	installer.
+
+	* autoconf.def, automake.def, ba-wrap.sh, build-autotools.sh,
+	msys-path.nsi, rtems-autotools.nsi, target-section-text,
+	upload.sh, version: New to version 4.8. Autotools is built when
+	installing.
+
 2007-05-21	Joel Sherrill <joel.sherrill@oarcorp.com>
 
Index: contrib/mingw/README
===================================================================
--- contrib/mingw/README	(revision e4a22331c63fcbb49592301cd7a6620c80dd9593)
+++ contrib/mingw/README	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -1,4 +1,4 @@
 
-    Copyright (C) 2006	Chris Johns, Sydney, Australia <chrisj@rtems.org>
+    Copyright (C) 2006-2007 Chris Johns, Sydney, Australia <chrisj@rtems.org>
 
     This program is free software; you can redistribute it and/or modify
@@ -17,2 +17,64 @@
 
 
+To build mingw32 tools on a Fedora Core 7 box:
+
+1. Add makensis to your path.
+
+   $ export PATH=/opt/nsis/2.29/bin:$PATH
+
+2. Set up the RPM packages:
+
+   $ cat ~/.rpmrc
+   os_canon: mingw32: mingw32 23
+   arch_canon: mingw32: i686 1
+   arch_compat: mingw32: i686 noarch
+   buildarch_compat: mingw32: i686 noarch
+   optflags: mingw32 -O2 -g
+   optflags: i686 -O2 -pipe
+   $ cat ~/.rpmmacros
+   %_topdir /home2/work/chris/rtems/4.8/packages
+   %_tmppath /home2/work/chris/tmp/rtems
+   %_rpmdir        %_topdir/%_target_os/RPMS
+   %_srcrpmdir     %_topdir/%_target_os/SRPMS
+   %_signature gpg
+   # %_gpg_path ~/.gnupg
+   # %_gpg_name "RTEMS Packager"
+   %_gpg_name rtems
+   %vendor: RTEMS Project
+   %packager chrisj@rtems.org
+   %distribution RTEMS Project http://www.rtems.org/
+   $ mkdir -p /home2/work/chris/rtems/4.8/packages
+   $ mkdir /home2/work/chris/rtems/4.8/packages/SOURCES
+   $ mkdir /home2/work/chris/rtems/4.8/packages/BUILD
+   $ mkdir -p /home2/work/chris/rtems/4.8/packages/linux/SRPMS
+   $ mkdir -p /home2/work/chris/rtems/4.8/packages/linux/RPMS
+   $ mkdir -p /home2/work/chris/rtems/4.8/packages/mingw32/SRPMS
+   $ mkdir -p /home2/work/chris/rtems/4.8/packages/mingw32/RPMS
+   $ cp /home2/work/chris/rtems/4.8/head/contrib/crossrpms/patches/* \
+        /home2/work/chris/rtems/4.8/packages/SOURCES/.
+
+   Download the required sources to:
+
+     /home2/work/chris/rtems/4.8/packages/SOURCES
+
+   The list you need depends on what version you build. A tool exists
+   that atempts to determine the package. Ask on the list for it.
+
+2. Run the build.sh script where:
+
+    -d            : debug output from the script and nested scripts
+    -h host       : the host to buidl for
+    -p prefix     : the prefix (not that important for mingw)
+    -s crossrpms  : the path to the crossrpms source tree
+    -r relocation : the path for the NSIS installer executables
+
+   $ export PATH=/opt/rtems-4.8/bin:$PATH
+   $ cd /home2/work/chris/rtems/4.8/head/contrib/crossrpms
+   $ ./bootstrap
+   $ cd /home2/work/chris/rtems/4.8/head/contrib/mingw
+   $ ./build.sh -d -h mingw32 \
+         -p /home2/work/chris/rtems/4.8/build/rpms \
+         -s /home2/work/chris/rtems/4.8/head/contrib/crossrpms \
+         -r /home2/work/chris/rtems/4.8/build/mingw
+
+   Sit back and wait. The build take a long time on a fast machine.
Index: contrib/mingw/autoconf.def
===================================================================
--- contrib/mingw/autoconf.def	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
+++ contrib/mingw/autoconf.def	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -0,0 +1,4 @@
+package_name=autoconf-2.61
+package_source=$package_name.tar.bz2
+package_taropts=jxf
+package_patches=autoconf-20070411-cross-test-x.patch
Index: contrib/mingw/automake.def
===================================================================
--- contrib/mingw/automake.def	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
+++ contrib/mingw/automake.def	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -0,0 +1,4 @@
+package_name=automake-1.10
+package_source=$package_name.tar.bz2
+package_taropts=jxf
+package_patches=
Index: contrib/mingw/ba-wrap.sh
===================================================================
--- contrib/mingw/ba-wrap.sh	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
+++ contrib/mingw/ba-wrap.sh	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -0,0 +1,15 @@
+#! /bin/sh
+source=$(dirname $0)
+if [ "$source" = "." ]; then
+  source=$(pwd)
+fi
+echo
+echo "             DO NOT CLOSE    DO NOT CLOSE"
+echo
+echo "Warning: this command window will automatically close."
+echo
+echo "Build output: $source/at-log.txt"
+echo
+$source/build-autotools.sh $* 2>&1 >> $source/at-log.txt
+ec=$?
+exit $ec
Index: contrib/mingw/build-autotools.sh
===================================================================
--- contrib/mingw/build-autotools.sh	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
+++ contrib/mingw/build-autotools.sh	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -0,0 +1,281 @@
+#! /bin/sh
+
+terminate()
+{
+  echo "error: $*" >&2
+  if [ $? -eq 0 ]; then
+    exit 222
+  fi
+  exit $?
+}
+
+check()
+{
+  if [ $? -ne 0 ]; then
+    terminate $*
+  fi
+}
+
+source=$(dirname $0)
+
+if [ "$source" = "." ]; then
+  source=$(pwd)
+fi
+
+build=none
+clean=no
+prefix=none
+
+while [ $# -gt 0 ];
+do
+  case $1 in
+    -b)
+      shift
+      build=$1
+      ;;
+    -c)
+      shift
+      config=$1
+      ;;
+    -d)
+      set -x
+      ;;
+    -h)
+      usage
+      exit 223
+      ;;
+    -p)
+      shift
+      prefix=$1
+      ;;
+    -s)
+      shift
+      source=$1
+      ;;
+    *)
+      terminate "invalid option (try -h): $1"
+      ;;
+  esac
+  shift
+done
+
+#
+# dirdepth: find the depth of a directory
+#
+# $1 : path
+#
+dirdepth()
+{
+  local depth=0
+  local p=$1
+  p=$(echo $p | sed -e "s/^\///g")
+  p=$(echo $p | sed -e "s/\/$//g")
+  while [ $p != . ];
+  do
+    depth=$(expr $depth + 1)
+    p=$(dirname $p)
+  done
+  echo $depth
+}
+
+#
+# build_package()
+#
+# $1 : package
+# $2 : package source
+# $3 : tar options
+# $4 : patch list
+#
+build_package()
+{
+  local mydir=$(pwd)
+
+  if [ ! -f $source/$2 ]; then
+    terminate "$1 source is not present or not a file: $2"
+  fi
+
+  for p in $4
+  do
+    if [ ! -f $source/$p ]; then
+      terminate "$1 patch is not present or not a file: $p"
+    fi
+  done
+
+  echo "cd $build"
+  cd $build
+  check "changing to $build directory"
+
+  echo "tar $3 $source/$2"
+  tar $3 $source/$2
+  check "extraction of source: $2"
+
+  echo "cd $build/$1"
+  cd $build/$1
+  check "changing to $build/$1 directory"
+
+  for p in $4
+  do
+    echo "patch -p0 < $source/$p"
+    patch -p0 < $source/$p
+    check "patching $autoconf with $p"
+  done
+
+  echo "cd $build"
+  cd $build
+  check "changing to $build directory"
+
+  echo "rm -rf mingw32-$1"
+  rm -rf mingw32-$1
+  check "removing mingw32-$1 build directory"
+
+  echo "mkdir mingw32-$1"
+  mkdir mingw32-$1
+  check "creating mingw32-$1"
+
+  echo "cd $build/mingw32-$1"
+  cd $build/mingw32-$1
+  check "changing to $build/mingw32-$1"
+
+  echo "$build/$1/configure --prefix=$prefix"
+  $build/$1/configure --prefix=$prefix
+  check "configuring $1"
+
+  echo "make"
+  make
+  check "building $1"
+
+  echo "make DESTDIR=$build/install-$1 install"
+  make DESTDIR=$build/install-$1 install
+  check "installing to $build/install-$1"
+
+  echo find $build/install-$1$prefix -type f
+  local files=$(find $build/install-$1$prefix -type f)
+  check "reading $1 file list"
+
+  of=$prefix/Uninstall/$1-files
+  echo "b install-$1$prefix" | sed -e "s/\//\\\\/g" >> $of
+
+  re_path=$(echo $build/install-$1$prefix/ | sed -e 's/\//\\\//g' -e 's/\./\\\./g')
+
+  dirs=
+  for f in $files
+  do
+    if [ $(basename $f) = dir ]; then
+      continue
+    fi
+    f=$(echo $f | sed -e "s/$re_path//g")
+    found=no
+    fd=$(dirname $f)
+    for d in $dirs
+    do
+      if [ $d = $fd ]; then
+        found=yes
+        break;
+      fi
+    done
+    if [ $found = no ]; then
+      echo "d $fd" | sed -e "s/\//\\\\/g" >> $of
+      dirs="$fd $dirs"
+    fi
+    echo "f $f" | sed -e "s/\//\\\\/g" >> $of
+  done
+
+  for d in $dirs
+  do
+    while [ $d != . ]
+    do
+      found=no
+      for rd in $dirs
+      do
+        if [ "$d" = "$rd" ]; then
+          found=yes
+          break
+        fi
+      done
+      if [ $found = no ]; then
+        dirs="$dirs $d"
+      fi
+      d=$(dirname $d)
+    done
+  done
+
+  sorted_dirs=
+  for d in $dirs
+  do
+    depth=$(dirdepth $d)
+    nsp=
+    for sd in $sorted_dirs
+    do
+      if [ ! -z "$d" ]; then
+        spd=$(dirdepth $sd)
+        if [ $depth -ge $spd ]; then
+          sd="$d $sd"
+          d=
+        fi
+      fi
+      nsp="$nsp $sd"
+    done
+    if [ ! -z "$d" ]; then
+      nsp="$nsp $d"
+    fi
+    sorted_dirs=$nsp
+  done
+
+  for d in $sorted_dirs
+  do
+    echo "D $d" | sed -e "s/\//\\\\/g" >> $of
+  done
+
+  echo "cd $mydir"
+  cd $mydir
+  check "changing to $mydir"
+}
+
+munch_path()
+{
+  local p=$1
+  if [ $(echo $p | sed -e "s/[a-zA-Z]:.*/yes/g") = yes ]; then
+    p=$(echo $p | sed -e "s/^[a-zA-Z]:/\/\0/g" -e "s/://g")
+  fi
+  echo $p
+}
+
+if [ $build = none ]; then
+  terminate "no build specified (try -h)"
+fi
+
+if [ $prefix = none ]; then
+  terminate "no prefix specified (try -h)"
+fi
+
+source=$(munch_path $source)
+build=$(munch_path $build)
+prefix=$(munch_path $prefix)
+config=$(munch_path $config)
+
+if [ ! -d $build ]; then
+  terminate "build path is not a directory or does not exist: $build"
+fi
+
+if [ ! -d $prefix ]; then
+  terminate "prefix path is not a directory or does not exist: $prefix"
+fi
+
+if [ ! -f $config ]; then
+  terminate "could find package configuration file: $config"
+fi
+
+. $config
+
+# Need to handle paths carefully as a problem seems to exist
+# with autoconf when it is in the path.
+if [ $(echo $package_name | sed -e "s/autoconf-.*/yes/g") != yes ]; then
+ export PATH=$prefix/bin:$PATH
+fi
+
+build_package $package_name \
+              $package_source \
+              $package_taropts \
+              "$package_patches"
+
+exit $?
Index: contrib/mingw/build-exes.sh
===================================================================
--- contrib/mingw/build-exes.sh	(revision e4a22331c63fcbb49592301cd7a6620c80dd9593)
+++ contrib/mingw/build-exes.sh	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -5,7 +5,9 @@
 # RTEMS Build Executable Installers script.
 #
-# This script takes the RPM files built using the crossrpms/build-rpms.sh
+# This script takes the RPM files built using the mingw/build-rpms.sh
 # script.
 #
+
+echo $*
 
 source=$(dirname $0)
@@ -24,12 +26,15 @@
 }
 
-version=4.7
-tool_build=3
+. $source/version
 
 target_list=$(cat $source/targets)
 
+. $source/target-section-text
+
 mingw32_cpu_list="i686"
 
 rpm_topdir=$(rpm --eval "%{_topdir}")
+
+rtems_url="http://www.rtems.org/ftp/pub/rtems/windows/${version}/build-${tool_build}"
 
 common_label="common"
@@ -38,4 +43,7 @@
 run_prefix=
 relocation=
+rpm_install=yes
+
+package_source=$(cat $HOME/.rpmmacros | grep "^%_topdir" | sed -e "s/^.* //g")/SOURCES
 
 if [ "$source" = "." ]; then
@@ -48,4 +56,7 @@
   -d)
    set -x
+   ;;
+  -i)
+   rpm_install=no
    ;;
   -l)
@@ -106,4 +117,10 @@
 fi
 
+#
+# Get the RPM list given the architecture and the package.
+#
+# $1 - architecture
+# $2 - package
+#
 get_rpm_list()
 {
@@ -114,36 +131,49 @@
 
 #
-# Handle each type of host processor.
-#
-for p in $mingw32_cpu_list
-do
- common_rpms="$(get_rpm_list noarch auto) $(get_rpm_list $p $common_label)"
- check "getting the autotools and common RPM list"
-
- rpm_options="--ignoreos --force --nodeps --noorder "
-
- for t in $targets
- do
+# Create the installer given the architecture and package.
+#
+# $1 - architecture/processor
+# $2 - package
+# $3 - package name
+create_installer()
+{
+  local p=$1
+  local t=$2
+  local n=$3
+
+  rpm_options="--ignoreos --force --nodeps --noorder "
+
   rpms=$(get_rpm_list $p $t)
-  check "getting the RPM list"
+  check "getting the $n RPM list"
+
   if [ -n "$rpms" ]; then
-   echo "Clean the relocation directory"
-   $rm -rf $relocation
-   check "removing the relocation directory: $relocation"
-
-   for r in $common_rpms $rpms
-   do
-    echo "rpm $rpm_database --relocate $prefix=$relocation $rpm_options -i $r"
-    $rpm $rpm_database --relocate $prefix=$relocation $rpm_options -i $r
-    check "installing rpm: $r"
-   done
-
-   files=$(find $relocation -type f | sed -e "s/^$(echo ${relocation} | sed 's/\//\\\//g')//" -e "s/^\///" | sort)
-
-   echo "$files" > $relocation/files.txt
-
+   treloc=$relocation/$n
+   echo "Relocation path: $treloc"
+
+   if [ $rpm_install = yes ]; then
+    echo "Clean the relocation directory: $treloc"
+    $rm -rf $treloc
+    check "removing the relocation directory: $treloc"
+
+    for r in $rpms
+    do
+     echo "rpm $rpm_database --relocate $prefix=$treloc $rpm_options -i $r"
+     $rpm $rpm_database --relocate $prefix=$treloc $rpm_options -i $r
+     check "installing rpm: $r"
+    done
+   fi
+
+   files=$(find $treloc -type f -a -not \( -name \*.gch \
+                                        -o -name rtems.nsi \
+                                        -o -name rtems-files.nsi \
+                                        -o -name rtems.ini \
+                                        -o -name files.txt \) | \
+           sed -e "s/^$(echo ${treloc} | sed 's/\//\\\//g')//" -e "s/^\///" | sort)
    check "find the file list"
 
-   of=$relocation/rtems-files.nsi
+   echo "$files" > $treloc/files.txt
+   check "write the file list"
+
+   of=$treloc/rtems-files.nsi
 
    echo "!macro RTEMS_INSTALL_FILES" > $of
@@ -160,5 +190,5 @@
      install_dir=$d
     fi
-    echo "  File \"$relocation/$f\"" >> $of
+    echo "  File \"$treloc/$f\"" >> $of
    done
 
@@ -169,16 +199,50 @@
    echo " !ifndef EMPTY_INSTALLER" >> $of
 
+   #
+   # Get a list of directories so we can delete them once all
+   # the files have been deleted. We need to be selective as
+   # the directory maybe used by another installer.
+   #
+   # Once we get a list we need to also add the path down
+   # to that node and then sort them so we work from bottom up.
+   #
+
    remove_dirs=
-   remove_dir=
 
    for f in $files
    do
     d=$(dirname $f)
-    if [ "$remove_dir" != "$d" ]; then
+    found=no
+    for rd in $remove_dirs
+    do
+     if [ "$d" = "$rd" ]; then
+      found=yes
+      break;
+     fi
+    done
+    if [ $found = no ]; then
      remove_dirs="$remove_dirs $d"
-     remove_dir=$d
     fi
     rf=$(echo $f | sed -e 's/\//\\/g' -e 's/\/$//')
     echo "  Delete \"\$INSTDIR\\$rf\"" >> $of
+   done
+
+   for d in $remove_dirs
+   do
+    while [ $d != . ]
+    do
+     found=no
+     for rd in $remove_dirs
+     do
+      if [ "$d" = "$rd" ]; then
+       found=yes
+       break
+      fi
+     done
+     if [ $found = no ]; then
+      remove_dirs="$remove_dirs $d"
+     fi
+     d=$(dirname $d)
+    done
    done
 
@@ -202,21 +266,33 @@
    check "make the RTEMS binary install point: $rtems_binary"
 
-   of=$relocation/rtems.nsi
-   echo "!define RTEMS_TARGET \"$t\"" > $of
+   outfile=rtems$version-tools-$n-$tool_build.exe
+
+   of=$treloc/rtems.nsi
+   echo "!define RTEMS_TARGET \"$n\"" > $of
    echo "!define RTEMS_VERSION \"$version\"" >> $of
    echo "!define RTEMS_BUILD_VERSION \"$tool_build\"" >> $of
    echo "!define RTEMS_PREFIX \"rtems-tools\"" >> $of
    echo "!define RTEMS_SOURCE \"$source\"" >> $of
-   echo "!define RTEMS_RELOCATION \"$relocation\"" >> $of
+   echo "!define RTEMS_RELOCATION \"$treloc\"" >> $of
    echo "!define RTEMS_LOGO \"$source/rtems_logo.bmp\"" >> $of
    echo "!define RTEMS_BINARY \"$rtems_binary\"" >> $of
    echo "!define RTEMS_LICENSE_FILE \"$source/rtems-license.rtf\"" >> $of
+   echo "!define RTEMS_OUTFILE \"$outfile\"" >> $of
    echo "!define TOOL_PREFIX \"$prefix\"" >> $of
-   echo "!include \"$relocation/rtems-files.nsi\"" >> $of
+
+   if [ $n = $common_label ]; then
+     echo "!define COMMON_FILES" >> $of
+   fi
+
+   echo "!include \"$treloc/rtems-files.nsi\"" >> $of
    echo "!include \"$source/rtems-tools.nsi\"" >> $of
 
-   echo "cp $source/rtems.ini $relocation/rtems.ini"
-   $cp $source/rtems.ini $relocation/rtems.ini
-   check "coping the dialog definition file: $relocation/rtems.ini"
+   if [ $n = $common_label ]; then
+     echo "!include \"$relocation/rtems-sections.nsi\"" >> $of
+   fi
+
+   echo "cp $source/rtems.ini $treloc/rtems.ini"
+   $cp $source/rtems.ini $treloc/rtems.ini
+   check "coping the dialog definition file: $treloc/rtems.ini"
 
    echo "makensis $of"
@@ -224,5 +300,165 @@
    check "making the installer: $of"
 
+   if [ $n != $common_label ]; then
+     of=$relocation/rtems-sections.nsi
+     tst=${t}_section_text
+     echo "" >> $of
+     echo "; Target: $t" >> $of
+     echo "Section \"${!tst}\" Section_$t" >> $of
+     echo " StrCpy \$1 \$EXEDIR\\$outfile" >> $of
+     echo " DetailPrint \"Checking for \$1\"" >> $of
+     echo " IfFileExists \$1 ${t}_found" >> $of
+     echo " StrCpy \$1 \$INSTDIR\\Packages\\$outfile" >> $of
+     echo " DetailPrint \"Checking for \$1\"" >> $of
+     echo " IfFileExists \$1 ${t}_found" >> $of
+     echo "  SetOutPath \"\$INSTDIR\\Packages\"" >> $of
+     echo "  DetailPrint \"Downloading $rtems_url/$outfile\"" >> $of
+     echo "  NSISdl::download $rtems_url/$outfile $outfile" >> $of
+     echo "  Pop \$R0" >> $of
+     echo "  StrCmp \$R0 \"success\" ${t}_found_2 ${t}_not_found_2" >> $of
+     echo " ${t}_not_found_2:" >> $of
+     echo "   SetDetailsView show" >> $of
+     echo "   DetailPrint \"Download failed: \$R0\"" >> $of
+     echo "   MessageBox MB_OK \"Download failed: \$R0\"" >> $of
+     echo "   Goto ${t}_done" >> $of
+     echo " ${t}_found_2:" >> $of
+     echo "   Strcpy \$1 \"\$INSTDIR\\Packages\\$outfile\"" >> $of
+     echo " ${t}_found:" >> $of
+     echo "  DetailPrint \"Installing: \$1\"" >> $of
+     echo "  ExecWait '\"\$1\" /S'" >> $of
+     echo "  BringToFront" >> $of
+     echo " ${t}_done:" >> $of
+     echo "SectionEnd" >> $of
+   else
+     echo "Section -SecCommon" >> $of
+     echo " SetOutPath \"\$INSTDIR"\" >> $of
+     echo " File \"\${RTEMS_SOURCE}/AUTHORS"\" >> $of
+     echo " File \"\${RTEMS_SOURCE}/COPYING\"" >> $of
+     echo " File \"\${RTEMS_SOURCE}/README\"" >> $of
+     echo "SectionEnd" >> $of
+   fi
   fi
+}
+
+create_autotools_installer()
+{
+  local p=$1
+  local t=$2
+  local n=$3
+
+  treloc=$relocation/$n
+  echo "Relocation path: $treloc"
+
+  echo "Clean the relocation directory: $treloc"
+  $rm -rf $treloc
+  check "removing the relocation directory: $treloc"
+  mkdir -p $treloc
+  check "creating relocation directory: $treloc"
+
+  rtems_binary=$rpm_topdir/mingw32/exe/$p
+  echo "mkdir -p $rtems_binary"
+  $mkdir -p $rtems_binary
+  check "make the RTEMS binary install point: $rtems_binary"
+
+  outfile=rtems$version-tools-$n-$tool_build.exe
+
+  of=$treloc/rtems.nsi
+  echo "!define RTEMS_TARGET \"$n\"" > $of
+  echo "!define RTEMS_VERSION \"$version\"" >> $of
+  echo "!define RTEMS_BUILD_VERSION \"$tool_build\"" >> $of
+  echo "!define RTEMS_PREFIX \"rtems-tools\"" >> $of
+  echo "!define RTEMS_SOURCE \"$source\"" >> $of
+  echo "!define RTEMS_PACKAGE_SOURCE \"$package_source\"" >> $of
+  echo "!define RTEMS_LOGO \"$source/rtems_logo.bmp\"" >> $of
+  echo "!define RTEMS_BINARY \"$rtems_binary\"" >> $of
+  echo "!define RTEMS_LICENSE_FILE \"$source/rtems-license.rtf\"" >> $of
+  echo "!define RTEMS_OUTFILE \"$outfile\"" >> $of
+  echo "!define TOOL_PREFIX \"$prefix\"" >> $of
+
+  . $source/autoconf.def
+
+  echo "!define RTEMS_AUTOCONF \"$package_name\"" >> $of
+  echo "!define RTEMS_AUTOCONF_SOURCE \"$package_source\"" >> $of
+  echo "!macro RTEMS_AUTOCONF_PATCHES" >> $of
+  for p in $package_patches
+  do
+    echo " File \"\${RTEMS_PACKAGE_SOURCE}/$p\"" >> $of
+  done
+  echo "!macroend" >> $of 
+
+  echo "!macro RTEMS_DELETE_AUTOCONF_PATCHES" >> $of
+  for p in $package_patches
+  do
+    echo " Delete \"\$INSTDIR\\Packages\\Source\\$p\"" >> $of
+  done
+  echo "!macroend" >> $of 
+
+  . $source/automake.def
+
+  echo "!define RTEMS_AUTOMAKE \"$package_name\"" >> $of
+  echo "!define RTEMS_AUTOMAKE_SOURCE \"$package_source\"" >> $of
+  echo "!macro RTEMS_AUTOMAKE_PATCHES" >> $of
+  for p in $package_patches
+  do
+    echo " File \"\${RTEMS_PACKAGE_SOURCE}/$p\"" >> $of
+  done
+  echo "!macroend" >> $of 
+
+  echo "!macro RTEMS_DELETE_AUTOMAKE_PATCHES" >> $of
+  for p in $package_patches
+  do
+    echo " Delete \"\$INSTDIR\\Packages\\Source\\$p\"" >> $of
+  done
+  echo "!macroend" >> $of 
+
+  echo "!include \"$source/rtems-autotools.nsi\"" >> $of
+
+  echo "cp $source/rtems.ini $treloc/rtems.ini"
+  $cp $source/rtems.ini $treloc/rtems.ini
+  check "coping the dialog definition file: $treloc/rtems.ini"
+
+  echo "makensis $of"
+  $makensis $of
+  check "making the installer: $of"
+
+  of=$relocation/rtems-sections.nsi
+  tst=${t}_section_text
+  echo "" >> $of
+  echo "; Target: $t" >> $of
+  echo "Section \"${!tst}\" Section_$t" >> $of
+  echo " StrCpy \$1 \$EXEDIR\\$outfile" >> $of
+  echo " IfFileExists \$1 ${t}_found" >> $of
+  echo "  SetOutPath \"\$INSTDIR\Packages\"" >> $of
+  echo "  DetailPrint \"Downloading $rtems_url/$outfile\"" >> $of
+  echo "  NSISdl::download $rtems_url/$outfile $outfile" >> $of
+  echo "  Pop \$R0" >> $of
+  echo "  StrCmp \$R0 \"success\" ${t}_found_2 ${t}_not_found_2" >> $of
+  echo " ${t}_not_found_2:" >> $of
+  echo "   SetDetailsView show" >> $of
+  echo "   DetailPrint \"Download failed: \$R0\"" >> $of
+  echo "   MessageBox MB_OK \"Download failed: \$R0\"" >> $of
+  echo "   Goto ${t}_done" >> $of
+  echo " ${t}_found_2:" >> $of
+  echo "   Strcpy \$1 \"\$INSTDIR\\Packages\\$outfile\"" >> $of
+  echo " ${t}_found:" >> $of
+  echo "  DetailPrint \"Installing: \$1\"" >> $of
+  echo "  ExecWait '\"\$1\" /S'" >> $of
+  echo "  BringToFront" >> $of
+  echo " ${t}_done:" >> $of
+  echo "SectionEnd" >> $of
+}
+
+#
+# Handle each type of host processor.
+#
+for p in $mingw32_cpu_list
+do
+ echo "; Components based on each target." > $relocation/rtems-sections.nsi
+ create_autotools_installer noarch auto autotools
+ for t in $targets
+ do
+  create_installer $p $t $t
  done
+ # Must be done last
+ create_installer $p $common_label $common_label
 done
Index: contrib/mingw/build-rpms.sh
===================================================================
--- contrib/mingw/build-rpms.sh	(revision e4a22331c63fcbb49592301cd7a6620c80dd9593)
+++ contrib/mingw/build-rpms.sh	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -31,5 +31,5 @@
 processor=$(uname -p)
 
-version=4.7
+. $source/version
 
 base_tool_list="binutils gcc"
@@ -38,5 +38,5 @@
 host_list="cygwin freebsd5.2 freebsd6.0 freebsd6.1 mingw32"
 
-rtems_tool_list="autoconf automake $base_tool_list"
+rtems_tool_list="autoconf automake $base_tool_list gdb"
 linux_tool_list="autoconf automake $base_tool_list"
 cygwin_tool_list="w32api libs autoconf automake $base_tool_list"
@@ -324,5 +324,5 @@
      autoconf|automake)
       # Hack around the prefix in the spec files for autotools.
-      ba="-ba $prefix/autotools/$rpm_prefix$s-rtems.spec"
+      ba="-ba $prefix/autotools/$rpm_prefix$s.spec"
       ;;
      *)
@@ -351,5 +351,5 @@
     autoconf|automake)
      # Hack around the prefix in the spec files for autotools.
-     ba="-ba $prefix/autotools/$rpm_prefix$s-rtems.spec"
+     ba="-ba $prefix/autotools/$rpm_prefix$s.spec"
      ;;
     *)
Index: contrib/mingw/msys-path.nsi
===================================================================
--- contrib/mingw/msys-path.nsi	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
+++ contrib/mingw/msys-path.nsi	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -0,0 +1,109 @@
+Function MsysPath
+  Push $R0
+  ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MSYS-1.0_is1" "Inno Setup: App Path"
+  Exch $R0
+FunctionEnd
+
+Function MsysDTKPath
+  Push $R0
+  ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MSYS-DTK_is1" "Inno Setup: App Path"
+  Exch $R0
+FunctionEnd
+
+Function MSYSCheckExes
+  Exch $R0
+  DetailPrint "Checking for MSYS $R0\bin\sh.exe."
+  IfFileExists "$R0\bin\sh.exe" +5 0
+   DetailPrint "Could not find $R0\bin\sh.exe."
+   StrCpy $R0 "$R0\bin\sh.exe"
+   Exch $R0
+   Return
+  DetailPrint "Checking for MSYS $R0\bin\m4.exe."
+  IfFileExists "$R0\bin\m4.exe" +5 0
+   DetailPrint "Could not find $R0\bin\m4.exe."
+   StrCpy $R0 "$R0\bin\m4.exe"
+   Exch $R0
+   Return
+  DetailPrint "Checking for MSYS $R0\bin\perl.exe."
+  IfFileExists "$R0\bin\perl.exe" +5 0
+   DetailPrint "Could not find $R0\bin\perl.exe."
+   StrCpy $R0 "$R0\bin\perl.exe"
+   Exch $R0
+   Return
+  StrCpy $R0 "ok"
+  Exch $R0
+FunctionEnd
+
+Function MSYSDetect
+  Push $R0
+  Push $R1
+  StrCpy $R1 "c:\msys\1.0"
+  DetailPrint "Checking MSYS default install path: $R1"
+  Push $R1
+  Call MSYSCheckExes
+  Pop $R0
+  StrCmp $R0 "ok" Found
+  DetailPrint "Checking Registry for MSYS Installed Path"
+  Call MsysPath
+  Pop $R0
+  ifErrors 0 +3
+   MessageBox MB_OK "MSYS Not Installed. Please install MSYS."
+   Abort
+  DetailPrint "Checking Registry for MSYS DTK Installed Path"
+  Call MsysDTKPath
+  Pop $R1
+  ifErrors 0 +3
+   MessageBox MB_OK "MSYS DTK Not Installed. Please install MSYS DTK."
+   Abort
+  StrCmp $R0 $R1 +3 0
+   MessageBox MB_OK "MSYS and MSYS DTK installed to different paths. This is not supported."
+   Abort
+  Push $R0
+  Call MSYSCheckExes
+  Pop $R0
+  StrCmp $R0 "ok" Found
+   MessageBox MB_OK "MSYS Executable '$R0' not found. Please install."
+   Abort
+ Found:
+  StrCpy $R0 $R1
+  DetailPrint "MSYS Found: $R0"
+  Pop $R1
+  Exch $R0
+FunctionEnd
+
+Function MSYSDetectSilent
+  Push $R0
+  Push $R1
+  StrCpy $R1 "c:\msys\1.0"
+  DetailPrint "Checking MSYS default install path: $R1"
+  Push $R1
+  Call MSYSCheckExes
+  Pop $R0
+  StrCmp $R0 "ok" Done
+  DetailPrint "Checking Registry for MSYS Installed Path"
+  Call MsysPath
+  Pop $R0
+  ifErrors 0 +3
+   StrCpy $R1 "not-found"
+   Goto Done
+  DetailPrint "Checking Registry for MSYS DTK Installed Path"
+  Call MsysDTKPath
+  Pop $R1
+  ifErrors 0 +3
+   StrCpy $R1 "not-found"
+   Goto Done
+  StrCmp $R0 $R1 +3 0
+   StrCpy $R1 "not-found"
+   Goto Done
+  Push $R0
+  Call MSYSCheckExes
+  Pop $R0
+  StrCmp $R0 "ok" Done
+   StrCpy $R1 "not-found"
+   Goto Done
+ Done:
+  StrCpy $R0 $R1
+  DetailPrint "MSYS Result: $R0"
+  Pop $R1
+  Exch $R0
+FunctionEnd
Index: contrib/mingw/rtems-autotools.nsi
===================================================================
--- contrib/mingw/rtems-autotools.nsi	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
+++ contrib/mingw/rtems-autotools.nsi	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -0,0 +1,391 @@
+;
+; $Id$
+;
+; RTEMS Autotools Installer.
+;
+; Copyright Chris Johns (chrisj@rtems.org)
+;
+
+;!define EMPTY_INSTALLER
+
+!define PRODUCT_NAME      "RTEMS Autotools"
+!define PRODUCT_VERSION   ${RTEMS_VERSION}
+!define PRODUCT_PUBLISHER "RTEM Project Team"
+!define PRODUCT_WEB_SITE  "http://www.rtems.org/"
+
+; MUI 1.66 compatible ------
+!include "MUI.nsh"
+
+; MUI Settings
+!define MUI_ABORTWARNING
+!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\win-install.ico"
+!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\win-uninstall.ico"
+
+!define MUI_HEADERIMAGE
+!define MUI_HEADERIMAGE_BITMAP "${RTEMS_LOGO}"
+
+!define MUI_COMPONENTSPAGE_SMALLDESC
+
+; Welcome page
+!insertmacro MUI_PAGE_WELCOME
+; Details of what will happen.
+Page custom RTEMSMessage
+; License page
+;!define MUI_LICENSEPAGE_CHECKBOX
+!insertmacro MUI_PAGE_LICENSE "${RTEMS_LICENSE_FILE}"
+; Components page
+!insertmacro MUI_PAGE_COMPONENTS
+; Directory page
+!insertmacro MUI_PAGE_DIRECTORY
+; Instfiles page
+!insertmacro MUI_PAGE_INSTFILES
+; Finish page
+!insertmacro MUI_PAGE_FINISH
+
+; Uninstaller pages
+!insertmacro MUI_UNPAGE_INSTFILES
+
+; Language files
+!insertmacro MUI_LANGUAGE "English"
+
+; Reserve files
+!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
+
+; MUI end ------
+
+ReserveFile "rtems.ini"
+!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
+
+Name "${PRODUCT_NAME} ${PRODUCT_VERSION} (${RTEMS_TARGET})"
+OutFile "${RTEMS_BINARY}/rtems${PRODUCT_VERSION}-tools-${RTEMS_TARGET}-${RTEMS_BUILD_VERSION}.exe"
+InstallDir "C:\opt\rtems-${PRODUCT_VERSION}"
+ShowInstDetails show
+ShowUnInstDetails show
+BrandingText "RTEMS ${RTEMS_TARGET} Tools v${PRODUCT_VERSION}"
+AllowRootDirInstall false
+AutoCloseWindow false
+CRCCheck force
+
+!include "${RTEMS_SOURCE}/msys-path.nsi"
+
+Section "RTEMS ${RTEMS_TARGET} Tools" SecTools
+ SetDetailsView show
+
+ /*
+  * Detect if MSYS is installed.
+  */
+ Call MSYSDetect
+ Pop $9
+
+ SetOutPath "$INSTDIR\Uninstall"
+ SetOutPath "$INSTDIR\Packages\Build"
+ SetOutPath "$INSTDIR\Packages\Build"
+ SetOutPath "$INSTDIR\Packages\Source"
+ File "${RTEMS_SOURCE}/build-autotools.sh"
+ File "${RTEMS_SOURCE}/ba-wrap.sh"
+ File "${RTEMS_PACKAGE_SOURCE}/${RTEMS_AUTOCONF_SOURCE}"
+ File "${RTEMS_SOURCE}/autoconf.def"
+ File "${RTEMS_SOURCE}/automake.def"
+ !insertmacro RTEMS_AUTOCONF_PATCHES
+ File "${RTEMS_PACKAGE_SOURCE}/${RTEMS_AUTOMAKE_SOURCE}"
+ !insertmacro RTEMS_AUTOMAKE_PATCHES
+
+ Delete "$INSTDIR\Packages\Source\at-log.txt"
+
+ /*
+  * Need to fix the slashes when using a Unix type shell.
+  */
+ Push "$INSTDIR\Packages\Source\ba-wrap.sh"
+ Push '\\'
+ Pop $R0
+ Call StrSlash
+ Pop $R1
+ Push "$INSTDIR\Packages\Build"
+ Push '\\'
+ Pop $R0
+ Call StrSlash
+ Pop $R2
+
+ /*
+  * Build Autoconf.
+  */
+ Push "$INSTDIR\Packages\Source\autoconf.def"
+ Push '\\'
+ Pop $R0
+ Call StrSlash
+ Pop $R0
+ DetailPrint "Building autoconf. Command window closes automatically."
+ ExecWait '"$9\bin\sh" --login -c "$R1 -p /opt/rtems-${PRODUCT_VERSION} -b $R2 -c $R0"' $0
+ BringToFront
+ IntCmp $0 0 +3
+  MessageBox MB_OK "Autoconf build failed. See $INSTDIR\Packages\Source\at-log.txt"
+  Abort
+
+ BringToFront
+
+ Push "$INSTDIR\Uninstall\${RTEMS_AUTOCONF}-files"
+ call InstallFilesFromFile
+
+ /*
+  * Build Automake.
+  */
+ Push "$INSTDIR\Packages\Source\automake.def"
+ Push '\\'
+ Pop $R0
+ Call StrSlash
+ Pop $R0
+ DetailPrint "Building automake. Command window closes automatically."
+ ExecWait '"$9\bin\sh" --login -c "$R1 -p /opt/rtems-${PRODUCT_VERSION} -b $R2 -c $R0"' $0
+ BringToFront
+ IntCmp $0 0 +3
+  MessageBox MB_OK "Automake build failed. See $INSTDIR\Packages\Source\at-log.txt"
+  Abort
+
+ BringToFront
+
+ Push "$INSTDIR\Uninstall\${RTEMS_AUTOMAKE}-files"
+ call InstallFilesFromFile
+
+ DetailPrint "Removing Build directory"
+ RMDir /r "$INSTDIR\Packages\Build"
+SectionEnd
+
+!macro FILE_WRITE_LINE Handle Text
+  FileWrite     ${Handle} `${Text}`
+  FileWriteByte ${Handle} "13"
+  FileWriteByte ${Handle} "10"
+!macroend
+
+Function .onInit
+  ;Extract InstallOptions INI files
+  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "rtems.ini"
+FunctionEnd
+
+Function RTEMSMessage
+
+  !insertmacro MUI_HEADER_TEXT \
+               "RTEMS Tools (Autoconf/Automake)" \
+               "A tool set for the RTEMS operating system."
+
+  ;Display the Install Options dialog
+
+  Push $R0
+  Push $R1
+  Push $R2
+
+    InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\rtems.ini"
+    Pop $R0
+
+    GetDlgItem $R1 $R0 1200 ;1200 + Field number - 1
+    ;$R1 contains the HWND of the first field
+    CreateFont $R2 "Tahoma" "8" "300"
+    SendMessage $R1 ${WM_SETFONT} $R2 0
+	
+    GetDlgItem $R1 $R0 1201 ;1200 + Field number - 1
+    ;$R1 contains the HWND of the first field
+    CreateFont $R2 "Tahoma" "12" "700"
+    SendMessage $R1 ${WM_SETFONT} $R2 0
+	
+    GetDlgItem $R1 $R0 1202 ;1200 + Field number - 1
+    ;$R1 contains the HWND of the first field
+    CreateFont $R2 "Tahoma" "8" "300"
+    SendMessage $R1 ${WM_SETFONT} $R2 0
+	
+    GetDlgItem $R1 $R0 1203 ;1200 + Field number - 1
+    ;$R1 contains the HWND of the first field
+    CreateFont $R2 "Tahoma" "8" "300"
+    SendMessage $R1 ${WM_SETFONT} $R2 0
+	
+    GetDlgItem $R1 $R0 1204 ;1200 + Field number - 1
+    ;$R1 contains the HWND of the first field
+    CreateFont $R2 "Tahoma" "8" "300"
+    SendMessage $R1 ${WM_SETFONT} $R2 0
+	
+    GetDlgItem $R1 $R0 1205 ;1200 + Field number - 1
+    ;$R1 contains the HWND of the first field
+    CreateFont $R2 "Tahoma" "8" "300"
+    SendMessage $R1 ${WM_SETFONT} $R2 0
+	
+    GetDlgItem $R1 $R0 1206 ;1200 + Field number - 1
+    ;$R1 contains the HWND of the first field
+    CreateFont $R2 "Tahoma" "8" "300"
+    SendMessage $R1 ${WM_SETFONT} $R2 0
+	
+    InstallOptions::show
+    Pop $R0
+
+  Pop $R2
+  Pop $R1
+  Pop $R0
+
+FunctionEnd
+
+Var FileList
+
+Function InstallFilesFromFile
+  Pop $R6
+  Push $R7
+  Push $R8
+  Push $R9
+  DetailPrint "Installing file list: $R6"
+  SetFileAttributes "$R6" NORMAL
+  FileOpen $FileList "$R6" r
+  IfErrors 0 +3
+   MessageBox MB_OK "Internal error reading file list (0:$R6)."
+   Abort
+ ReadLoop:
+  FileRead $FileList $R7
+  IfErrors Done
+  StrCpy $R7 $R7 -1 # has a \n only at the end
+  StrCpy $R8 $R7
+  StrCpy $R7 $R7 1  # first character on the line
+  StrCpy $R8 $R8 256 2
+  StrCmpS $R7 "D" ReadLoop
+  StrCmpS $R7 "b" 0 +3
+   StrCpy $R9 $R8
+   Goto ReadLoop
+  StrCmpS $R7 "d" 0 +3
+   CreateDirectory "$INSTDIR\$R8"
+   Goto ReadLoop
+  StrCmpS $R7 "f" 0 +3
+   CopyFiles /SILENT "$INSTDIR\Packages\Build\$R9\$R8" "$INSTDIR\$R8" 
+   Goto ReadLoop
+  MessageBox MB_OK "Internal error installing package (2:$R6)."
+  Abort
+ Done:
+  FileClose $FileList
+  ClearErrors
+  Pop $R9
+  Pop $R8
+  Pop $R7
+FunctionEnd
+
+Function un.RemoveFilesFromFile
+  ; Two passes, one to delete files then the directories
+  ; This is due to the order in the *-files list. Plus
+  ; RMDir seems to stuff things up (maybe a NSIS bug!)
+  Pop $R6
+  Push $R7
+  Push $R8
+  Push $R9
+  DetailPrint "Delete file list: $R6"
+  SetFileAttributes "$R6" NORMAL
+  FileOpen $FileList "$R6" r
+  IfErrors 0 +3
+   MessageBox MB_OK "Internal error reading file list (0:$R6)."
+   Abort
+ ReadLoop:
+  FileRead $FileList $R7
+  IfErrors Pass2
+  StrCpy $R7 $R7 -1 # has a \n only at the end
+  StrCpy $R8 $R7
+  StrCpy $R7 $R7 1  # first character on the line
+  StrCpy $R8 $R8 256 2
+  StrCmp $R7 "b" ReadLoop
+  StrCmp $R7 "d" ReadLoop
+  StrCmp $R7 "D" ReadLoop
+  StrCmp $R7 "f" 0 +3
+   Delete "$INSTDIR\$R8"
+   Goto ReadLoop
+  MessageBox MB_OK "Internal error removing package (2:$R6)."
+  Abort
+ Pass2:
+  ClearErrors
+  FileSeek $FileList 0 SET
+ ReadLoop2:
+  FileRead $FileList $R7
+  IfErrors Done
+  StrCpy $R7 $R7 -1 # has a \n only at the end
+  StrCpy $R8 $R7
+  StrCpy $R7 $R7 1  # first character on the line
+  StrCpy $R8 $R8 256 2
+  StrCmpS $R7 "b" ReadLoop2
+  StrCmpS $R7 "d" ReadLoop2
+  StrCmpS $R7 "f" ReadLoop2
+  StrCmpS $R7 "D" 0 Fail
+   ifFileExists "$INSTDIR\$R8\*.*" 0 ReadLoop2
+    RMDir "$INSTDIR\$R8"  #is dir
+   Delete "$INSTDIR\$R8"
+   ClearErrors
+   Goto ReadLoop2
+ Fail:
+  MessageBox MB_OK "Internal error removing package (2:$R6)."
+  Abort
+ Done:
+  FileClose $FileList
+  ClearErrors
+  Delete $R6
+  Pop $R9
+  Pop $R8
+  Pop $R7
+FunctionEnd
+
+; Push $filenamestring (e.g. 'c:\this\and\that\filename.htm')
+; Push '\\'
+; Pop $R0
+; Call StrSlash
+; Pop $R0
+; ;Now $R0 contains 'c:/this/and/that/filename.htm'
+Function StrSlash
+ Exch $R0
+ Push $R1
+ Push $R2
+ StrCpy $R1 0
+loop:
+  IntOp $R1 $R1 - 1
+  StrCpy $R2 $R0 1 $R1
+  StrCmp $R2 "" done
+ StrCmp $R2 "\" 0 loop ;" keep to get Emacs for fontlock
+  StrCpy $R2 $R0 $R1
+   Push $R1
+  IntOp $R1 $R1 + 1
+  StrCpy $R1 $R0 "" $R1
+ StrCpy $R0 "$R2/$R1"
+   Pop $R1
+  IntOp $R1 $R1 - 1
+ Goto loop
+done:
+ Pop $R2
+ Pop $R1
+ Exch $R0
+FunctionEnd
+
+Section -Post
+ WriteUninstaller "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-${RTEMS_TARGET}-uninst.exe"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
+                  "DisplayName" "$(^Name)"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
+                  "UninstallString" "$INSTDIR\uninst.exe"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
+                  "DisplayVersion" "${PRODUCT_VERSION}"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
+                  "URLInfoAbout" "${PRODUCT_WEB_SITE}"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
+                  "Publisher" "${PRODUCT_PUBLISHER}"
+SectionEnd
+
+Section Uninstall
+ SetDetailsView show
+ DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
+ DetailPrint "Delete the installed files"
+ Push "$INSTDIR\Uninstall\${RTEMS_AUTOCONF}-files"
+ call un.RemoveFilesFromFile 
+ Push "$INSTDIR\Uninstall\${RTEMS_AUTOMAKE}-files"
+ call un.RemoveFilesFromFile
+ RMDir "$INSTDIR\Uninstall"
+ Delete "$INSTDIR\Packages\Source\build-autotools.sh"
+ Delete "$INSTDIR\Packages\Source\ba-wrap.sh"
+ Delete "$INSTDIR\Packages\Source\${RTEMS_AUTOCONF_SOURCE}"
+ Delete "$INSTDIR\Packages\Source\${RTEMS_AUTOMAKE_SOURCE}"
+ Delete "$INSTDIR\Packages\Source\autoconf.def"
+ Delete "$INSTDIR\Packages\Source\automake.def"
+ Delete "$INSTDIR\Packages\Source\at-log.txt"
+ !insertmacro RTEMS_DELETE_AUTOCONF_PATCHES
+ !insertmacro RTEMS_DELETE_AUTOMAKE_PATCHES
+ RMDir "$INSTDIR\Packages\Source"
+ RMDir "$INSTDIR\Packages\Build"
+ Delete $INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-${RTEMS_TARGET}-uninst.exe
+ RMDir "$INSTDIR"
+ DetailPrint "All done."
+ SetAutoClose false
+SectionEnd
Index: contrib/mingw/rtems-tools.nsi
===================================================================
--- contrib/mingw/rtems-tools.nsi	(revision e4a22331c63fcbb49592301cd7a6620c80dd9593)
+++ contrib/mingw/rtems-tools.nsi	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -11,5 +11,5 @@
 !define PRODUCT_NAME      "RTEMS Tools"
 !define PRODUCT_VERSION   ${RTEMS_VERSION}
-!define PRODUCT_PUBLISHER "RTEM Project Team"
+!define PRODUCT_PUBLISHER "RTEMS Project Team"
 !define PRODUCT_WEB_SITE  "http://www.rtems.org/"
 
@@ -58,6 +58,10 @@
 
 Name "${PRODUCT_NAME} ${PRODUCT_VERSION} (${RTEMS_TARGET})"
-OutFile "${RTEMS_BINARY}/rtems${PRODUCT_VERSION}-${RTEMS_TARGET}-${RTEMS_BUILD_VERSION}.exe"
-InstallDir "C:\rtems\${RTEMS_TARGET}"
+!ifdef COMMON_FILES
+OutFile "${RTEMS_BINARY}/rtems${PRODUCT_VERSION}-tools-${RTEMS_BUILD_VERSION}.exe"
+!else
+OutFile "${RTEMS_BINARY}/${RTEMS_OUTFILE}"
+!endif
+InstallDir "C:\opt\rtems-${PRODUCT_VERSION}"
 ShowInstDetails show
 ShowUnInstDetails show
@@ -67,11 +71,18 @@
 CRCCheck force
 
-Section "RTEMS ${RTEMS_TARGET} Tools" SecTools
+!include "${RTEMS_SOURCE}/msys-path.nsi"
+
+Section -SecFiles
+ !insertmacro RTEMS_INSTALL_FILES
+SectionEnd
+
+!ifdef COMMON_FILES
+Section -SecCommon
  SetOutPath "$INSTDIR"
  File "${RTEMS_SOURCE}/AUTHORS"
  File "${RTEMS_SOURCE}/COPYING"
  File "${RTEMS_SOURCE}/README"
- !insertmacro RTEMS_INSTALL_FILES
-SectionEnd
+SectionEnd
+!endif
 
 !macro FILE_WRITE_LINE Handle Text
@@ -160,5 +171,5 @@
   StrCpy $R2 $R0 1 $R1
   StrCmp $R2 "" done
- StrCmp $R2 "\" 0 loop
+ StrCmp $R2 "\" 0 loop  ; "
   StrCpy $R2 $R0 $R1
    Push $R1
@@ -175,15 +186,16 @@
 FunctionEnd
 
+!ifdef COMMON_FILES
 Section -BatchFiles
  FileOpen $9 $INSTDIR\rtems.bat w
  !insertmacro FILE_WRITE_LINE $9 "@echo off"
- !insertmacro FILE_WRITE_LINE $9 "rem RTEMS batch file: ${RTEMS_TARGET} (${RTEMS_VERSION})"
+ !insertmacro FILE_WRITE_LINE $9 "rem RTEMS batch file: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}"
  !insertmacro FILE_WRITE_LINE $9 "set PATH=$INSTDIR\bin;c:\mingw\bin;c:\msys\1.0\bin;%PATH%"
- !insertmacro FILE_WRITE_LINE $9 "set PROMPT=RTEMS(${RTEMS_TARGET}) $$P$$G"
+ !insertmacro FILE_WRITE_LINE $9 "set PROMPT=RTEMS $$P$$G"
  !insertmacro FILE_WRITE_LINE $9 "If $\"x%OS%x$\" == $\"xWindows_NTx$\" Goto WinNT_Title"
  !insertmacro FILE_WRITE_LINE $9 "doskey > Nul"
  !insertmacro FILE_WRITE_LINE $9 "goto Finished"
  !insertmacro FILE_WRITE_LINE $9 ":WinNT_Title"
- !insertmacro FILE_WRITE_LINE $9 "Title RTEMS(${RTEMS_TARGET})"
+ !insertmacro FILE_WRITE_LINE $9 "Title RTEMS ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}"
  !insertmacro FILE_WRITE_LINE $9 ":Finished"
  FileClose $9
@@ -191,5 +203,5 @@
  FileOpen $9 $INSTDIR\rtems-cmd.bat w
  !insertmacro FILE_WRITE_LINE $9 "@echo off"
- !insertmacro FILE_WRITE_LINE $9 "rem RTEMS batch file: ${RTEMS_TARGET} (${RTEMS_VERSION})"
+ !insertmacro FILE_WRITE_LINE $9 "rem RTEMS batch file: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}"
  !insertmacro FILE_WRITE_LINE $9 "If $\"x%OS%x$\" == $\"xWindows_NTx$\" Goto WinNT"
  !insertmacro FILE_WRITE_LINE $9 "start command.com /e:4096 /k $INSTDIR\rtems.bat %1 %2 %3 %4"
@@ -202,4 +214,5 @@
  FileOpen $9 $INSTDIR\sh-run.bat w
  !insertmacro FILE_WRITE_LINE $9 "@echo off"
+ !insertmacro FILE_WRITE_LINE $9 "rem RTEMS batch file: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}"
  !insertmacro FILE_WRITE_LINE $9 "rem We can only handle 9 parameters. More is too hard."
  !insertmacro FILE_WRITE_LINE $9 "call $INSTDIR\rtems.bat"
@@ -209,4 +222,5 @@
  FileOpen $9 $INSTDIR\vs-make.sh w
  !insertmacro FILE_WRITE_LINE $9 "#! /bin/sh"
+ !insertmacro FILE_WRITE_LINE $9 "# RTEMS script: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}"
  !insertmacro FILE_WRITE_LINE $9 "if [ ! -d $$1 ]; then"
  !insertmacro FILE_WRITE_LINE $9 " echo $\"error: no build directory found$\""
@@ -223,23 +237,41 @@
 
 Section -MSYSLinks
- FindFirst $8 $1 c:\msys\1.0\etc\fstab
- StrCmp $1 "" MSYSLinksdone
+ Call MSYSDetectSilent
+ Pop $R0
+ ifFileExists "$R0\etc\fstab" 0 Done
+  Push $R0
   Push $INSTDIR
+  Push '\\'
+  Pop $R0
   Call StrSlash
+  Pop $R1
   Pop $R0
-  DetailPrint "Setting MSYS fstab: $R0 -> ${TOOL_PREFIX}"
-  FileOpen $9 "c:\msys\1.0\etc\fstab" a
+  DetailPrint "Setting MSYS fstab: $R1 -> /opt/rtems-${PRODUCT_VERSION}"
+  StrCpy $R1 "$R1 /opt/rtems-${PRODUCT_VERSION}$\n"
+  FileOpen $9 "$R0\etc\fstab" a
+  ifErrors 0 +3
+    MessageBox MB_OK "Cannot open $R0\etc\fstab. MSYS mount point no added."
+    Goto Close
+  FileSeek $9 0 SET
+ ReadLoop:
+  FileRead $9 $R2
+  ifErrors Append
+  StrCmp $R1 $R2 Close ReadLoop
+ Append:
   FileSeek $9 0 END
-  FileWrite $9 $R0
-  FileWriteByte $9 "32"
-  FileWrite $9 ${TOOL_PREFIX}
-  FileWriteByte $9 "10"
+  FileWrite $9 $R1
+ Close:
   FileClose $9
- MSYSLinksdone:
- FindClose $8
-SectionEnd
+ Done:
+  ClearErrors
+SectionEnd
+!endif
 
 Section -Post
- WriteUninstaller "$INSTDIR\rtems-${RTEMS_TARGET}-uninst.exe"
+!ifdef COMMON_FILES
+ WriteUninstaller "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-uninst.exe"
+!else
+ WriteUninstaller "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-${RTEMS_TARGET}-uninst.exe"
+!endif
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
                   "DisplayName" "$(^Name)"
@@ -256,12 +288,25 @@
 Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \
-            "Are you sure you want to uninstall RTEMS Tools?" IDYES +2
+            "Are you sure you want to uninstall RTEMS Tools (${RTEMS_TARGET})?" IDYES +2
  Abort
 FunctionEnd
 
 Section Uninstall
- Delete $INSTDIR\rtems-${RTEMS_TARGET}-uninst.exe
+ SetDetailsView show
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
- DetailPrint "Delete the install directory"
+ DetailPrint "Delete the installed files"
+ !insertmacro RTEMS_DELETE_FILES
+!ifdef COMMON_FILES
+ FindFirst $0 $1 "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-*-uninst.exe"
+ Uninstall_Targets:
+  StrCmp $1 "" Uninstall_Targets_Done
+  DetailPrint "Uninstalling $1"
+  ExecWait '"$INSTDIR\$1" /S'
+  Delete $1
+  BringToFront
+  FindNext $0 $1
+  Goto Uninstall_Targets
+ Uninstall_Targets_Done:
+ FindClose $0
  Delete "$INSTDIR\AUTHORS"
  Delete "$INSTDIR\COPYING"
@@ -271,6 +316,11 @@
  Delete "$INSTDIR\sh-run.bat"
  Delete "$INSTDIR\vs-make.sh"
- !insertmacro RTEMS_DELETE_FILES
+ Delete "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-uninst.exe"
+!else
+ Delete "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-${RTEMS_TARGET}-uninst.exe"
+ Delete "$INSTDIR\Packages"
+!endif
+ RMDir "$INSTDIR"
  DetailPrint "All done."
- SetAutoClose true
-SectionEnd
+ SetAutoClose false
+SectionEnd
Index: contrib/mingw/rtems.ini
===================================================================
--- contrib/mingw/rtems.ini	(revision e4a22331c63fcbb49592301cd7a6620c80dd9593)
+++ contrib/mingw/rtems.ini	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -8,5 +8,5 @@
 [Field 1]
 Type=Label
-Text=RTEMS Tools for Windows is a set of MinGW tools suitable for compiling RTEMS and RTEMS applications. You should install download and install the MinGW runtime and if you wish to build RTEMS or need autoconf or automake support the MSYS packages as well. You can find the MinGW and MSYS installers on the MinGW web site.\r\n\r\nFurther information and the source code with patches can be located via the link below.
+Text=RTEMS Tools for Windows is a set of MinGW tools suitable for compiling RTEMS and RTEMS applications. You should install download and install the MinGW runtime and if you wish to build RTEMS and if you need autoconf or automake support the MSYS and MSYS DTK packages as well. You can find the MinGW and MSYS installers on the MinGW web site.\r\n\r\nFurther information and the source code with patches can be located via the link below.
 Left=0
 Right=292
@@ -25,5 +25,5 @@
 Type=Link
 Text=Source Code with patches
-State=ftp://www.rtems.org/pub/rtems/SOURCES
+State=http://www.rtems.org/ftp/pub/rtems/SOURCES
 Left=150
 Right=275
Index: contrib/mingw/target-section-text
===================================================================
--- contrib/mingw/target-section-text	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
+++ contrib/mingw/target-section-text	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -0,0 +1,9 @@
+auto_section_text="Autoconf and Automake"
+arm_section_text="ARM Targets"
+h8300_section_text="H8300 16bit Target"
+i386_section_text="Intel i386 Targets"
+m68k_section_text="Coldfire and M68000 Targets"
+mips_section_text="MIPS Targets"
+powerpc_section_text="PowerPC Targets"
+sh_section_text="SH Targets"
+sparc_section_text="SPARC (Leon) Targets"
Index: contrib/mingw/upload.sh
===================================================================
--- contrib/mingw/upload.sh	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
+++ contrib/mingw/upload.sh	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -0,0 +1,104 @@
+#! /bin/sh
+
+# $Id$
+#
+# RTEMS Installers and Source Upload script.
+#
+# This script copies the executable and source to the RTEMS FTP server. It is for
+# use on the RTEMS build server.
+#
+
+echo $0 $*
+
+source=$(dirname $0)
+top=$(pwd)
+
+terminate()
+{
+  echo "error: $*" >&2
+  exit 1
+}
+
+check()
+{
+  if [ $? -ne 0 ]; then
+    terminate
+  fi
+}
+
+. $source/version
+
+ftpbase=none
+prefix=none
+
+while [ $# -gt 0 ];
+do
+  case $1 in
+    -b)
+      shift
+      tool_build=$1
+      ;;
+    -d)
+      set -x
+      ;;
+    -f)
+      shift
+      ftpbase=$1
+      ;;
+    -p)
+      shift
+      prefix=$1
+      ;;
+    -v)
+      shift
+      version=$1
+      ;;
+    --help)
+      echo "$0 -d -b <build> -f <ftpbase> -p <prefix> -v <version>"
+      exit 2
+      ;;
+    *)
+      terminate "error: invalid option (try --help): $1"
+      ;;
+  esac
+  shift
+done
+
+if [ $ftpbase = none ]; then
+  terminate "no ftpbase set"
+fi
+
+if [ $prefix = none ]; then
+  terminate "no prefix set"
+fi
+
+exebase=${prefix}/${version}/packages/mingw32/exe
+srcbase=${prefix}/${version}/packages/mingw32/SRPMS
+
+mkdir -p ${ftpbase}/${version}/build-${tool_build}/source
+check "creating: ${ftpbase}/${version}/build-${tool_build}/source"
+
+exes=$(find $exebase -name \*.exe)
+for e in $exes
+do
+  echo "cp $e ${ftpbase}/${version}/build-${tool_build}/."
+  cp $e ${ftpbase}/${version}/build-${tool_build}/.
+  check "coping installer: $e"
+done
+
+cd ${ftpbase}/${version}/build-${tool_build}/source
+check "change directory: ${ftpbase}/${version}/build-${tool_build}/source"
+
+for s in ${srcbase}/*.rpm
+do
+  echo "rpm2cpio $s | cpio --extract --quiet"
+  rpm2cpio $s | cpio --extract --quiet
+  check "RPM to CPIO and CPIO Copy-In failed"
+done
+
+rm -f *.spec
+check "deleting spec files"
+
+cd $top
+
+exit 0
Index: contrib/mingw/version
===================================================================
--- contrib/mingw/version	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
+++ contrib/mingw/version	(revision f6cd0dbeadb89f13c616bc3bce19fad59093759b)
@@ -0,0 +1,2 @@
+version=4.8
+tool_build=14
