*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / config.gdb
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
12 progname=$0
13 host=
14 target=
15 list_hosts=
16 list_targets=
17 srcdir=
18
19 for 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
59 done
60
61 if [ "$target" = "" ]; then target=$host; fi
62 if [ "$host" = "" ]; then bad=true; fi
63
64 # Find the source files, if location was not specified
65 if [ "$srcdir" = "" ]; then
66 srcdirdefaulted=true
67 srcdir=.
68 if [ ! -r main.c ]; then
69 srcdir=..
70 fi
71 fi
72 if [ ! -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
79 fi
80
81 if [ "$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)
87 if (lastchar != \"~\" && lastchar != \"#\") \
88 printf \"%-12s %s\n\", \"${i}\", substr(\$0,2) }"
89 done
90 fi
91
92 if [ "$list_targets" = "true" ]; then
93 cd $srcdir/tconfig
94 for i in * ; do
95 awk <$i "NR == 1 { lastchar = substr(\"${i}\", length(\"${i}\"), 1)
96 if (lastchar != \"~\" && lastchar != \"#\") \
97 printf \"%-12s %s\n\", \"${i}\", substr(\$0,2) }"
98 done
99 fi
100
101 if [ "$list_hosts" = "true" -o "$list_targets" = "true" ]; then
102 exit 0
103 fi
104
105 if [ "$host" != "" -a ! -f $srcdir/xconfig/$host ]; then
106 echo "No such host $host"
107 bad=true
108 fi
109
110 if [ "$target" != "" -a ! -f $srcdir/tconfig/$target ]; then
111 echo "No such target $target"
112 bad=true
113 fi
114
115 if [ "$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
142 fi
143
144 rm -f tm.h xm.h
145
146 cat $srcdir/xconfig/$host $srcdir/tconfig/$target | awk '$1 == "#msg" {
147 print substr($0,6)}'
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
153 fi
154
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
160 fi
161
162 rm -f config.status
163
164 case ${srcdir} in
165 .)
166 ;;
167 *)
168 echo "srcdir=${srcdir}" >./Makefile.sdir
169 grep -s "source ${srcdir}/.gdbinit" .gdbinit 2>/dev/null || \
170 echo "source ${srcdir}/.gdbinit" >> .gdbinit
171 esac
172
173 rm -f Makefile
174 make "srcdir=${srcdir}" \
175 "M_MAKEFILE=$srcdir/tconfig/$target $srcdir/xconfig/$host" \
176 -f $srcdir/Makefile.dist Makefile
177
178 echo "GDB is now set up for host machine $host and target machine $target." \
179 | tee config.status
180 exit 0
This page took 0.033772 seconds and 4 git commands to generate.