force all files to end in "/* end of filename"
[platform/upstream/binutils.git] / gas / configure.was
1 #!/bin/sh
2 # Configuration script for GNU GAS
3 #   Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc.
4
5 #This file is not yet part of GNU GAS.
6
7 #GNU GAS is free software; you can redistribute it and/or modify
8 #it under the terms of the GNU General Public License as published by
9 #the Free Software Foundation; either version 1, or (at your option)
10 #any later version.
11
12 #GNU GAS is distributed in the hope that it will be useful,
13 #but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #GNU General Public License for more details.
16
17 #You should have received a copy of the GNU General Public License
18 #along with GNU GAS; see the file COPYING.  If not, write to
19 #the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 # $Id$
22
23 #
24 # Shell script to create proper links to machine-dependent files in
25 # preparation for compiling gas.
26 #
27 # Usage: configure [-srcdir=DIR] [-host=HOST] TARGET
28 #
29 # If configure succeeds, it leaves its status in config.status.
30 # If configure fails after disturbing the status quo, 
31 #       config.status is removed.
32 #
33
34 progname=$0
35
36 remove=rm
37 hard_link=ln
38 symbolic_link='ln -s'
39
40 host=
41 target=
42
43 #for Test
44 #remove="echo rm"
45 #hard_link="echo ln"
46 #symbolic_link="echo ln -s"
47
48 for arg in $*;
49 do
50   case $arg in
51    -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*)
52         srcdir=`echo $arg | sed 's/[+-]s[a-z]*=//'`
53         ;;
54    -host=* | +host=* | +hos=* | +ho=* | +h=*)
55         host=`echo $arg | sed 's/[+-]h[a-z]*=//'`
56         ;; 
57    *)
58 # Allow configure HOST TARGET
59         if [ x$host = x ]
60         then
61                 host=$target
62         fi
63         target=$arg
64         ;;
65   esac
66 done
67
68 # Complain if an arg is missing
69 if [ x$target = x ]
70 then
71         echo "Usage: $progname [+srcdir=DIR] [+host=HOST] TARGET"
72         echo -n "Where HOST and TARGET are something like "
73         echo "\`vax', \`sun3', \`encore', etc."
74         if [ -r config.status ]
75         then
76                 cat config.status
77         fi
78         exit 1
79 fi
80
81 # Default other arg
82 if [ x$host = x ]
83 then
84         host=$target
85 fi
86
87 # Find the source files, if location was not specified.
88 if [ x$srcdir = x ]
89 then
90         srcdirdefaulted=1
91         srcdir=.
92         if [ ! -r as.c ]
93         then
94                 srcdir=..
95         fi
96 fi
97
98 if [ ! -r ${srcdir}/as.c ]
99 then
100         if [ x$srcdirdefaulted = x ]
101         then
102           echo "$progname: Can't find assembler sources in \`${srcdir}'." 1>&2
103         else
104           echo "$progname: Can't find assembler sources in \`.' or \`..'." 1>&2
105         fi
106         exit 1
107 fi
108
109 # Decode the host machine, then the target machine.
110 # For the host machine, we save the ho variable as host_ho;
111 # then we decode the target machine and forget everything else
112 # that came from the host machine.
113 for machine in $host $target; do
114         tc=
115         obj=
116
117         host_header=
118         obj_header=
119         obj_source=
120         te_header=
121         tc_header=
122         tc_source=
123
124         make_var_file=
125
126         case $machine in
127         generic)
128                 ;;
129         i860)
130                 tc=i860
131                 obj=aout
132                 ;;
133         pmax | dec3100)
134                 ho=pmax
135                 ;;
136         sun386)
137                 ho=sun386
138                 ;;
139         sun4 | sun4-aout | sun-4 | sun4-os4 | sun-4-os4)
140                 ho=sun4
141                 tc=sparc
142                 obj=aout
143                 ;;
144         sun4-bout)
145                 tc=sparc
146                 obj=bout
147                 ;;
148         sun4-bfd-sunos)
149                 tc=sparc
150                 obj=bfd-sunos
151                 ;;
152         i960 | i960-coff)
153                 tc=i960
154                 obj=coff
155                 te=ic960
156                 ;;
157         i960-bout)
158                 tc=i960
159                 obj=bout
160                 ;;
161         i960-aout)
162                 tc=i960
163                 obj=aout
164                 ;;
165         sun3 | sun3-aout)
166                 ho=sun3
167                 tc=m68k
168                 obj=aout
169                 te=sun3
170                 ;;
171         a29k | a29k-aout)
172                 tc=a29k
173                 obj=aout
174                 ;;
175         a29k-coff)
176                 tc=a29k
177                 obj=coff
178                 ;;
179         i386)
180                 tc=i386
181                 obj=aout
182                 ;;
183         ns32k)
184                 tc=ns32k
185                 obj=aout
186                 ;;
187         vax)
188                 tc=vax
189                 obj=aout
190                 ;;
191         rs6000)
192                 ;;
193         esac
194         if [ x$pass1done = x ]
195         then
196                 if [ x$ho = x ]; then ho=$host; fi
197                 if [ x$ho_header = x ]; then ho_ho_header=ho-$ho.h
198                 else ho_ho_header=$ho_header
199                 fi
200                 if [ x$make_var_file = x ]
201                 then make_var_file=make-$ho; fi
202                 ho_make_var_file=$make_var_file
203                 pass1done=yes
204         else
205                 host_make_var_file=$ho_make_var_file
206                 ho_header=$ho_ho_header
207         fi
208 done
209
210
211 # Default the machine-specific variables that were not explicitly set.
212 if [ x$te = x ]
213 then te=generic; fi
214
215 if [ x$te_header = x ]
216 then te_header=te-$te.h; fi
217
218
219 if [ x$tc = x ]
220 then tc=generic; fi
221
222 if [ x$tc_header = x ]
223 then tc_header=tc-$tc.h; fi
224
225 if [ x$tc_source = x ]
226 then tc_source=tc-$tc.c; fi
227
228
229 if [ x$obj = x ]
230 then obj=generic; fi
231
232 if [ x$obj_header = x ]
233 then obj_header=obj-$obj.h; fi
234
235 if [ x$obj_source = x ]
236 then obj_source=obj-$obj.c; fi
237
238
239 if [ x$atof_source = x ]
240 then atof_source=atof-ieee.c; fi
241
242 # Set up the list of links to be made.
243 # $links is the list of link names, and $files is the list of names to link to.
244 files="$ho_header $te_header $tc_header $tc_source $obj_header $obj_source $atof_source"
245 links="host.h targ-env.h targ-cpu.h targ-cpu.c obj-format.h obj-format.c atof-targ.c"
246
247 # Make the links.
248 while [ -n "$files" ]
249 do
250         # set file to car of files, files to cdr of files
251         set $files; file=$1; shift; files=$*
252         set $links; link=$1; shift; links=$*
253
254         if [ ! -r ${srcdir}/config/$file ]
255         then
256                 echo "$progname: cannot create a link \`$link'," 1>&2
257                 echo "since the file \`config/$file' does not exist." 1>&2
258                 exit 1
259         fi
260
261         $remove -f $link
262         rm -f config.status
263         # Make a symlink if possible, otherwise try a hard link
264         $symbolic_link ${srcdir}/config/$file $link 2>/dev/null || $hard_link ${srcdir}/config/$file $link
265
266         if [ ! -r $link ]
267         then
268                 echo "$progname: unable to link \`$link' to \`${srcdir}/config/$file'." 1>&2
269                 exit 1
270         fi
271         echo "Linked \`$link' to \`${srcdir}/config/$file'."
272 done
273
274 # Build a Makefile
275
276 # Install a makefile, and make it set srcdir
277 # if necessary so that the sources are found.
278 # Also change its value of srcdir.
279 # Also create a .gdbinit file which runs the one in srcdir
280 # and tells GDB to look there for source files.
281 case $srcdir in
282 .)
283         ;;
284 *)
285         echo "VPATH = ${srcdir}" > x
286         cat x ${srcdir}/Makefile.in | sed "s@^srcdir = \.@srcdir = ${srcdir}@" > Makefile.in
287         rm x
288         echo "dir ." > .gdbinit
289         echo "dir ${srcdir}" >> .gdbinit
290         echo "source ${srcdir}/.gdbinit" >> .gdbinit
291         ;;
292 esac
293
294 # Conditionalize the makefile for this machine.
295 if [ -f ${srcdir}/config/${host_make_var_file} ]
296 then
297         sed -e "/####/  r ${srcdir}/config/${host_make_var_file}" Makefile.in > Makefile.tem
298 else
299         cp Makefile.in Makefile.tem
300 fi
301
302 # Remove all formfeeds, since some Makes get confused by them.
303 sed "s/\f//" Makefile.tem > Makefile.tem1
304
305 # Delete the intermediate files
306 rm Makefile.tem
307 if [ x$srcdir != x. ]
308 then
309         rm Makefile.in
310 fi
311
312
313 # actual Makefile starts here.
314
315 echo "host = $host" > Makefile
316 echo "target = $target" >> Makefile
317
318 # Define macro CROSS_ASSEMBLE in compilation if this is a cross-assembler.
319 if [ x$host = x$target ]
320 then
321         sed "/^ALL=gas/s//ALL=bootstrap/" < Makefile.tem1 >> Makefile
322 else
323         echo "CROSS=-DCROSS_ASSEMBLE" >> Makefile
324         cat Makefile.tem1 >> Makefile
325 fi
326
327 rm Makefile.tem1
328
329 echo "Edited the makefile"
330
331 if [ x$host = x$target ]
332 then
333         echo "Links are now set up for use with a $target." \
334                 | tee config.status
335 else
336         echo "Links are now set up for host $host and target $target." \
337                 | tee config.status
338 fi
339
340 exit 0