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