Intel 386 Mach host port
[deliverable/binutils-gdb.git] / gdb / config.gdb
index f94eee606f9f9b1ec9c4b547862ca0c74695489f..c380fe45772d13ab849a2a42c733c17d1d488bd1 100755 (executable)
 #!/bin/sh
 
-#
 # Shell script to do machine-dependent things in
 # preparation for compiling gdb.
 #
-# Usage: config.gdb machine [operating-system]
+# Usage: config.gdb machine
 #
 # If config.gdb succeeds, it leaves its status in config.status.
 # If config.gdb fails after disturbing the status quo, 
 #      config.status is removed.
-#
-# Note: if making something gives errors like "unable to make target
-# 1-dep.c", this means that the compiler has put in a builtin define
-# and there is a "-U" missing from makedefine in this file.
-#
 
 progname=$0
+host=
+target=
+list_hosts=
+list_targets=
+srcdir=
 
-case $# in 
-1)
-       machine=$1
-       os=""
-       ;;
-2)
-       machine=$1
-       os=$2
-       ;;
-*)
-       echo "Usage: $progname machine [operating-system]"
-       echo "Available machine types:"
-       echo m-*.h | sed 's/m-//g' | sed 's/\.h//g'
-       if [ -r config.status ]
-       then
-               cat config.status
-       fi
-       exit 1
-       ;;
-esac
+for arg in $*; do
+  case $arg in
+    -srcdir=*|+srcdir=*)
+      srcdir=`echo $arg | sed 's/[+-]srcdir=//'`
+      ;;
+    -host|+host)
+      list_hosts=true
+      ;;
+    -target|+target)
+      list_targets=true
+      ;;
+    -host=*|+host=*)
+      if [ "$host" = "" ]; then
+        host=`echo $arg | sed 's/[+-]host=//'`
+      else
+        echo Error: Attempt to specify host machine twice
+        bad=true
+      fi
+      ;;
+    -target=*|+target=*)
+      if [ "$target" = "" ]; then
+        target=`echo $arg | sed 's/[+-]target=//'`
+      else
+        echo Error: Attempt to specify target machine twice
+        bad=true
+      fi
+      ;;
+    *)
+      if [ "$host" = "" ]; then
+       host=$arg
+      else
+        if [ "$target" = "" ]; then
+          target=$arg
+        else
+          echo Error: More arguments than host and target machine names
+         bad=true
+        fi
+      fi
+      ;;
+  esac
+done
 
-# cannonicalize the machine name.
-case $machine in
-news)
-       case $os in
-       os3|newsos3)
-               $machine=newsos3
-               $os=""
-               ;;
-       esac
-       ;;
-sun2)
-       case $os in
-       os4|sunos4)
-               machine=sun2os4
-               os=""
-       ;;
-       os2|sunos2)
-               machine=sun2os2
-               os=""
-               ;;
-       esac
-       ;;
-sun3)
-       case $os in
-       os4|sunos4)
-               machine=sun3os4
-               os=""
-               ;;
-       os3|sunos3)
-               machine=sun3os3
-               os=""
-               ;;
-       esac
-       ;;
-sparc|sun4)
-       case $os in
-       os4|sunos4)
-               machine=sun4os4
-               os=""
-               ;;
-       esac
-       ;;
-# GCC accepts sequent-i386 or symmetry, so be consistent.
-sequent-i386)
-       machine=symmetry
-       os=""
-       ;;
-esac
+if [ "$target" = "" ]; then target=$host; fi
+if [ "$host" = "" ]; then bad=true; fi
 
-paramfile=m-${machine}${os}.h
-pinsnfile=${machine}${os}-pinsn.c
-opcodefile=${machine}${os}-opcode.h
-# Set up a define for purposes of editing the makefile.
-makedefine=
-if [ -r ${machine}${os}-dep.c ]
-then
-       depfile=${machine}${os}-dep.c
-else
-       depfile=default-dep.c
+# Find the source files, if location was not specified
+if [ "$srcdir" = "" ]; then
+  srcdirdefaulted=true
+  srcdir=.
+  if [ ! -r main.c ]; then
+    srcdir=..
+  fi
+fi
+if [ ! -r ${srcdir}/main.c ]; then
+  if [ "$srcdirdefaulted" != "true" ]; then
+    echo "$progname: Can't find debugger sources in \`${srcdir}'." 1>&2
+  else
+    echo "$progname: Can't find debugger sources in \`.' or \`..'." 1>&2
+  fi
+  exit 1
 fi
 
-#
-# Special cases.
-# If a file is not needed, set the file name to something.
-# It must be linked to something, or else make will try to make it.
-# /dev/null will not work because on systems without symbolic links,
-# it will complain that /dev/null is on a different file system.
-#
-case $machine in
-altos)
-       makedefine="-DM_REGEX=regex.o -DM_SYSV -DM_BSD_NM"
-       pinsnfile=m68k-pinsn.c
-       opcodefile=m68k-opcode.h
-       ;;
-altosgas)
-       echo "Use of the coff encapsulation features require the GNU binutils utilities"
-       echo "To be ahead of their System V counterparts in your path."
-       makedefine="-DM_REGEX=regex.o -DM_SYSV -DM_BSD_NM"
-       pinsnfile=m68k-pinsn.c
-       depfile=altos-dep.c
-       opcodefile=m68k-opcode.h
-       ;;
-vax)
-       echo
-# The following types of /bin/cc failures have been observed:
-# 1.  Something in readline.c which I have never seen
-# 2.  ``"values.c", line 816: compiler error: schain botch''
-       echo "/bin/cc has been known to fail on VAXen running BSD4.3"
-       echo "If this occurs, use gcc "
-       echo " (but see comments in Makefile.dist about compiling with gcc)."
-       echo
-       pinsnfile=vax-pinsn.c
-       opcodefile=vax-opcode.h
-       ;;
-hp9k320)
-# The headers in the directory hp-include override system headers
-# and tell GDB to use BSD executable file format (hence -Ihp-include)
-       makedefine="-DM_SYSV -DM_BSD_NM -DM_REGEX=regex.o 
-               -DM_ALLOCA=alloca.o -DM_CFLAGS=-Ihp-include"
-# The following is true because gcc uses a different .o file format
-# than the native HPUX compiler
-       echo
-       echo "If you compile GDB with GCC on HPUX, you must make sure"
-       echo "that the \`nm' used in \`munch' is GNU nm"
-       echo
-       pinsnfile=m68k-pinsn.c
-       opcodefile=m68k-opcode.h
-       ;;
-hp300bsd)
-# Not sure what makefile editing (if any) is necessary for this machine.
-       pinsnfile=m68k-pinsn.c
-       opcodefile=m68k-opcode.h
-       ;;
-isi)
-# ISI running bsd4.2
-       pinsnfile=m68k-pinsn.c
-       opcodefile=m68k-opcode.h
-       ;;
-i386)
-       makedefine="-DM_CLIBS=-lPW -DM_SYSV -DM_REGEX=regex.o"
-# The following is a lie, but a necessary one.  See comment at beginning
-# of this file about unneeded files.
-       opcodefile=m-i386.h
-       ;;
-i386gas)
-       makedefine="-DM_CLIBS=-lPW -DM_SYSV -DM_REGEX=regex.o"
-       echo
-       echo "Use of the coff encapsulation features requires the GNU binary utilities"
-       echo "to be ahead of their System V counterparts in your path."
-       echo
-       pinsnfile=i386-pinsn.c
-       depfile=i386-dep.c
-# The following is a lie, but a necessary one.  See comment at beginning
-# of this file about unneeded files.
-       opcodefile=m-i386.h
-       ;;
-# These names are short and cryptic due to the @#$#!@#$@! System V
-# 14 character file name limit.
-i386-sv32)
-       makedefine="-DM_CLIBS=-lPW -DM_SYSV -DM_REGEX=regex.o"
-       pinsnfile=i386-pinsn.c
-       depfile=i386-dep.c
-# The following is a lie, but a necessary one.  See comment at beginning
-# of this file about unneeded files.
-       opcodefile=m-i386.h
-       ;;
-i386g-sv32)
-       makedefine="-DM_CLIBS=-lPW -DM_SYSV -DM_REGEX=regex.o"
-       echo
-       echo "Use of the coff encapsulation features requires the GNU binary utilities"
-       echo "to be ahead of their System V counterparts in your path."
-       echo
-       pinsnfile=i386-pinsn.c
-       depfile=i386-dep.c
-# The following is a lie, but a necessary one.  See comment at beginning
-# of this file about unneeded files.
-       opcodefile=m-i386.h
-       ;;
-merlin)
-       pinsnfile=ns32k-pinsn.c
-       opcodefile=ns32k-opcode.h
-       ;;
-news)
-       pinsnfile=m68k-pinsn.c
-       opcodefile=m68k-opcode.h
-       ;;
-newsos3)
-       pinsnfile=m68k-pinsn.c
-       opcodefile=m68k-opcode.h
-       depfile=news-dep.c
-       ;;
-npl)
-       pinsnfile=gld-pinsn.c
-       ;;
-pn)
-       pinsnfile=gld-pinsn.c
-       ;;
-sun2)
-       depfile=sun3-dep.c
-       pinsnfile=m68k-pinsn.c
-       opcodefile=m68k-opcode.h
-       ;;
-sun2os2|sun2-os2)
-       depfile=default-dep.c
-       paramfile=m-sun2.h
-       pinsnfile=m68k-pinsn.c
-       opcodefile=m68k-opcode.h
-       ;;      
-sun2os4|sun2-os4)
-# Compile GDB without shared libraries so that it can be run on itself.
-       makedefine=-DM_CFLAGS=-Bstatic
-       echo
-       echo "Make sure to compile any program on which you want to run gdb"
-       echo " without shared libraries (cc -Bstatic)"
-       echo
-       paramfile=m-sun2os4.h
-       depfile=sun3-dep.c
-       pinsnfile=m68k-pinsn.c
-       opcodefile=m68k-opcode.h
-       ;;      
-sun3os3)
-       paramfile=m-sun3.h
-       depfile=sun3-dep.c
-       pinsnfile=m68k-pinsn.c
-       opcodefile=m68k-opcode.h
-       ;;
-sun3os4|sun3-os4)
-# Compile GDB without shared libraries so that it can be run on itself.
-       makedefine=-DM_CFLAGS=-Bstatic
-       echo
-       echo "Make sure to compile any program on which you want to run gdb"
-       echo " without shared libraries (cc -Bstatic)"
-       echo
-       paramfile=m-sun3os4.h
-       pinsnfile=m68k-pinsn.c
-       opcodefile=m68k-opcode.h
-       depfile=sun3-dep.c
-       ;;      
-sun4os4|sun4-os4)
-# Compile GDB without shared libraries so that it can be run on itself.
-# Undefine sparc to avoid changing sparc-dep.c to 1-dep.c
-       makedefine="-DM_CFLAGS=-Bstatic -Usparc"
-       echo
-       echo "Make sure to compile any program on which you want to run gdb"
-       echo " without shared libraries (cc -Bstatic)"
-       echo
-       paramfile=m-sun4os4.h
-       pinsnfile=sparc-pinsn.c
-       opcodefile=sparc-opcode.h
-       depfile=sparc-dep.c
-       ;;      
-symmetry)
-       paramfile=m-symmetry.h
-       depfile=symmetry-dep.c
-       pinsnfile=i386-pinsn.c
-# The following is a lie, but a necessary one.  See comment at beginning
-# of this file about unneeded files.
-       opcodefile=m-i386.h
-       ;;
-umax)
-       pinsnfile=ns32k-pinsn.c
-       opcodefile=ns32k-opcode.h
-       ;;
-sparc|sun4|sun4os3|sun4-os3)
-       paramfile=m-sparc.h
-# Undefine sparc to avoid changing sparc-dep.c to 1-dep.c
-       makedefine=-Usparc
-       pinsnfile=sparc-pinsn.c
-       opcodefile=sparc-opcode.h
-       depfile=sparc-dep.c
-       ;;
-convex)
-       ;;
-test)
-       paramfile=one
-       pinsnfile=three
-       opcodefile=four
-       ;;
-*)
-       echo "Unknown machine type: \`$machine'"
-       echo "Available types:"
-       echo m-*.h | sed 's/m-//g' | sed 's/\.h//g'
-       exit 1
-       ;;
-esac
+if [ "$list_hosts" = "true" ]; then
+  cd $srcdir/xconfig
+  for i in * ; do
+# The {} in ${i} are required or else /bin/sh in sony newsos 3.2 removes
+# the quote after it.
+  awk <$i "NR == 1 { lastchar = substr(\"${i}\", length(\"${i}\"), 1)
+if (lastchar != \"~\" && lastchar != \"#\") \
+printf \"%-12s %s\n\", \"${i}\", substr(\$0,2) }"
+  done
+fi
 
-files="$paramfile $pinsnfile $opcodefile $depfile"
-links="param.h pinsn.c opcode.h dep.c" 
+if [ "$list_targets" = "true" ]; then
+  cd $srcdir/tconfig
+  for i in * ; do
+  awk <$i "NR == 1 { lastchar = substr(\"${i}\", length(\"${i}\"), 1)
+if (lastchar != \"~\" && lastchar != \"#\") \
+printf \"%-12s %s\n\", \"${i}\", substr(\$0,2) }"
+  done
+fi
 
-rm -f config.status
-while [ -n "$files" ]
-do
-       # set file to car of files, files to cdr of files
-       set $files; file=$1; shift; files=$*
-       set $links; link=$1; shift; links=$*
+if [ "$list_hosts" = "true" -o "$list_targets" = "true" ]; then
+  exit 0
+fi
 
-       if [ "$file" != skip ]
-       then
-               if [ ! -r $file ]
-               then
-                       echo "$progname: cannot create a link \`$link',"
-                       echo "since the file \`$file' does not exist."
-                       exit 1
-               fi
+if [ "$host" != "" -a ! -f $srcdir/xconfig/$host ]; then
+  echo "No such host $host"
+  bad=true
+fi
 
-               echo "Linking \`$link' to \`$file'."
-               rm -f $link
-               # Make a symlink if possible, otherwise try a hard link
-               ln -s $file $link 2>/dev/null || ln $file $link
+if [ "$target" != "" -a ! -f $srcdir/tconfig/$target ]; then
+  echo "No such target $target"
+  bad=true
+fi
 
-               if [ ! -r $link ]
-               then
-                       echo "$progname: unable to link \`$link' to \`$file'."
-                       exit 1
-               fi
-       fi
-done
+if [ "$bad" = "true" ] ; then
+  echo "Usage: "
+  echo "  $progname [+srcdir=\`dir'] machine"
+  echo "    For normal usage"
+  echo "  $progname [+srcdir=\`dir'] \`host' \`target'"
+  echo "  $progname [+srcdir=\`dir'] +host=\`host' +target=\`target'"
+  echo "    If you are doing remote debugging between machines of two"
+  echo "    different types (cross-debugging).  \`host' is the type of"
+  echo "    machine on which GDB will be running.  \`target' is the"
+  echo "    machine that the program you are debugging will be"
+  echo "    running on."
+  echo "  $progname +host"
+  echo "    Print a list of valid host machine types."
+  echo "  $progname +target"
+  echo "    Print a list of valid target machine types."
+  echo
+  echo "  +srcdir=\`dir' means that the sources are in \`dir'.  For"
+  echo "    example, \`cd /obj/hp300; config.gdb +srcdir=/src/gdb hp300'"
+  echo "    If +srcdir is not specified, sources can either be in \`.'"
+  echo "    or \`..'."
+  echo
+
+  if [ -r config.status ]
+  then
+    cat config.status
+  fi
+  exit 1
+fi
+
+rm -f tm.h xm.h
+
+cat $srcdir/xconfig/$host $srcdir/tconfig/$target | awk '$1 == "#msg" {
+  print substr($0,6)}'
+paramfile=${srcdir}/`awk '
+  $1 == "TM_FILE=" { print $2 }' <$srcdir/tconfig/$target`
+if [ "$paramfile" != "${srcdir}/" ] ; then
+  # Make a symlink if possible, otherwise try a hard link
+  ln -s $paramfile tm.h 2>/dev/null || ln $paramfile tm.h
+fi
 
-# edit the makefile
-echo "Editing Makefile"
-cp Makefile.dist tmp.c
-cc -E >Makefile tmp.c $makedefine -DM_MAKEDEFINE="$makedefine"
-rm -f tmp.c
+paramfile=${srcdir}/`awk '
+  $1 == "XM_FILE=" { print $2 }' <$srcdir/xconfig/$host`
+if [ "$paramfile" != "${srcdir}/" ] ; then
+  # Make a symlink if possible, otherwise try a hard link
+  ln -s $paramfile xm.h 2>/dev/null || ln $paramfile xm.h
+fi
+
+rm -f config.status
 
-echo "GDB is now set up for use with a $machine." \
+case ${srcdir} in
+  .)
+    ;;
+  *)
+    echo "srcdir=${srcdir}" >./Makefile.sdir
+    grep -s "source ${srcdir}/.gdbinit" .gdbinit 2>/dev/null || \
+      echo "source ${srcdir}/.gdbinit" >> .gdbinit
+esac
+
+rm -f Makefile
+make "srcdir=${srcdir}" \
+  "M_MAKEFILE=$srcdir/tconfig/$target $srcdir/xconfig/$host" \
+  -f $srcdir/Makefile.dist Makefile
+
+echo "GDB is now set up for host machine $host and target machine $target." \
        | tee config.status
 exit 0
-
This page took 0.028286 seconds and 4 git commands to generate.