Various fixes for openvms/alpha.
[binutils-gdb.git] / gas / config-gas.com
1 $!
2 $! This file sets things up to build gas on a VMS system to generate object
3 $! files for a VMS system. We do not use the configure script, since we
4 $! do not have /bin/sh to execute it.
5 $!
6 $!
7 $gas_host="vms"
8 $!
9 $arch_indx = 1 + ((f$getsyi("CPU").ge.128).and.1) ! vax==1, alpha==2
10 $arch = f$element(arch_indx,"|","|VAX|Alpha|")
11 $if arch .eqs. "VAX"
12 $then
13 $cpu_type="vax"
14 $obj_format="vms"
15 $atof="vax"
16 $else
17 $ cpu_type="alpha"
18 $ obj_format="evax"
19 $ atof="ieee"
20 $endif
21 $
22 $emulation="generic"
23 $!
24 $ DELETE = "delete/noConfirm"
25 $ ECHO = "write sys$output"
26 $!
27 $! Target specific information
28 $call link targ-cpu.c [.config]tc-'cpu_type'.c
29 $call link targ-cpu.h [.config]tc-'cpu_type'.h
30 $call link targ-env.h [.config]te-'emulation'.h
31 $!
32 $! Code to handle the object file format.
33 $call link obj-format.h [.config]obj-'obj_format'.h
34 $call link obj-format.c [.config]obj-'obj_format'.c
35 $!
36 $! Code to handle floating point.
37 $call link atof-targ.c [.config]atof-'atof'.c
38 $!
39 $!
40 $! Create the file version.opt, which helps identify the executable.
41 $!
42 $if f$trnlnm("IFILE$").nes."" then close/noLog ifile$
43 $search Makefile.in "VERSION="/Exact/Output=config-gas-tmp.tmp
44 $open ifile$ config-gas-tmp.tmp
45 $read ifile$ line
46 $close ifile$
47 $DELETE config-gas-tmp.tmp;*
48 $! Discard "VERSION=" and "\n" parts.
49 $ijk=f$locate("=",line)+1
50 $line=f$extract(ijk,f$length(line)-ijk,line)
51 $! [what "\n" part?? this seems to be useless, but is benign]
52 $ijk=f$locate("\n",line)
53 $line=f$extract(0,ijk,line)
54 $!
55 $ if f$search("version.opt").nes."" then DELETE version.opt;*
56 $copy _NL: version.opt
57 $open/Append ifile$ version.opt
58 $write ifile$ "identification="+""""+line+""""
59 $close ifile$
60 $!
61 $! Now write config.h.
62 $!
63 $ if f$search("config.h").nes."" then DELETE config.h;*
64 $copy _NL: config.h
65 $open/Append ifile$ config.h
66 $write ifile$ "/* config.h. Generated by config-gas.com. */
67 $write ifile$ "#ifndef GAS_VERSION"
68 $write ifile$ "#define GAS_VERSION """,line,""""
69 $write ifile$ "#endif"
70 $write ifile$ "/*--*/"
71 $if arch .eqs. "VAX"
72 $then
73 $append [.config]vms-conf.h ifile$:
74 $else
75 $ append [.config]vms-a-conf.h ifile$:
76 $endif
77 $close ifile$
78 $ECHO "Created config.h."
79 $!
80 $! Check for, and possibly make, header file <unistd.h>.
81 $!
82 $ if f$search("tmp-chk-h.*").nes."" then DELETE tmp-chk-h.*;*
83 $!can't use simple `#include HDR' with `gcc /Define="HDR=<foo.h>"'
84 $!because the 2.6.[0-3] preprocessor handles it wrong (VMS-specific gcc bug)
85 $ create tmp-chk-h.c
86 int tmp_chk_h; /* guarantee non-empty output */
87 #ifdef HAVE_STDIO_H
88 #include <stdio.h>
89 #endif
90 #ifdef HAVE_UNISTD_H
91 #include <unistd.h>
92 #endif
93 #ifdef HAVE_UNIXIO_H
94 #include <unixio.h>
95 #endif
96 #ifdef HAVE_UNIXLIB_H
97 #include <unixlib.h>
98 #endif
99 $ on warning then continue
100 $ CHECK = "call tmp_chk_h"
101 $ CHECK "HAVE_STDIO_H"
102 $ if .not.$status
103 $ then type sys$input:
104
105 ? could not compile <stdio.h>.
106
107 If you're compiling with DEC C or VAX C, create config.status as an
108 empty file and start gnu make again.
109
110 If you're compiling with GNU C, there is some setup problem and
111 gas configuration cannot proceed.
112
113 $ DELETE tmp-chk-h.c;*
114 $ exit %x002C
115 $ endif
116 $!
117 $ CHECK "HAVE_UNISTD_H"
118 $ if .not.$status
119 $ then
120 $ if f$trnlnm("HFILE$").nes."" then close/noLog hfile$
121 $ CHECK "HAVE_UNIXIO_H"
122 $ got_unixio = ($status .and. 1)
123 $ CHECK "HAVE_UNIXLIB_H"
124 $ got_unixlib = ($status .and. 1)
125 $ create []unistd.h !with rudimentary contents
126 /* <unistd.h> substitute for building gas */
127 #ifndef UNISTD_H
128 #define UNISTD_H
129
130 $ open/Append hfile$ []unistd.h
131 $ if got_unixio
132 $ then write hfile$ "#include <unixio.h>"
133 $ else append sys$input: hfile$:
134 /* some of the routines normally prototyped in <unixio.h> */
135 extern int creat(), open(), close(), read(), write();
136 extern int access(), dup(), dup2(), fstat(), stat();
137 extern long lseek();
138 $ endif
139 $ write hfile$ ""
140 $ if got_unixlib
141 $ then write hfile$ "#include <unixlib.h>"
142 $ else append sys$input: hfile$:
143 /* some of the routines normally prototyped in <unixlib.h> */
144 extern char *sbrk(), *getcwd(), *cuserid();
145 extern int brk(), chdir(), chmod(), chown(), mkdir();
146 extern unsigned getuid(), umask();
147 $ endif
148 $ append sys$input: hfile$:
149
150 #endif /*UNISTD_H*/
151 $ close hfile$
152 $ ECHO "Created ""[]unistd.h""."
153 $ endif !gcc '#include <unistd.h>' failed
154 $ DELETE tmp-chk-h.c;*
155 $
156 $tmp_chk_h: subroutine
157 $ set noOn
158 $ hname = f$edit("<" + (p1 - "HAVE_" - "_H") + ".h>","LOWERCASE")
159 $ write sys$output "Checking for ''hname'."
160 $ if f$search("tmp-chk-h.obj").nes."" then DELETE tmp-chk-h.obj;*
161 $ define/noLog sys$error _NL: !can't use /User_Mode here due to gcc
162 $ define/noLog sys$output _NL: ! driver's use of multiple image activation
163 $ gcc /Include=([],[-.include]) /Define=("''p1'") tmp-chk-h.c
164 $!can't just check $status; gcc 2.6.[0-3] preprocessor doesn't set it correctly
165 $ ok = (($status.and.1).and.(f$search("tmp-chk-h.obj").nes."")) .or. %x10000000
166 $ deassign sys$error !restore, more or less
167 $ deassign sys$output
168 $ if ok then DELETE tmp-chk-h.obj;*
169 $ exit ok
170 $ endsubroutine !tmp_chk_h
171 $
172 $!
173 $! Done
174 $!
175 $ if f$search("config.status") .nes. "" then DELETE config.status;*
176 $ open/write cfile []config.status
177 $ write cfile "Links are now set up for use with a "+arch+" running VMS."
178 $ close cfile
179 $ type []config.status
180 $exit
181 $!
182 $!
183 $link:
184 $subroutine
185 $ if f$search(p1).nes."" then DELETE 'p1';*
186 $ copy 'p2' 'p1'
187 $ ECHO "Copied ''f$edit(p2,"LOWERCASE")' to ''f$edit(p1,"LOWERCASE")'."
188 $endsubroutine