| 1 | $! libiberty/vmsbuild.com -- build liberty.olb for VMS host, VMS target | 
|---|
| 2 | $! | 
|---|
| 3 | $ CC    = "gcc /noVerbose/Debug/Incl=([],[-.include])" | 
|---|
| 4 | $ LIBR  = "library /Obj" | 
|---|
| 5 | $ LINK  = "link" | 
|---|
| 6 | $ DELETE= "delete /noConfirm" | 
|---|
| 7 | $ SEARCH= "search /Exact" | 
|---|
| 8 | $ ECHO  = "write sys$output" | 
|---|
| 9 | $ ABORT = "exit %x002C" | 
|---|
| 10 | $! | 
|---|
| 11 | $ LIB_NAME = "liberty.olb"      !this is what we're going to construct | 
|---|
| 12 | $ WORK_LIB = "new-lib.olb"      !used to guard against an incomplete build | 
|---|
| 13 | $ | 
|---|
| 14 | $! manually copied from Makefile.in | 
|---|
| 15 | $ REQUIRED_OFILES = "argv.o basename.o choose-temp.o concat.o cplus-dem.o "- | 
|---|
| 16 | + "fdmatch.o fnmatch.o getopt.o getopt1.o getruntime.o hex.o "- | 
|---|
| 17 | + "floatformat.o objalloc.o obstack.o spaces.o strerror.o strsignal.o "- | 
|---|
| 18 | + "xatexit.o xexit.o xmalloc.o xmemdup.o xstrdup.o xstrerror.o" | 
|---|
| 19 | $! anything not caught by link+search of dummy.* should be added here | 
|---|
| 20 | $ EXTRA_OFILES = "" | 
|---|
| 21 | $! | 
|---|
| 22 | $! move to the directory which contains this command procedure | 
|---|
| 23 | $ old_dir = f$environ("DEFAULT") | 
|---|
| 24 | $ new_dir = f$parse("_._;",f$environ("PROCEDURE")) - "_._;" | 
|---|
| 25 | $ set default 'new_dir' | 
|---|
| 26 | $ | 
|---|
| 27 | $ ECHO "Starting libiberty build..." | 
|---|
| 28 | $ create config.h | 
|---|
| 29 | /* libiberty config.h for VMS */ | 
|---|
| 30 | #define NEED_sys_siglist | 
|---|
| 31 | #define NEED_strsignal | 
|---|
| 32 | #define NEED_psignal | 
|---|
| 33 | #define NEED_basename | 
|---|
| 34 | $ LIBR 'WORK_LIB' /Create | 
|---|
| 35 | $ | 
|---|
| 36 | $! first pass: compile "required" modules | 
|---|
| 37 | $ ofiles = REQUIRED_OFILES + " " + EXTRA_OFILES | 
|---|
| 38 | $ pass = 1 | 
|---|
| 39 | $ gosub do_ofiles | 
|---|
| 40 | $ | 
|---|
| 41 | $! second pass: process dummy.c, using the first pass' results | 
|---|
| 42 | $ ECHO " now checking run-time library for missing functionality" | 
|---|
| 43 | $ if f$search("dummy.obj").nes."" then  DELETE dummy.obj;* | 
|---|
| 44 | $ define/noLog sys$error _NL:   !can't use /User_Mode here due to gcc | 
|---|
| 45 | $ define/noLog sys$output _NL:  ! driver's use of multiple image activation | 
|---|
| 46 | $ on error then continue | 
|---|
| 47 | $ 'CC' dummy.c | 
|---|
| 48 | $ deassign sys$error   !restore, more or less | 
|---|
| 49 | $ deassign sys$output | 
|---|
| 50 | $ if f$search("dummy.obj").eqs."" then  goto pass2_failure1 | 
|---|
| 51 | $! link dummy.obj, capturing full linker feedback in dummy.map | 
|---|
| 52 | $ oldmsg = f$environ("MESSAGE") | 
|---|
| 53 | $ set message /Facility/Severity/Identification/Text | 
|---|
| 54 | $ define/User sys$output _NL: | 
|---|
| 55 | $ define/User sys$error _NL: | 
|---|
| 56 | $ LINK/Map=dummy.map/noExe dummy.obj,'WORK_LIB'/Libr,- | 
|---|
| 57 | gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr | 
|---|
| 58 | $ set message 'oldmsg' | 
|---|
| 59 | $ if f$search("dummy.map").eqs."" then  goto pass2_failure2 | 
|---|
| 60 | $ DELETE dummy.obj;* | 
|---|
| 61 | $ SEARCH dummy.map "%LINK-I-UDFSYM" /Output=dummy.list | 
|---|
| 62 | $ DELETE dummy.map;* | 
|---|
| 63 | $ ECHO " check completed" | 
|---|
| 64 | $! we now have a file with one entry per line of unresolvable symbols | 
|---|
| 65 | $ ofiles = "" | 
|---|
| 66 | $ if f$trnlnm("IFILE$").nes."" then  close/noLog ifile$ | 
|---|
| 67 | $       open/Read ifile$ dummy.list | 
|---|
| 68 | $iloop: read/End=idone ifile$ iline | 
|---|
| 69 | $       iline = f$edit(iline,"COMPRESS,TRIM,LOWERCASE") | 
|---|
| 70 | $       ofiles = ofiles + " " + f$element(1," ",iline) + ".o" | 
|---|
| 71 | $       goto iloop | 
|---|
| 72 | $idone: close ifile$ | 
|---|
| 73 | $ DELETE dummy.list;* | 
|---|
| 74 | $ on error then ABORT | 
|---|
| 75 | $ | 
|---|
| 76 | $! third pass: compile "missing" modules collected in pass 2 | 
|---|
| 77 | $ pass = 3 | 
|---|
| 78 | $ gosub do_ofiles | 
|---|
| 79 | $ | 
|---|
| 80 | $! finish up | 
|---|
| 81 | $ LIBR 'WORK_LIB' /Compress /Output='LIB_NAME'  !new-lib.olb -> liberty.olb | 
|---|
| 82 | $ DELETE 'WORK_LIB';* | 
|---|
| 83 | $ | 
|---|
| 84 | $! all done | 
|---|
| 85 | $ ECHO "Completed libiberty build." | 
|---|
| 86 | $ type sys$input: | 
|---|
| 87 |  | 
|---|
| 88 | You many wish to do | 
|---|
| 89 | $ COPY LIBERTY.OLB GNU_CC:[000000] | 
|---|
| 90 | so that this run-time library resides in the same location as gcc's | 
|---|
| 91 | support library.  When building gas, be sure to leave the original | 
|---|
| 92 | copy of liberty.olb here so that gas's build procedure can find it. | 
|---|
| 93 |  | 
|---|
| 94 | $ set default 'old_dir' | 
|---|
| 95 | $ exit | 
|---|
| 96 | $ | 
|---|
| 97 | $! | 
|---|
| 98 | $! compile each element of the space-delimited list 'ofiles' | 
|---|
| 99 | $! | 
|---|
| 100 | $do_ofiles: | 
|---|
| 101 | $ ofiles = f$edit(ofiles,"COMPRESS,TRIM") | 
|---|
| 102 | $ i = 0 | 
|---|
| 103 | $oloop: | 
|---|
| 104 | $ f = f$element(i," ",ofiles) | 
|---|
| 105 | $ if f.eqs." " then  goto odone | 
|---|
| 106 | $ f = f - ".o"  !strip dummy suffix | 
|---|
| 107 | $ ECHO "  ''f'" | 
|---|
| 108 | $ skip_f = 0 | 
|---|
| 109 | $ if pass.eq.3 .and. f$search("''f'.c").eqs."" then  gosub chk_deffunc | 
|---|
| 110 | $ if .not.skip_f | 
|---|
| 111 | $ then | 
|---|
| 112 | $   'CC' 'f'.c | 
|---|
| 113 | $   LIBR 'WORK_LIB' 'f'.obj /Insert | 
|---|
| 114 | $   DELETE 'f'.obj;* | 
|---|
| 115 | $ endif | 
|---|
| 116 | $ i = i + 1 | 
|---|
| 117 | $ goto oloop | 
|---|
| 118 | $odone: | 
|---|
| 119 | $ return | 
|---|
| 120 | $ | 
|---|
| 121 | $! | 
|---|
| 122 | $! check functions.def for a DEFFUNC() entry corresponding to missing file 'f'.c | 
|---|
| 123 | $! | 
|---|
| 124 | $chk_deffunc: | 
|---|
| 125 | $ define/User sys$output _NL: | 
|---|
| 126 | $ define/User sys$error _NL: | 
|---|
| 127 | $ SEARCH functions.def "DEFFUNC","''f'" /Match=AND | 
|---|
| 128 | $ if (($status.and.%x7FFFFFFF) .eq. 1) | 
|---|
| 129 | $ then | 
|---|
| 130 | $   skip_f = 1 | 
|---|
| 131 | $   open/Append config_h config.h | 
|---|
| 132 | $   write config_h "#define NEED_''f'" | 
|---|
| 133 | $   close config_h | 
|---|
| 134 | $ endif | 
|---|
| 135 | $ return | 
|---|
| 136 | $ | 
|---|
| 137 | $! | 
|---|
| 138 | $pass2_failure1: | 
|---|
| 139 | $! if we reach here, dummy.c failed to compile and we're really stuck | 
|---|
| 140 | $ type sys$input: | 
|---|
| 141 |  | 
|---|
| 142 | Cannot compile the library contents checker (dummy.c + functions.def), | 
|---|
| 143 | so cannot continue! | 
|---|
| 144 |  | 
|---|
| 145 | $! attempt the compile again, without suppressing diagnostic messages this time | 
|---|
| 146 | $ on error then ABORT +0*f$verify(v) | 
|---|
| 147 | $ v = f$verify(1) | 
|---|
| 148 | $ 'CC' dummy.c | 
|---|
| 149 | $ ABORT +0*f$verify(v)  !'f$verify(0)' | 
|---|
| 150 | $! | 
|---|
| 151 | $pass2_failure2: | 
|---|
| 152 | $! should never reach here.. | 
|---|
| 153 | $ type sys$input: | 
|---|
| 154 |  | 
|---|
| 155 | Cannot link the library contents checker (dummy.obj), so cannot continue! | 
|---|
| 156 |  | 
|---|
| 157 | $! attempt the link again, without suppressing diagnostic messages this time | 
|---|
| 158 | $ on error then ABORT +0*f$verify(v) | 
|---|
| 159 | $ v = f$verify(1) | 
|---|
| 160 | $ LINK/Map=dummy.map/noExe dummy.obj,'WORK_LIB'/Libr,- | 
|---|
| 161 | gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr | 
|---|
| 162 | $ ABORT +0*f$verify(v)  !'f$verify(0)' | 
|---|
| 163 | $ | 
|---|
| 164 | $! not reached | 
|---|
| 165 | $ exit | 
|---|