3 # Shell script to do machine-dependent things in
4 # preparation for compiling gdb.
6 # Usage: config.gdb machine
8 # If config.gdb succeeds, it leaves its status in config.status.
9 # If config.gdb fails after disturbing the status quo,
10 # config.status is removed.
22 srcdir=`echo $arg | sed 's/[+-]srcdir=//'`
31 if [ "$host" = "" ]; then
32 host=`echo $arg | sed 's/[+-]host=//'`
34 echo Error: Attempt to specify host machine twice
39 if [ "$target" = "" ]; then
40 target=`echo $arg | sed 's/[+-]target=//'`
42 echo Error: Attempt to specify target machine twice
47 if [ "$host" = "" ]; then
50 if [ "$target" = "" ]; then
53 echo Error: More arguments than host and target machine names
61 if [ "$target" = "" ]; then target=$host; fi
62 if [ "$host" = "" ]; then bad=true; fi
64 # Find the source files, if location was not specified
65 if [ "$srcdir" = "" ]; then
68 if [ ! -r main.c ]; then
72 if [ ! -r ${srcdir}/main.c ]; then
73 if [ "$srcdirdefaulted" != "true" ]; then
74 echo "$progname: Can't find debugger sources in \`${srcdir}'." 1>&2
76 echo "$progname: Can't find debugger sources in \`.' or \`..'." 1>&2
81 if [ "$list_hosts" = "true" ]; then
84 # The {} in ${i} are required or else /bin/sh in sony newsos 3.2 removes
86 awk <$i "NR == 1 { lastchar = substr(\"${i}\", length(\"${i}\"), 1)
87 if (lastchar != \"~\" && lastchar != \"#\") \
88 printf \"%-12s %s\n\", \"${i}\", substr(\$0,2) }"
92 if [ "$list_targets" = "true" ]; then
95 awk <$i "NR == 1 { lastchar = substr(\"${i}\", length(\"${i}\"), 1)
96 if (lastchar != \"~\" && lastchar != \"#\") \
97 printf \"%-12s %s\n\", \"${i}\", substr(\$0,2) }"
101 if [ "$list_hosts" = "true" -o "$list_targets" = "true" ]; then
105 if [ "$host" != "" -a ! -f $srcdir/xconfig/$host ]; then
106 echo "No such host $host"
110 if [ "$target" != "" -a ! -f $srcdir/tconfig/$target ]; then
111 echo "No such target $target"
115 if [ "$bad" = "true" ] ; then
117 echo " $progname [+srcdir=\`dir'] machine"
118 echo " For normal usage"
119 echo " $progname [+srcdir=\`dir'] \`host' \`target'"
120 echo " $progname [+srcdir=\`dir'] +host=\`host' +target=\`target'"
121 echo " If you are doing remote debugging between machines of two"
122 echo " different types (cross-debugging). \`host' is the type of"
123 echo " machine on which GDB will be running. \`target' is the"
124 echo " machine that the program you are debugging will be"
126 echo " $progname +host"
127 echo " Print a list of valid host machine types."
128 echo " $progname +target"
129 echo " Print a list of valid target machine types."
131 echo " +srcdir=\`dir' means that the sources are in \`dir'. For"
132 echo " example, \`cd /obj/hp300; config.gdb +srcdir=/src/gdb hp300'"
133 echo " If +srcdir is not specified, sources can either be in \`.'"
137 if [ -r config.status ]
146 cat $srcdir/xconfig/$host $srcdir/tconfig/$target | awk '$1 == "#msg" {
148 paramfile=${srcdir}/`awk '
149 $1 == "TM_FILE=" { print $2 }' <$srcdir/tconfig/$target`
150 if [ "$paramfile" != "${srcdir}/" ] ; then
151 # Make a symlink if possible, otherwise try a hard link
152 ln -s $paramfile tm.h 2>/dev/null || ln $paramfile tm.h
155 paramfile=${srcdir}/`awk '
156 $1 == "XM_FILE=" { print $2 }' <$srcdir/xconfig/$host`
157 if [ "$paramfile" != "${srcdir}/" ] ; then
158 # Make a symlink if possible, otherwise try a hard link
159 ln -s $paramfile xm.h 2>/dev/null || ln $paramfile xm.h
168 echo "srcdir=${srcdir}" >./Makefile.sdir
169 grep -s "source ${srcdir}/.gdbinit" .gdbinit 2>/dev/null || \
170 echo "source ${srcdir}/.gdbinit" >> .gdbinit
174 make "srcdir=${srcdir}" \
175 "M_MAKEFILE=$srcdir/tconfig/$target $srcdir/xconfig/$host" \
176 -f $srcdir/Makefile.dist Makefile
178 echo "GDB is now set up for host machine $host and target machine $target." \