1$!
2$! This file configures the bfd library for use with openVMS.
3$!
4$! We do not use the configure script, since we do not have /bin/sh
5$! to execute it.
6$!
7$! Written by Klaus K"ampf (kkaempf@rmi.de)
8$! Rewritten by Tristan Gingold (gingold@adacore.com)
9$!
10$ arch=F$GETSYI("ARCH_NAME")
11$ arch=F$EDIT(arch,"LOWERCASE")
12$if arch .eqs. "alpha" then target = "alpha"
13$if arch .eqs. "ia64" then target = "ia64"
14$!
15$if (arch .eqs. "alpha") .or. (arch .eqs. "ia64")
16$then
17$!
18$ write sys$output "Configuring BFD for ''target' target"
19$!
20$!
21$! copy bfd-in2.h to bfd.h, replacing @ macros
22$!
23$ edit/tpu/nojournal/nosection/nodisplay/command=sys$input -
24        []bfd-in2.h /output=[]bfd.h
25$DECK
26!
27!  Copy file, changing lines with macros (@@)
28!
29!
30   set (success,off);
31   vfile := CREATE_BUFFER("vfile", "CONFIGURE.IN");
32   rang := CREATE_RANGE(BEGINNING_OF(vfile), END_OF(vfile));
33   match_pos := SEARCH_QUIETLY('AM_INIT_AUTOMAKE(bfd, ', FORWARD, EXACT, rang);
34   IF match_pos <> 0 THEN;
35     POSITION(BEGINNING_OF(match_pos));
36     ERASE(match_pos);
37     vers := CURRENT_LINE-")";
38   ELSE;
39     vers := "unknown";
40   ENDIF;
41
42   file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
43   rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file));
44
45   match_pos := SEARCH_QUIETLY('@VERSION@', FORWARD, EXACT, rang);
46   IF match_pos <> 0 THEN;
47      POSITION(BEGINNING_OF(match_pos));
48      ERASE(match_pos);
49      COPY_TEXT(vers);
50   ENDIF;
51   match_pos := SEARCH_QUIETLY('@wordsize@', FORWARD, EXACT, rang);
52   IF match_pos <> 0 THEN;
53      POSITION(BEGINNING_OF(match_pos));
54      ERASE(match_pos);
55      COPY_TEXT('64');
56   ENDIF;
57   match_pos := SEARCH_QUIETLY('@bfd_default_target_size@', FORWARD, EXACT, rang);
58   IF match_pos <> 0 THEN;
59      POSITION(BEGINNING_OF(match_pos));
60      ERASE(match_pos);
61      COPY_TEXT('64');
62   ENDIF;
63   match_pos := SEARCH_QUIETLY('@BFD_HOST_64BIT_LONG@', FORWARD, EXACT, rang);
64   IF match_pos <> 0 THEN;
65      POSITION(BEGINNING_OF(match_pos));
66      ERASE(match_pos);
67      COPY_TEXT('0');
68   ENDIF;
69   match_pos := SEARCH_QUIETLY('@BFD_HOST_LONG_LONG@', FORWARD, EXACT, rang);
70   IF match_pos <> 0 THEN;
71      POSITION(BEGINNING_OF(match_pos));
72      ERASE(match_pos);
73      COPY_TEXT('1');
74   ENDIF;
75   match_pos := SEARCH_QUIETLY('@BFD_HOST_64BIT_LONG_LONG@', FORWARD, EXACT, rang);
76   IF match_pos <> 0 THEN;
77      POSITION(BEGINNING_OF(match_pos));
78      ERASE(match_pos);
79      COPY_TEXT('1');
80   ENDIF;
81   match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT_DEFINED@', FORWARD, EXACT, rang);
82   IF match_pos <> 0 THEN;
83      POSITION(BEGINNING_OF(match_pos));
84      ERASE(match_pos);
85      COPY_TEXT('__DECC');
86      SPLIT_LINE;
87      COPY_TEXT('#include <ints.h>');
88   ENDIF;
89   match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT@', FORWARD, EXACT, rang);
90   IF match_pos <> 0 THEN;
91      POSITION(BEGINNING_OF(match_pos));
92      ERASE(match_pos);
93      COPY_TEXT('int64');
94   ENDIF;
95   match_pos := SEARCH_QUIETLY('@BFD_HOST_U_64_BIT@', FORWARD, EXACT, rang);
96   IF match_pos <> 0 THEN;
97      POSITION(BEGINNING_OF(match_pos));
98      ERASE(match_pos);
99      COPY_TEXT('uint64');
100   ENDIF;
101   match_pos := SEARCH_QUIETLY('@BFD_HOSTPTR_T@', FORWARD, EXACT, rang);
102   IF match_pos <> 0 THEN;
103      POSITION(BEGINNING_OF(match_pos));
104      ERASE(match_pos);
105      COPY_TEXT('uint64');
106   ENDIF;
107   match_pos := SEARCH_QUIETLY('@bfd_file_ptr@', FORWARD, EXACT, rang);
108   IF match_pos <> 0 THEN;
109      POSITION(BEGINNING_OF(match_pos));
110      ERASE(match_pos);
111      COPY_TEXT('bfd_signed_vma');
112   ENDIF;
113   match_pos := SEARCH_QUIETLY('unsigned @bfd_file_ptr@ ufile_ptr', FORWARD, EXACT, rang);
114   IF match_pos <> 0 THEN;
115      POSITION(BEGINNING_OF(match_pos));
116      ERASE(match_pos);
117      COPY_TEXT('bfd_vma ufile_ptr');
118   ENDIF;
119   match_pos := SEARCH_QUIETLY('@supports_plugins@', FORWARD, EXACT, rang);
120   IF match_pos <> 0 THEN;
121      POSITION(BEGINNING_OF(match_pos));
122      ERASE(match_pos);
123      COPY_TEXT('0');
124   ENDIF;
125   WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
126   QUIT
127$  EOD
128$
129$else
130$
131$ write sys$output "Configuring for Vax target"
132$ target = "vax"
133$!
134$! copy bfd-in2.h to bfd.h, replacing @ macros
135$!
136$ write sys$output "Generated `bfd.h' from `bfd-in2.h'."
137$ edit/tpu/nojournal/nosection/nodisplay/command=sys$input -
138        []bfd-in2.h /output=[]bfd.h
139$DECK
140!
141!  Copy file, changing lines with macros (@@)
142!
143!
144   set (success,off);
145   vfile := CREATE_BUFFER("vfile", "CONFIGURE.IN");
146   rang := CREATE_RANGE(BEGINNING_OF(vfile), END_OF(vfile));
147   match_pos := SEARCH_QUIETLY('AM_INIT_AUTOMAKE(bfd, ', FORWARD, EXACT, rang);
148   IF match_pos <> 0 THEN;
149     POSITION(BEGINNING_OF(match_pos));
150     ERASE(match_pos);
151     vers := CURRENT_LINE-")";
152   ELSE;
153     vers := "unknown";
154   ENDIF;
155
156   file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
157   rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file));
158
159   match_pos := SEARCH_QUIETLY('@VERSION@', FORWARD, EXACT, rang);
160   IF match_pos <> 0 THEN;
161      POSITION(BEGINNING_OF(match_pos));
162      ERASE(match_pos);
163      COPY_TEXT(vers);
164   ENDIF;
165   match_pos := SEARCH_QUIETLY('@wordsize@', FORWARD, EXACT, rang);
166   IF match_pos <> 0 THEN;
167      POSITION(BEGINNING_OF(match_pos));
168      ERASE(match_pos);
169      COPY_TEXT('32');
170   ENDIF;
171   match_pos := SEARCH_QUIETLY('@BFD_HOST_64BIT_LONG@', FORWARD, EXACT, rang);
172   IF match_pos <> 0 THEN;
173      POSITION(BEGINNING_OF(match_pos));
174      ERASE(match_pos);
175      COPY_TEXT('0');
176   ENDIF;
177   match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT_DEFINED@', FORWARD, EXACT, rang);
178   IF match_pos <> 0 THEN;
179      POSITION(BEGINNING_OF(match_pos));
180      ERASE(match_pos);
181      COPY_TEXT('__DECC');
182      SPLIT_LINE;
183      COPY_TEXT('#include <ints.h>');
184   ENDIF;
185   match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT@', FORWARD, EXACT, rang);
186   IF match_pos <> 0 THEN;
187      POSITION(BEGINNING_OF(match_pos));
188      ERASE(match_pos);
189      COPY_TEXT('int64');
190   ENDIF;
191   match_pos := SEARCH_QUIETLY('@BFD_HOST_U_64_BIT@', FORWARD, EXACT, rang);
192   IF match_pos <> 0 THEN;
193      POSITION(BEGINNING_OF(match_pos));
194      ERASE(match_pos);
195      COPY_TEXT('uint64');
196   ENDIF;
197   WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
198   QUIT
199$  EOD
200$endif
201$
202$!
203$! create bfdver.h
204$!
205$ write sys$output "Generate `bfdver.h' from 'version.h' and `configure.in'."
206$ edit/tpu/nojournal/nosection/nodisplay/command=sys$input -
207        []version.h /output=[]bfdver.h
208$DECK
209!
210!  Copy file, changing lines with macros (@@)
211!
212!
213   set (success,off);
214   vfile := CREATE_BUFFER("vfile", "configure.in");
215   rang := CREATE_RANGE(BEGINNING_OF(vfile), END_OF(vfile));
216   match_pos := SEARCH_QUIETLY('AM_INIT_AUTOMAKE(bfd, ', FORWARD, EXACT, rang);
217   IF match_pos <> 0 THEN;
218     POSITION(BEGINNING_OF(match_pos));
219     ERASE(match_pos);
220     vers := CURRENT_LINE-")";
221   ELSE;
222     vers := "unknown";
223   ENDIF;
224   versnum := vers - "." - ".";
225
226   file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
227   rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file));
228
229   match_pos := SEARCH_QUIETLY('@bfd_version@', FORWARD, EXACT, rang);
230   IF match_pos <> 0 THEN;
231      POSITION(BEGINNING_OF(match_pos));
232      ERASE(match_pos);
233      COPY_TEXT(versnum);
234   ENDIF;
235   match_pos := SEARCH_QUIETLY('@bfd_version_string@', FORWARD, EXACT, rang);
236   IF match_pos <> 0 THEN;
237      POSITION(BEGINNING_OF(match_pos));
238      ERASE(match_pos);
239      COPY_TEXT('"');
240      COPY_TEXT(vers);
241      COPY_TEXT('"');
242   ENDIF;
243   match_pos := SEARCH_QUIETLY('@bfd_version_package@', FORWARD, EXACT, rang);
244   IF match_pos <> 0 THEN;
245      POSITION(BEGINNING_OF(match_pos));
246      ERASE(match_pos);
247      COPY_TEXT('"(GNU Binutils) "');
248   ENDIF;
249   match_pos := SEARCH_QUIETLY('@report_bugs_to@', FORWARD, EXACT, rang);
250   IF match_pos <> 0 THEN;
251      POSITION(BEGINNING_OF(match_pos));
252      ERASE(match_pos);
253      COPY_TEXT('"<http://www.sourceware.org/bugzilla/>"');
254   ENDIF;
255   WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
256   QUIT
257$  EOD
258$!
259$!
260$! create bfd_stdint.h
261$!
262$ write sys$output "Generate `bfd_stdint.h'"
263$ create []bfd_stdint.h
264#include <inttypes.h>
265$!
266$!
267$! create targmatch.h
268$!
269$ write sys$output "Generate `targmatch.h'"
270$ open/write tfile []targmatch.h
271$ write tfile "{ """ + target + "-*-*vms*""" + ","
272$ write tfile "#if defined (SELECT_VECS)"
273$ write tfile "SELECT_VECS"
274$ write tfile "#else"
275$ write tfile "UNSUPPORTED_TARGET"
276$ write tfile "#endif"
277$ write tfile "},"
278$ close tfile
279$!
280$!
281$! create config.h
282$!
283$ write sys$output "Generate `config.h'"
284$ create []config.h
285/* config.h-vms.  Generated by hand by Klaus K�mpf, kkaempf@didymus.rmi.de.  */
286/* config.in.  Generated automatically from configure.in by autoheader.  */
287/* Whether malloc must be declared even if <stdlib.h> is included.  */
288/* #undef NEED_DECLARATION_MALLOC */
289/* Whether free must be declared even if <stdlib.h> is included.  */
290/* #undef NEED_DECLARATION_FREE */
291/* Define if you have a working `mmap' system call.  */
292/* #define HAVE_MMAP 1 */
293/* Do we need to use the b modifier when opening binary files?  */
294/* #undef USE_BINARY_FOPEN */
295/* Name of host specific header file to include in trad-core.c.  */
296/* #undef TRAD_HEADER */
297/* Define only if <sys/procfs.h> is available *and* it defines prstatus_t.  */
298/* #undef HAVE_SYS_PROCFS_H */
299/* Do we really want to use mmap if it's available?  */
300/* #undef USE_MMAP */
301/* Define if you have the fcntl function.  */
302#define HAVE_FCNTL 1
303/* Define if you have the getpagesize function.  */
304#define HAVE_GETPAGESIZE 1
305/* Define if you have the madvise function.  */
306#define HAVE_MADVISE 1
307/* Define if you have the mprotect function.  */
308#define HAVE_MPROTECT 1
309/* Define if you have the <fcntl.h> header file.  */
310#define HAVE_FCNTL_H 1
311/* Define if you have the <stddef.h> header file.  */
312#define HAVE_STDDEF_H 1
313/* Define if you have the <stdlib.h> header file.  */
314#define HAVE_STDLIB_H 1
315/* Define if you have the <string.h> header file.  */
316#define HAVE_STRING_H 1
317/* Define if you have the <strings.h> header file.  */
318#define HAVE_STRINGS_H 1
319/* Define if you have the <sys/file.h> header file.  */
320#define HAVE_SYS_FILE_H 1
321/* Define if you have the <time.h> header file.  */
322#define HAVE_TIME_H 1
323/* Define if you have the <unistd.h> header file.  */
324#define HAVE_UNISTD_H 1
325/* Disable NLS  */
326#undef ENABLE_NLS
327$!
328$ write sys$output "Copy sysdep.h"
329$ copy [.hosts]alphavms.h sysdep.h
330$
331$ write sys$output "Generate build.com"
332$!
333$ if ARCH.eqs."alpha"
334$ then
335$   create build.com
336$DECK
337$ DEFS="""SELECT_VECS=&vms_alpha_vec"","+-
338  """SELECT_ARCHITECTURES=&bfd_alpha_arch"""
339$ FILES="cpu-alpha,vms,vms-hdr,vms-gsd,vms-tir,vms-misc,"
340$EOD
341$ endif
342$ if ARCH.eqs."ia64"
343$ then
344$   create build.com
345$DECK
346$ DEFS="""SELECT_VECS=&bfd_elf64_ia64_vms_vec"","+-
347  """SELECT_ARCHITECTURES=&bfd_ia64_arch"""
348$ FILES="cpu-ia64,elf64-ia64,elf-strtab,corefile,stabs,merge,elf-eh-frame,"+-
349  "elflink,elf-attrs,dwarf1,elf64,"
350$EOD
351$ create substxx.tpu
352$DECK
353   set (success,off);
354   file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
355   found_range := CREATE_RANGE(BEGINNING_OF(file), BEGINNING_OF(file));
356
357   LOOP
358     rang := CREATE_RANGE (END_OF(found_range),END_OF(file));
359     match_pos := SEARCH_QUIETLY('NN', FORWARD, EXACT, rang);
360     EXITIF match_pos = 0;
361     POSITION(BEGINNING_OF(match_pos));
362     ERASE(match_pos);
363     COPY_TEXT('64');
364   ENDLOOP;
365   WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
366   QUIT
367$  EOD
368$ write sys$output "Generate elf64-ia64.c from elfxx-ia64.c"
369$ edit/tpu/nojournal/nosection/nodisplay/command=substxx.tpu -
370        []elfXX-ia64.c /output=[]elf64-ia64.c
371$ write sys$output "Generate elf64-target.h from elfxx-target.h"
372$ edit/tpu/nojournal/nosection/nodisplay/command=substxx.tpu -
373        []elfXX-target.h /output=[]elf64-target.h
374$ del substxx.tpu;*
375$ endif
376$ append sys$input build.com
377$DECK
378$ DEFS=DEFS + ",""unlink=remove"",""DEBUGDIR=""""GNU$DEBUGDIR:"""""""
379$ OPT="/noopt/debug"
380$ CFLAGS="/name=(as_is,shortened)" + -
381  "/include=([],""../"",""../include"")" + -
382  "/define=(" + DEFS + ")" + OPT
383$ FILES=FILES + "archive,archive64,archures,bfd,bfdio,binary,cache,coffgen,"+-
384  "compress,corefile,dwarf2,elf,format,hash,ihex,init,libbfd,linker,"+-
385  "opncls,reloc,section,simple,srec,stab-syms,syms,targets,tekhex,verilog"
386$ write sys$output "CFLAGS=",CFLAGS
387$ cflags_libbfd="/warning=(disable=missingreturn)"
388$ cflags_nil=""
389$ NUM = 0
390$ OBJS=""
391$ LOOP:
392$   F = F$ELEMENT(NUM,",",FILES)
393$   IF F.EQS."," THEN GOTO END
394$   eflags_name="cflags_''f'"
395$   name_len=f$length(eflags_name)
396$   dash_pos=f$locate("-",eflags_name)
397$   if dash_pos.ne.name_len
398$   then
399$     eflags_name['dash_pos,1]:="_"
400$     dash_pos=f$locate("-",eflags_name)
401$     if dash_pos.ne.name_len then eflags_name['dash_pos,1]:="_"
402$   endif
403$   if f$type('eflags_name).eqs."" then eflags_name="cflags_nil"
404$   eflags='eflags_name
405$   write sys$output "Compiling ", F, ".c", eflags
406$   cc 'CFLAGS 'eflags 'F.c
407$   IF OBJS.NES."" THEN OBJS=OBJS + ","
408$   OBJS=OBJS + F + ".obj"
409$   NUM = NUM + 1
410$   GOTO LOOP
411$ END:
412$ purge
413$ lib/create libbfd 'OBJS
414$EOD
415