* config/irix3.mh (NATDEPFILES): nat-mips.o => mips-nat.o.
[deliverable/binutils-gdb.git] / gdb / config.gdb
CommitLineData
dd3b648e
RP
1#!/bin/sh
2
3# Shell script to do machine-dependent things in
4# preparation for compiling gdb.
5#
6# Usage: config.gdb machine
7#
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.
11
12progname=$0
13host=
14target=
15list_hosts=
16list_targets=
17srcdir=
18
19for arg in $*; do
20 case $arg in
21 -srcdir=*|+srcdir=*)
22 srcdir=`echo $arg | sed 's/[+-]srcdir=//'`
23 ;;
24 -host|+host)
25 list_hosts=true
26 ;;
27 -target|+target)
28 list_targets=true
29 ;;
30 -host=*|+host=*)
31 if [ "$host" = "" ]; then
32 host=`echo $arg | sed 's/[+-]host=//'`
33 else
34 echo Error: Attempt to specify host machine twice
35 bad=true
36 fi
37 ;;
38 -target=*|+target=*)
39 if [ "$target" = "" ]; then
40 target=`echo $arg | sed 's/[+-]target=//'`
41 else
42 echo Error: Attempt to specify target machine twice
43 bad=true
44 fi
45 ;;
46 *)
47 if [ "$host" = "" ]; then
48 host=$arg
49 else
50 if [ "$target" = "" ]; then
51 target=$arg
52 else
53 echo Error: More arguments than host and target machine names
54 bad=true
55 fi
56 fi
57 ;;
58 esac
59done
60
61if [ "$target" = "" ]; then target=$host; fi
62if [ "$host" = "" ]; then bad=true; fi
63
64# Find the source files, if location was not specified
65if [ "$srcdir" = "" ]; then
66 srcdirdefaulted=true
67 srcdir=.
68 if [ ! -r main.c ]; then
69 srcdir=..
70 fi
71fi
72if [ ! -r ${srcdir}/main.c ]; then
73 if [ "$srcdirdefaulted" != "true" ]; then
74 echo "$progname: Can't find debugger sources in \`${srcdir}'." 1>&2
75 else
76 echo "$progname: Can't find debugger sources in \`.' or \`..'." 1>&2
77 fi
78 exit 1
79fi
80
81if [ "$list_hosts" = "true" ]; then
82 cd $srcdir/xconfig
83 for i in * ; do
84# The {} in ${i} are required or else /bin/sh in sony newsos 3.2 removes
85# the quote after it.
86 awk <$i "NR == 1 { lastchar = substr(\"${i}\", length(\"${i}\"), 1)
87if (lastchar != \"~\" && lastchar != \"#\") \
88printf \"%-12s %s\n\", \"${i}\", substr(\$0,2) }"
89 done
90fi
91
92if [ "$list_targets" = "true" ]; then
93 cd $srcdir/tconfig
94 for i in * ; do
95 awk <$i "NR == 1 { lastchar = substr(\"${i}\", length(\"${i}\"), 1)
96if (lastchar != \"~\" && lastchar != \"#\") \
97printf \"%-12s %s\n\", \"${i}\", substr(\$0,2) }"
98 done
99fi
100
101if [ "$list_hosts" = "true" -o "$list_targets" = "true" ]; then
102 exit 0
103fi
104
105if [ "$host" != "" -a ! -f $srcdir/xconfig/$host ]; then
106 echo "No such host $host"
107 bad=true
108fi
109
110if [ "$target" != "" -a ! -f $srcdir/tconfig/$target ]; then
111 echo "No such target $target"
112 bad=true
113fi
114
115if [ "$bad" = "true" ] ; then
116 echo "Usage: "
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"
125 echo " running on."
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."
130 echo
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 \`.'"
134 echo " or \`..'."
135 echo
136
137 if [ -r config.status ]
138 then
139 cat config.status
140 fi
141 exit 1
142fi
143
144rm -f tm.h xm.h
145
146cat $srcdir/xconfig/$host $srcdir/tconfig/$target | awk '$1 == "#msg" {
147 print substr($0,6)}'
148paramfile=${srcdir}/`awk '
149 $1 == "TM_FILE=" { print $2 }' <$srcdir/tconfig/$target`
150if [ "$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
153fi
154
155paramfile=${srcdir}/`awk '
156 $1 == "XM_FILE=" { print $2 }' <$srcdir/xconfig/$host`
157if [ "$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
160fi
161
162rm -f config.status
163
164case ${srcdir} in
165 .)
166 ;;
167 *)
3f2e006b 168 echo "srcdir=${srcdir}" >./Makefile.sdir
dd3b648e
RP
169 grep -s "source ${srcdir}/.gdbinit" .gdbinit 2>/dev/null || \
170 echo "source ${srcdir}/.gdbinit" >> .gdbinit
dd3b648e
RP
171esac
172
33cc288d 173rm -f Makefile
dd3b648e
RP
174make "srcdir=${srcdir}" \
175 "M_MAKEFILE=$srcdir/tconfig/$target $srcdir/xconfig/$host" \
176 -f $srcdir/Makefile.dist Makefile
177
178echo "GDB is now set up for host machine $host and target machine $target." \
179 | tee config.status
180exit 0
This page took 0.068396 seconds and 4 git commands to generate.